授權碼模式、密碼模式、簡易模式、客戶端模式這些都正常,但是在請求頭中設定token卻無法識別用戶,一直顯示Access is denied (user is anonymous)。經過排查好像是因為沒有執行`OAuth2ClientAuthenticationProcessingFilter`這個過濾器。但是具體不知道為什么。希望大佬幫忙
uj5u.com熱心網友回復:
日志資訊:
2020-12-23 11:28:29.739 DEBUG 9924 --- [io-30000-exec-5] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/oauth/token']
2020-12-23 11:28:29.739 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/user/1'; against '/oauth/token'
2020-12-23 11:28:29.739 DEBUG 9924 --- [io-30000-exec-5] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/oauth/token_key']
2020-12-23 11:28:29.739 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/user/1'; against '/oauth/token_key'
2020-12-23 11:28:29.739 DEBUG 9924 --- [io-30000-exec-5] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/oauth/check_token']
2020-12-23 11:28:29.739 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/user/1'; against '/oauth/check_token'
2020-12-23 11:28:29.740 DEBUG 9924 --- [io-30000-exec-5] o.s.s.web.util.matcher.OrRequestMatcher : No matches found
2020-12-23 11:28:29.740 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 1 of 13 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2020-12-23 11:28:29.740 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 2 of 13 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2020-12-23 11:28:29.740 DEBUG 9924 --- [io-30000-exec-5] w.c.HttpSessionSecurityContextRepository : No HttpSession currently exists
2020-12-23 11:28:29.740 DEBUG 9924 --- [io-30000-exec-5] w.c.HttpSessionSecurityContextRepository : No SecurityContext was available from the HttpSession: null. A new one will be created.
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 3 of 13 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 4 of 13 in additional filter chain; firing Filter: 'LogoutFilter'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/logout', GET]
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/user/1'; against '/logout'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/logout', POST]
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Request 'GET /user/1' doesn't match 'POST /logout'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/logout', PUT]
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Request 'GET /user/1' doesn't match 'PUT /logout'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.web.util.matcher.OrRequestMatcher : Trying to match using Ant [pattern='/logout', DELETE]
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Request 'GET /user/1' doesn't match 'DELETE /logout'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.web.util.matcher.OrRequestMatcher : No matches found
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 5 of 13 in additional filter chain; firing Filter: 'UsernamePasswordAuthenticationFilter'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Request 'GET /user/1' doesn't match 'POST /login'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 6 of 13 in additional filter chain; firing Filter: 'DefaultLoginPageGeneratingFilter'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 7 of 13 in additional filter chain; firing Filter: 'DefaultLogoutPageGeneratingFilter'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/user/1'; against '/logout'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 8 of 13 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.s.HttpSessionRequestCache : saved request doesn't match
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 9 of 13 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2020-12-23 11:28:29.742 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 10 of 13 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2020-12-23 11:28:29.743 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.a.AnonymousAuthenticationFilter : Populated SecurityContextHolder with anonymous token: 'org.springframework.security.authentication.AnonymousAuthenticationToken@d5becc82: 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-12-23 11:28:29.743 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 11 of 13 in additional filter chain; firing Filter: 'SessionManagementFilter'
2020-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.session.SessionManagementFilter : Requested session ID DCFD81E6AED84FF6418C40CAA738809E is invalid.
2020-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 12 of 13 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2020-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.security.web.FilterChainProxy : /user/1 at position 13 of 13 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2020-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/user/1'; against '/login'
2020-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/user/1'; against '/oauth/**'
2020-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/user/1'; against '/swagger**/**'
2020-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/user/1'; against '/webjars/**'
2020-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/user/1'; against '/v3/**'
2020-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.u.matcher.AntPathRequestMatcher : Checking match of request : '/user/1'; against '/doc.html'
2020-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.a.i.FilterSecurityInterceptor : Secure object: FilterInvocation: URL: /user/1; Attributes: [authenticated]
2020-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.a.i.FilterSecurityInterceptor : Previously Authenticated: org.springframework.security.authentication.AnonymousAuthenticationToken@d5becc82: 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-12-23 11:28:29.744 DEBUG 9924 --- [io-30000-exec-5] o.s.s.access.vote.AffirmativeBased : Voter: org.springframework.security.web.access.expression.WebExpressionVoter@2eae565, returned: -1
2020-12-23 11:28:29.756 DEBUG 9924 --- [io-30000-exec-5] o.s.s.w.a.ExceptionTranslationFilter : Access is denied (user is anonymous); redirecting to authentication entry point
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/239216.html
標籤:Java SE
下一篇:wtforms表單渲染錯誤資訊
