Spring boot 当我发送JSSessionID时,Spring Boot基本身份验证忽略了授权头?
我正在使用Spring Security进行基本身份验证。我的安全适配器如下所示:Spring boot 当我发送JSSessionID时,Spring Boot基本身份验证忽略了授权头?,spring-boot,spring-security,http-authentication,Spring Boot,Spring Security,Http Authentication,我正在使用Spring Security进行基本身份验证。我的安全适配器如下所示: @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth)
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("user").password(passwordEncoder().encode("pass")).authorities("ROLE_USER");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/securityNone").permitAll()
.anyRequest().authenticated()
.and()
.httpBasic().and().cors().and().csrf().disable();
}
}
当我使用浏览器或REST客户机发出请求时,我使用Base64中编码的用户和密码设置授权
标题。它工作正常,服务器返回一个JSESSIONID
,并存储在Cookie中
在第一次身份验证之后,我感到困惑。当我尝试进行后续请求但更改授权
标题时,它仍然有效给我状态200 OK
。我注意到它还发送JSESSIONID
所以我的问题是:基本安全性是否只验证授权
头一次
另外:当我在浏览器上更改JSESSIONID
cookie时,请求仍然有效
有人能解释一下这个过程是如何工作的吗
提前谢谢 如果会话中已经存在有效的
身份验证
,则将忽略标头。如果更改会话id(或删除cookie),但保留身份验证标头,则只需重新进行身份验证。因此,如果我有有效的JSESSIONID,spring security将忽略授权标头?是的,除非以无状态方式使用spring security,否则它将永远不会在会话中存储信息。