【发布时间】:2017-06-21 02:49:18
【问题描述】:
我的 Grails 应用程序(由 Spring Security 插件提供支持)有一个非常基本的支持“快速登录”功能,基本上提示用户只需输入密码即可登录,而 userId 存储在加密的 cookie 中。
所以在我的控制器中我正在使用
springSecurityService.reauthenticate(userid)
手动验证用户。
我的应用程序还要求不允许并发会话。因此,与上一行一起,我添加了
def authentication = SecurityContextHolder.context.authentication
def sessions = sessionRegistry.getAllSessions(authentication.getPrincipal(), false)
// [L]
sessions.each {
it.expireNow()
}
问题是这些重新身份验证没有反映在sessionRegistry 中的条目中,这是上面代码的问题,在sessions 中我找不到该用户的任何会话。
我目前无法解决的问题是:
- 用户 [U] 登录到位置 [A]
- [U] 登录到位置 [B] => 会话 [A] 被强制过期
- [U]不断导航/刷新[A],提示快速登录
- [U] 再次登录到[A] =>
reauthenticate被触发,sessionRegistry没有添加任何内容 - [U]不断导航/刷新[B],提示快速登录
- [U]再次登录[B]
- [U] 同时登录 [A] 和 [B]
我也试过添加sessionRegistry.registerNewSession(newSessionId, authentication.getPrincipal())
在[L] 的位置,但是这个会话和重新生成的会话似乎没有任何关系。
欢迎提出任何建议!提前致谢。
配置
- Grails 3.2.4
- Spring 安全插件(核心)3.1.1
【问题讨论】:
标签: authentication grails spring-security grails3