【发布时间】:2015-05-22 21:10:56
【问题描述】:
我试图为某些特定的 api 调用启用 csrf 过滤器,而其他人则不需要 csrf 过滤器。我所做的是
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests().antMatchers("/public/**").permitAll();
http.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint);
http.csrf().disable().addFilterBefore(new StatelessCSRFFilter(), CsrfFilter.class).authorizeRequests().antMatchers("/rest/**").permitAll();
}
问题是当我调用 localhost:8080/public/hello 时
显示错误
"message": "CSRF-token 缺失或不匹配"
我正在使用 Spring Boot 和 Spring Security。
感谢您的帮助。
【问题讨论】:
标签: java spring spring-mvc spring-security spring-boot