认证后开始执行方法

时间:2019-06-06 09:36:25

标签: javascript java angular spring-boot spring-security

我将Angluar用作客户端,将Spring Boot用作服务器。一些提供程序将在特定的(获取/发布)端点中直接调用我的服务器。如果用户通过了身份验证,则该方法的执行将正常开始,如果未将用户重定向到login -ui(angluar-client),则成功登录后的用户将重定向到主页,但是我想开始执行上一个请求(获取/发布) singleSignOnServicePost)。我该如何解决?

 @PostMapping(value = ["/sso"])
    fun singleSignOnServicePost(
            request: HttpServletRequest,
            response: HttpServletResponse,
            authentication: Authentication,
            @RequestParam(value = "SAMLRequest") samlRequest: String) {
       //.......
}

 override fun configure(http: HttpSecurity) {
        http
                .csrf().disable()
                .exceptionHandling().authenticationEntryPoint(LoginUrlFilter("https://xxxx/login"))
                .and()
                .requestMatchers()
                .antMatchers(LOGIN_ENDPOINT_SUFFIX)
                .antMatchers(OAUTH_AUTHORIZATION_ENDPOINT_SUFFIX)
                .antMatchers(SAML_ENDPOINT_SUFFIX)
                .antMatchers(TWO_FACTOR_DEVICE_SETUP)
                .and()
                .formLogin().loginPage()(LOGIN_ENDPOINT_SUFFIX).permitAll().successHandler( authenticationSuccessHandler)

}

1 个答案:

答案 0 :(得分:0)

使用LocalStorage存储请求的端点,然后再重定向到angular用户登录。

(或)

在服务器端创建session并将请求的端点存储在session中,然后执行authentication

使用存储在session / LocalStorage中的值来命中端点。

相关问题