简体   繁体   English

Spring 授权服务器:登录后如何继续授权

[英]Spring Authorization Server: how to continue authorization after login

I am trying to integrate Authorization Server into my app with form login.我正在尝试通过表单登录将授权服务器集成到我的应用程序中。 I'm using my own login page.我正在使用自己的登录页面。 Samples suggest to use the following configuration:示例建议使用以下配置:

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"));
//...
                )

Now when I try to authorize ( /oauth2/authorize?... ) I got redirection to my login page.现在,当我尝试授权( /oauth2/authorize?... )时,我被重定向到我的登录页面。 If I logged in before I see OAuth consent page and able to submit consent.如果我在看到 OAuth 同意页面并能够提交同意之前登录。 But 99% of times I see my /login page, able to log in and stuck here.但是 99% 的时间我看到我的/login页面,能够登录并卡在这里。 How to continue to consent page there?如何继续那里的同意页面? Should I write my own logic for that?我应该为此编写自己的逻辑吗?

Solved issue myself by removing custom .successHandler(...) from my custom form login configuration.通过从我的自定义表单登录配置中删除自定义.successHandler(...)自己解决了问题。 Default SavedRequestAwareAuthenticationSuccessHandler correctly handle all redirects as expected.默认SavedRequestAwareAuthenticationSuccessHandler按预期正确处理所有重定向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM