Spring Authorization Server:登录后如何继续授权



我正试图将授权服务器与表单登录集成到我的应用程序中。我在用我自己的登录页面。示例建议使用以下配置:

public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http)
throws Exception {
OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http);
//...
http
// Redirect to the login page when not authenticated from the
// authorization endpoint
.exceptionHandling((exceptions) ->
exceptions
.authenticationEntryPoint(new LoginUrlAuthenticationEntryPoint("/login"));
//...
)

现在当我尝试授权(/oauth2/authorize?...)我得到重定向到我的登录页面。如果我在登录之前看到OAuth同意页面并能够提交同意。但是99%的时候我看到我的/login页面,可以登录并卡在这里。如何继续同意页面那里?我应该自己写逻辑吗?

通过从自定义表单登录配置中删除自定义.successHandler(...)来解决自己的问题。默认SavedRequestAwareAuthenticationSuccessHandler按预期正确处理所有重定向。

最新更新