Spring security 为什么Spring安全异常转换过滤器为默认配置创建403响应代码
我对春天的安全地带还很陌生。我将Spring安全性的编程配置与servletApi一起使用,这非常简洁 以下是配置:Spring security 为什么Spring安全异常转换过滤器为默认配置创建403响应代码,spring-security,Spring Security,我对春天的安全地带还很陌生。我将Spring安全性的编程配置与servletApi一起使用,这非常简洁 以下是配置: @Override protected void configure(HttpSecurity http) throws Exception { http .securityContext().and() .servletApi().and() .authorizeUrls() .ant
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.securityContext().and()
.servletApi().and()
.authorizeUrls()
.antMatchers("/login").permitAll()
.antMatchers("/").permitAll()
.antMatchers("/**").authenticated();
}
我正在使用HTTPServletAPI登录,我没有为此使用任何过滤器
如果是未经授权的请求,ExceptionTranslationFilter使用Http403EntryForbiddenEntryPoint返回403禁止状态
在我的场景中:
若用户未通过身份验证,则应返回401状态码。
如果用户已验证但未授权,则应返回403状态代码。
但默认配置会为这两种情况创建403状态
以下是我的问题:
为什么默认入口点是Http403EntryForbiddenEntryPoint?可能是401?
如果我将Http403EntryForbiddenEntryPoint更改为Http401EntryForbiddenEntryPoint,是否会产生问题?
谢谢