【发布时间】:2016-08-05 17:19:50
【问题描述】:
我有一个 Spring HttpSecurity 配置
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
http.csrf().disable().httpBasic().and()
.authorizeRequests()
.antMatchers("/public/**").permitAll()
.antMatchers("/secure/**").authenticated()
.antMatchers("/backend/**").authenticated()
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll();
}
客户端为“/public/**”端点设置授权标头可能很愚蠢。
但是,我注意到 Spring Security 尝试进行身份验证尝试为公共请求创建经过身份验证的会话,因为提供了授权标头。
HttpSecurity 配置不应该覆盖此行为吗?
【问题讨论】:
-
不,它不应该......允许所有的东西都不同,因为根本没有安全。对于后者,覆盖
configure(WebSecurity)并使用ignoring根本没有安全性。 -
谢谢!为什么我需要两个安全配置?
-
它们都有不同的用途。
标签: spring spring-security spring-boot spring-data spring-web