【发布时间】:2018-07-21 18:26:48
【问题描述】:
我有工作的 Spring Boot 应用程序,其中启用了 csrf,但现在我只想为 localhost 禁用它。来自其他域的任何请求都必须通过 csrf 安全性,但对于 localhost,我想禁用它。我怎样才能做到这一点?
我知道如何通过更改来禁用它
@Configuration
@EnableWebMvcSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf.disable();
}
}
上面的代码禁用了 csrf,但我想为唯一的 localhost 禁用 csrf。
你能帮帮我吗?
编辑:我知道如何通过两个配置文件来做到这一点。感谢@daren 的详细回答。
【问题讨论】:
-
在 localhost 上禁用它是什么意思?
标签: spring-boot spring-security csrf