Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring security 为什么Spring安全异常转换过滤器为默认配置创建403响应代码_Spring Security - Fatal编程技术网

Spring security 为什么Spring安全异常转换过滤器为默认配置创建403响应代码

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

我对春天的安全地带还很陌生。我将Spring安全性的编程配置与servletApi一起使用,这非常简洁

以下是配置:

  @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,是否会产生问题? 谢谢