Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.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
Java 使用CustomAuthenticationFilter获取403错误_Java_Spring_Spring Boot_Spring Security - Fatal编程技术网

Java 使用CustomAuthenticationFilter获取403错误

Java 使用CustomAuthenticationFilter获取403错误,java,spring,spring-boot,spring-security,Java,Spring,Spring Boot,Spring Security,使用默认的UsernamePasswordAuthenticationFilter时,它正在工作并返回accesstoken,但在实现我的CustomAuthenticationFilter后,它开始给出403错误。我不确定是否缺少任何配置 下面是我的securtiyconfig类 @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) public class WebSecurit

使用默认的UsernamePasswordAuthenticationFilter时,它正在工作并返回accesstoken,但在实现我的CustomAuthenticationFilter后,它开始给出403错误。我不确定是否缺少任何配置 下面是我的securtiyconfig类

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
    
    @Autowired
    private UserDetailsService userDetailsService;

    @Override
    @Bean
    public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder(10);
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
        .addFilterBefore(authenticationFilter(), UsernamePasswordAuthenticationFilter.class)
        .csrf().disable()
        .authorizeRequests().anyRequest()
        .authenticated().and()
        .sessionManagement()
        .sessionCreationPolicy(SessionCreationPolicy.NEVER);
    }
    
    @Bean
    public CustomAuthenticationFilter authenticationFilter() throws Exception {
        CustomAuthenticationFilter filter = new CustomAuthenticationFilter();
        filter.setAuthenticationManager(authenticationManagerBean());
        filter.setAuthenticationFailureHandler(failureHandler());
        filter.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher("/oauth/token", "POST"));
        System.out.println("Filter created");
        return filter;
    }
    
    public SimpleUrlAuthenticationFailureHandler failureHandler() {
        return new SimpleUrlAuthenticationFailureHandler();
    }
    
    
}
下面是我的CustomAuthenticationFilter类

public class CustomAuthenticationFilter extends UsernamePasswordAuthenticationFilter {

    @Override
    public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) 
        throws AuthenticationException {

        if (!request.getMethod().equals("POST")) {
            throw new AuthenticationServiceException("Authentication method not supported: " 
              + request.getMethod());
        }
        System.out.println("Custom Filter Called");
        CustomAuthenticationToken authRequest = getAuthRequest(request);
        setDetails(request, authRequest);
        return this.getAuthenticationManager().authenticate(authRequest);
    }

    private CustomAuthenticationToken getAuthRequest(HttpServletRequest request) {
        String username = obtainUsername(request);
        String password = obtainPassword(request);
        String flag = obtainFlag(request);
        if (username == null) {
            username = "";
        }
        if (password == null) {
            password = "";
        }
        if (flag == null) {
            flag = "";
        }

        return new CustomAuthenticationToken(username, password, domain);
    }

    private String obtainFlag(HttpServletRequest request) {
        return request.getParameter("flag");
    }
}
下面是CustomAuthenticationFilter的日志,该日志正在产生问题:

2020-11-14 18:09:37,553 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/oauth/token']
2020-11-14 18:09:37,554 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Checking match of request : '/oauth/token'; against '/oauth/token'
2020-11-14 18:09:37,557 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.OrRequestMatcher: matched
2020-11-14 18:09:37,560 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token at position 1 of 11 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2020-11-14 18:09:37,562 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token at position 2 of 11 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2020-11-14 18:09:37,564 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token at position 3 of 11 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2020-11-14 18:09:37,570 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token at position 4 of 11 in additional filter chain; firing Filter: 'LogoutFilter'
2020-11-14 18:09:37,572 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/logout', GET]
2020-11-14 18:09:37,572 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Request 'POST /oauth/token' doesn't match 'GET /logout'
2020-11-14 18:09:37,573 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/logout', POST]
2020-11-14 18:09:37,573 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Checking match of request : '/oauth/token'; against '/logout'
2020-11-14 18:09:37,575 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/logout', PUT]
2020-11-14 18:09:37,575 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Request 'POST /oauth/token' doesn't match 'PUT /logout'
2020-11-14 18:09:37,575 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/logout', DELETE]
2020-11-14 18:09:37,576 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Request 'POST /oauth/token' doesn't match 'DELETE /logout'
2020-11-14 18:09:37,576 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.OrRequestMatcher: No matches found
2020-11-14 18:09:37,577 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token at position 5 of 11 in additional filter chain; firing Filter: 'BasicAuthenticationFilter'
2020-11-14 18:09:37,581 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.authentication.www.BasicAuthenticationFilter: Basic Authentication Authorization header found for user 'mobile'
2020-11-14 18:09:37,582 DEBUG [http-nio-9191-exec-2] org.springframework.security.authentication.ProviderManager: Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
2020-11-14 18:09:38,274 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.authentication.www.BasicAuthenticationFilter: Authentication success: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@3fb5dc02: Principal: org.springframework.security.core.userdetails.User@c04a90a2: Username: mobile; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Not granted any authorities; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Not granted any authorities
2020-11-14 18:09:38,274 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token at position 6 of 11 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2020-11-14 18:09:38,275 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.savedrequest.HttpSessionRequestCache: saved request doesn't match
2020-11-14 18:09:38,275 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token at position 7 of 11 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2020-11-14 18:09:38,276 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token at position 8 of 11 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2020-11-14 18:09:38,276 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.authentication.AnonymousAuthenticationFilter: SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@3fb5dc02: Principal: org.springframework.security.core.userdetails.User@c04a90a2: Username: mobile; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Not granted any authorities; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Not granted any authorities'
2020-11-14 18:09:38,278 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token at position 9 of 11 in additional filter chain; firing Filter: 'SessionManagementFilter'
2020-11-14 18:09:38,278 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.authentication.session.CompositeSessionAuthenticationStrategy: Delegating to org.springframework.security.web.authentication.session.ChangeSessionIdAuthenticationStrategy@3872867d
2020-11-14 18:09:38,278 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token at position 10 of 11 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2020-11-14 18:09:38,278 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token at position 11 of 11 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2020-11-14 18:09:38,279 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Checking match of request : '/oauth/token'; against '/oauth/token'
2020-11-14 18:09:38,279 DEBUG [http-nio-9191-exec-2] org.springframework.security.access.intercept.AbstractSecurityInterceptor: Secure object: FilterInvocation: URL: /oauth/token; Attributes: [fullyAuthenticated]
2020-11-14 18:09:38,280 DEBUG [http-nio-9191-exec-2] org.springframework.security.access.intercept.AbstractSecurityInterceptor: Previously Authenticated: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@3fb5dc02: Principal: org.springframework.security.core.userdetails.User@c04a90a2: Username: mobile; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Not granted any authorities; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Not granted any authorities
2020-11-14 18:09:38,288 DEBUG [http-nio-9191-exec-2] org.springframework.security.access.vote.AffirmativeBased: Voter: org.springframework.security.web.access.expression.WebExpressionVoter@740de2fe, returned: 1
2020-11-14 18:09:38,290 DEBUG [http-nio-9191-exec-2] org.springframework.security.access.intercept.AbstractSecurityInterceptor: Authorization successful
2020-11-14 18:09:38,290 DEBUG [http-nio-9191-exec-2] org.springframework.security.access.intercept.AbstractSecurityInterceptor: RunAsManager did not change Authentication object
2020-11-14 18:09:38,290 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: /oauth/token reached end of additional filter chain; proceeding with original chain
2020-11-14 18:09:38,291 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Checking match of request : '/oauth/token'; against '/oauth/token'
Custom Filter Called
2020-11-14 18:09:38,291 DEBUG [http-nio-9191-exec-2] org.springframework.security.authentication.ProviderManager: Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
2020-11-14 18:09:38,920 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.authentication.AbstractAuthenticationTargetUrlRequestHandler: Using default Url: /
2020-11-14 18:09:38,921 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.DefaultRedirectStrategy: Redirecting to '/'
2020-11-14 18:09:38,922 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.header.writers.HstsHeaderWriter: Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@7b48ce75
2020-11-14 18:09:38,923 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.access.ExceptionTranslationFilter: Chain processed normally
2020-11-14 18:09:38,923 DEBUG [http-nio-9191-exec-2] org.springframework.security.web.context.SecurityContextPersistenceFilter: SecurityContextHolder now cleared, as request processing completed
2020-11-14 18:09:38,938 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/oauth/token']
2020-11-14 18:09:38,939 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Checking match of request : '/'; against '/oauth/token'
2020-11-14 18:09:38,939 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/oauth/token_key']
2020-11-14 18:09:38,940 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Checking match of request : '/'; against '/oauth/token_key'
2020-11-14 18:09:38,940 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/oauth/check_token']
2020-11-14 18:09:38,940 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Checking match of request : '/'; against '/oauth/check_token'
2020-11-14 18:09:38,940 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.OrRequestMatcher: No matches found
2020-11-14 18:09:38,940 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: / at position 1 of 11 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2020-11-14 18:09:38,941 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: / at position 2 of 11 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2020-11-14 18:09:38,941 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.context.HttpSessionSecurityContextRepository: No HttpSession currently exists
2020-11-14 18:09:38,941 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.context.HttpSessionSecurityContextRepository: No SecurityContext was available from the HttpSession: null. A new one will be created.
2020-11-14 18:09:38,942 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: / at position 3 of 11 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2020-11-14 18:09:38,943 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: / at position 4 of 11 in additional filter chain; firing Filter: 'LogoutFilter'
2020-11-14 18:09:38,943 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/logout', GET]
2020-11-14 18:09:38,943 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Checking match of request : '/'; against '/logout'
2020-11-14 18:09:38,944 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/logout', POST]
2020-11-14 18:09:38,944 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Request 'GET /' doesn't match 'POST /logout'
2020-11-14 18:09:38,944 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/logout', PUT]
2020-11-14 18:09:38,945 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Request 'GET /' doesn't match 'PUT /logout'
2020-11-14 18:09:38,945 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.OrRequestMatcher: Trying to match using Ant [pattern='/logout', DELETE]
2020-11-14 18:09:38,945 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Request 'GET /' doesn't match 'DELETE /logout'
2020-11-14 18:09:38,946 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.OrRequestMatcher: No matches found
2020-11-14 18:09:38,946 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: / at position 5 of 11 in additional filter chain; firing Filter: 'CustomAuthenticationFilter'
2020-11-14 18:09:38,946 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.util.matcher.AntPathRequestMatcher: Request 'GET /' doesn't match 'POST /oauth/token'
2020-11-14 18:09:38,946 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: / at position 6 of 11 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2020-11-14 18:09:38,947 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.savedrequest.HttpSessionRequestCache: saved request doesn't match
2020-11-14 18:09:38,947 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: / at position 7 of 11 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2020-11-14 18:09:38,947 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: / at position 8 of 11 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2020-11-14 18:09:38,948 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.authentication.AnonymousAuthenticationFilter: Populated SecurityContextHolder with anonymous token: 'org.springframework.security.authentication.AnonymousAuthenticationToken@cfc8b528: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS'
2020-11-14 18:09:38,949 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: / at position 9 of 11 in additional filter chain; firing Filter: 'SessionManagementFilter'
2020-11-14 18:09:38,949 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.session.SessionManagementFilter: Requested session ID 34F343DE72DBA443C5F7DC290B36E591 is invalid.
2020-11-14 18:09:38,950 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: / at position 10 of 11 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2020-11-14 18:09:38,951 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.FilterChainProxy$VirtualFilterChain: / at position 11 of 11 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2020-11-14 18:09:38,951 DEBUG [http-nio-9191-exec-4] org.springframework.security.access.intercept.AbstractSecurityInterceptor: Secure object: FilterInvocation: URL: /; Attributes: [authenticated]
2020-11-14 18:09:38,952 DEBUG [http-nio-9191-exec-4] org.springframework.security.access.intercept.AbstractSecurityInterceptor: Previously Authenticated: org.springframework.security.authentication.AnonymousAuthenticationToken@cfc8b528: Principal: anonymousUser; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS
2020-11-14 18:09:38,952 DEBUG [http-nio-9191-exec-4] org.springframework.security.access.vote.AffirmativeBased: Voter: org.springframework.security.web.access.expression.WebExpressionVoter@58207add, returned: -1
2020-11-14 18:09:38,956 DEBUG [http-nio-9191-exec-4] org.springframework.security.web.access.ExceptionTranslationFilter: Access is denied (user is anonymous); redirecting to authentication entry point
org.springframework.security.access.AccessDeniedException: Access is denied
    at org.springframework.security.access.vote.AffirmativeBased.decide(AffirmativeBased.java:84)
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:233)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:123)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92)
    at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
注意:如果我在不使用CustomAuthenticationFilter的情况下使用,则它将成功返回accessToken。也许我缺少一些配置。请帮忙