问题描述
我正在使用Spring Security进行基本身份验证。我的安全适配器如下所示:
@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中编码的用户和密码来设置Authorization
头。并且工作正常,服务器返回一个JSESSIONID
,并将其存储在Cookie中。
第一次认证后,我感到困惑。当我尝试发出后续请求但更改Authorization
标头它仍然有效时,我的状态为200 OK
。我注意到它还会发送JSESSIONID
。
所以我的问题是:基本安全性仅对Authorization
标头进行一次验证吗?
此外:当我在浏览器上更改JSESSIONID
cookie时,请求仍然有效。
有人可以阐明该过程如何工作吗?
提前谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)