我遵循本指南https://spring.io/guides/gs/securing-web/guide为我的微服务设置spring安全性
我只是发送基本的帖子,并收到请求。我可以收到请求,但是当我尝试发送请求时,我会收到403个错误(“未找到预期的CSRF令牌。您的会话是否过期了?”)我试图为我的微服务设置基本的身份验证
谢谢
发布于 2015-10-16 22:58:55
默认情况下启用csrf保护。您必须将所有页面配置为包含_csrf令牌才能工作(参见此处:CSRF弹簧文档 )
您可以始终禁用csrf保护。如果在代码中配置:
@EnableWebSecurity
public class WebSecurityConfig extends
WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.csrf().disable();
}
}或者在XML中:
<http>
<!-- ... -->
<csrf disabled="true"/>
</http>https://stackoverflow.com/questions/33180090
复制相似问题