javascript - 认证后开始执行方法
问题描述
我使用 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)
}
解决方案
用于LocalStorage
在 Angular 重定向到用户登录之前存储请求的端点。
(或者)
在服务器端创建session
并存储请求的端点session
,然后执行authentication
.
使用存储在session
/中的值LocalStorage
来命中端点。
推荐阅读
- python - UnboundLocalError:在 Pygame 2.0 中分配、前后移动之前引用的局部变量“x_direction”
- html - Excel VBA IE NAVIGATE 方法不返回完整的 HTML 页面
- reactjs - 如何在 div ReactJS 中将 JSON 中的数据显示为 flex 行
- python - 我正在尝试使用神经网络使用 tensorflow 对波士顿数据集进行回归。不知何故,我把所有的预测都弄错了
- shiny - 移动设备的闪亮 selectInput(multiple = TRUE) 问题
- angular - Auth0-lock 不会显示关闭按钮角度
- javascript - 如何使我的 CSS 动画对鼠标悬停更敏感
- javascript - React 无法从 api 渲染元素数组
- azure-devops - Azure Devops 构建管道不构建可执行文件
- javascript - 如何在同一页面上调用具有先前实例的浏览器选项卡