首页 > 解决方案 > Spring OAuth2 将原始请求保存在会话中并重定向到原始 URL

问题描述

这是安全配置

@Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .csrf()
                    .disable()
                .formLogin()
                    .disable()
                .httpBasic()
                    .disable()
                .authorizeRequests()                  
                    .antMatchers("/auth/**", "/oauth2/**")
                        .permitAll()
                    .anyRequest()
                        .authenticated()
                    .and()
                .oauth2Login()
                    .authorizationEndpoint()
                        .baseUri("/oauth2/authorize")
                        .and()
                    .redirectionEndpoint()
                        .baseUri("/oauth2/callback/*")
                        .and()
                    .userInfoEndpoint()
                        .userService(customOAuth2UserService)
                        .and()
                    .successHandler(oAuth2AuthenticationSuccessHandler)
                    .failureHandler(oAuth2AuthenticationFailureHandler);

    }

在前端,URL 是http://localhost:8080/oauth2/authorize/google?redirect_uri=http://localhost:8080/some-url

但是,在用户获得授权并成功登录后,用户不会被重定向到http://localhost:8080/some-url

可能是什么原因以及如何解决?

标签: spring-socialspring-oauth2spring-social-google

解决方案


推荐阅读