首页 > 解决方案 > 认证后开始执行方法

问题描述

我使用 Angular 作为客户端,使用 Spring Boot 作为服务器。一些提供者将在特定(获取/发布)端点中直接调用我的服务器。如果用户通过身份验证,方法的执行将正常开始,如果不是,用户被重定向到登录-ui(角度客户端),成功登录后用户被重定向到主页,但我想开始执行上一个请求(获取/发布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)

}

标签: javascriptjavaangularspring-bootspring-security

解决方案


用于LocalStorage在 Angular 重定向到用户登录之前存储请求的端点。

(或者)

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

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


推荐阅读