【发布时间】:2015-08-08 17:59:42
【问题描述】:
我正在尝试使用 POST 请求插入数据,但出现 403 错误。当我使用 GET 时,基本身份验证有效。对于测试,我使用 Fiddler。
有什么问题?
安全配置:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/**").hasRole("USER").and()
.httpBasic();
}
@Override
protected void configure(AuthenticationManagerBuilder auth)
throws Exception {
auth
.inMemoryAuthentication()
.withUser("user")
.password("password")
.roles("USER");
}
}
请求 - POST:
User-Agent: Fiddler
Host: localhost:8080
Content-Length: 200
Content-Type: application/json
Authorization: Basic dXNlcjpwYXNzd29yZA==
请求正文:
{"name" : "name1",
"description" : "desc1"}
【问题讨论】:
标签: java spring spring-security spring-boot basic-authentication