我试图插入数据使用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"}
THX禁用CSRF,但它不工作也。 – Bakus123
不太清楚:你是否正在尝试使用表单和POST登录/插入数据等,而不是使用SpringSecurity,但GET呢? – Asura