由于spring禁用了某些方法的CSRF令牌,例如GET,我们如何为所有请求启用CSRF令牌验证,包括使用spring安全的GET。
发布于 2021-01-09 14:01:33
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().requireCsrfProtectionMatcher(AnyRequestMatcher.INSTANCE);
}
}
注意:这种配置意味着任何请求都需要csrf令牌,这是不必要的,也很难实现
https://stackoverflow.com/questions/65636511
复制相似问题