正在更改OAuth2AuthorizationRequestRedirectFilter的BaseURI重定向不正确



我试图用github特定的oauth链让OAuth2AuthorizationRequestRedirectFilterbaseUri正确重定向,但我似乎无法解决。我的WebSecurityConfigurerAdapter设置有ClientRegistrationRepository集,我使用以下内容来设置基本uri:

.authorizationEndpoint()
.baseUri(GitHubRequestPaths.GITHUB_OAUTH_REDIRECT)
//Note the above is defined as:
//String GITHUB_OAUTH_REDIRECT = "/github/oauth2/authorization"

但是Spring似乎在抱怨它无法匹配授权端点,我认为这是它的原因,所以它没有正确地重定向到OAuth2LoginAuthenticationFilter的github登录。我在调试中看到了以下内容,这正是我产生这个想法的原因:

2021-12-07 10:20:24.015 DEBUG 11283 --- [nio-8091-exec-2] o.s.security.web.FilterChainProxy        : /github/oauth2/authorization at position 5 of 12 in additional filter chain; firing Filter: 'OAuth2AuthorizationRequestRedirectFilter'
2021-12-07 10:20:24.015 DEBUG 11283 --- [nio-8091-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/github/oauth2/authorization'; against '/github/oauth2/authorization/{registrationId}'
2021-12-07 10:20:24.015 DEBUG 11283 --- [nio-8091-exec-2] o.s.security.web.FilterChainProxy        : /github/login at position 6 of 12 in additional filter chain; firing Filter: 'OAuth2LoginAuthenticationFilter'
2021-12-07 10:20:24.015 DEBUG 11283 --- [nio-8091-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/github/login'; against '/login/oauth2/code/*'
2021-12-07 10:20:24.015 DEBUG 11283 --- [nio-8091-exec-2] o.s.security.web.FilterChainProxy        : /github/login at position 7 of 12 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2021-12-07 10:20:24.015 DEBUG 11283 --- [nio-8091-exec-2] o.s.s.w.s.HttpSessionRequestCache        : saved request doesn't match

网页的设置方式是从一个基本目录调用中收集登录名,该调用将返回GitHub登录名作为我设置的授权登录名调用(/github/oauth2/authorization(。我尝试手动设置注册id(/github/oauth2/authorization/GitHub(,但Spring只是返回了一个类似的错误,即查找与/github/oauth2/authorization/GitHub/{registrationId}匹配的内容。它似乎试图匹配baseUri + /{registrationId},我可以编辑此行为吗?

我创建了自己的OAuth2AuthorizationRequestResolver,它几乎完全镜像了DefaultOAuth2AuthorizationRequestResolver,但注册id是硬编码的。

相关内容

  • 没有找到相关文章

最新更新