简体   繁体   English

Grails-Spring Security Core onAuthenticationSuccess

[英]Grails - Spring Security Core onAuthenticationSuccess

I have a form that allows a user to either login or register. 我有一个允许用户登录或注册的表格。

When the user lands on the page containing the form, the request is saved in a RequestCache object (I'm using Spring Security). 当用户到达包含表单的页面时,请求将保存在RequestCache对象中(我正在使用Spring Security)。

In the case that the user decides to register, I want to mimic the behavior of the Spring Security onAuthenticationSuccess code, where the user is redirected to whatever page they were trying to get to before logging in (or, in my case, before registering). 在用户决定注册的情况下,我想模仿Spring Security onAuthenticationSuccess代码的行为,在该代码中,用户被重定向到他们在登录之前尝试访问的页面(或者,在我的情况下,注册之前) 。

To accomplish that, I added the following code to the RegistrationController: 为此,我将以下代码添加到RegistrationController中:

authenticationSuccessHandler.onAuthenticationSuccess(request, response, springSecurityService.authentication)

My question is, is this a reasonable approach to handle the on registration success use case? 我的问题是,这是处理注册成功用例的合理方法吗? Am I doing enough? 我够了吗?

Best way would be to keep a link to the original requested URL in a hidden formitem on the registration page and redirect after registration. 最好的方法是将指向原始请求URL的链接保留在注册页面上的隐藏密码表中,并在注册后重定向。 Try to keep the security layer as simple and close to the original intend as possible. 尝试使安全层尽可能简单,并尽可能接近最初的意图。

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

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