我試圖插入數據使用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