- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的Grails应用程序(带有Spring Security插件)具有非常基本的支持“快速登录”功能,基本上是在userId
存储在加密的cookie中时提示用户仅键入密码登录。
所以我在 Controller 中使用springSecurityService.reauthenticate(userid)
手动验证用户身份。
我的应用程序还具有不允许并发 session 的要求。因此,与上一行一样,我添加了
def authentication = SecurityContextHolder.context.authentication
def sessions = sessionRegistry.getAllSessions(authentication.getPrincipal(), false)
// [L]
sessions.each {
it.expireNow()
}
sessionRegistry
的条目中,而上述代码是一个问题,因为在
sessions
中我找不到该用户的任何 session 。
reauthenticate
,未向sessionRegistry
添加任何内容sessionRegistry.registerNewSession(newSessionId, authentication.getPrincipal())
处于
[L]
位置,但是此 session 与重新生成的 session 似乎没有任何关系。
最佳答案
经过几次尝试,我想出了一个可行的解决方案
// injected dependencies
AuthenticationManager authenticationManager
SessionAuthenticationStrategy sessionAuthenticationStrategy
// code
Authentication auth = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(user.email, params.password))
SecurityContextHolder.context.authentication = authResult // need to reassign to context, otherwise onAuthentication fails (wrong password)
sessionAuthenticationStrategy.onAuthentication(authResult, request, response)
onAuthentication
,触发所有已定义的请求过滤器,这依赖于我的并发 session 管理。
关于authentication - Grails 3-springSecurity重新认证和SessionRegistry,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42029206/
我做了以下事情: 登录到我的 spring 应用程序(例如,作为用户“admin”) 停止tomcat 现在我看到 session 被序列化到 sessions.ser 文件中 我重启tomcat s
我有一个完全由 Weblogic 容器保护的 Web 应用程序。现在我必须列出当前登录的用户。我必须为此使用 Spring Security 2.0.4 在 web.xml 中我定义了必要的监听器和过
我使用 spring security3 和 spring mvc3 来构建一个 web 项目。有一个叫index.jsp的页面,会显示登录用户名和在线用户数 此屏幕的顶部。登录系统有两种方式: 从登
使用 @Autovired SessionRegistry sessionRegistry 在我的代码中,我添加了以下配置: http.sessionManagement() .max
我在 Spring Boot 应用程序中使用 Spring Security 来提供用户功能。我花了一些时间寻找问题的答案,但只为使用基于 xml 的配置的人找到了解决方案。 我的设置与此非常相似:h
我似乎找不到如何在 Struts 操作中获取对 Spring Security (V3) SessionRegistry 的引用。 我已经在我的 web.xml 文件中配置了监听器: org
有人可以提供关于如何仅使用 java 配置在 Spring Security 中获取非空 SessionRegistry 对象(没有任何 XML)的真实工作代码片段。 我正在使用 Spring Sec
在我写的http标签内: 我有以下 sas bean 在代码中我从注册表获取信息: @Autowired private SessionRegistr
我们的应用过去只有一种登录方式:用户名和密码。一旦新用户登录到应用程序,他们的 session 将出现在 Spring Security 的 SessionRegistry 中。 现在我正在 Spri
我正在使用 Hazelcast 3.4 和 Spring security 3.2.5。当我部署应用程序并尝试登录时,登录成功但抛出异常,导致错误页面。无论错误页面如何,我都已登录并且我的 sessi
问题场景: 我正在尝试使用带有 Java 配置的 Spring Security v3.2.3 来配置 session 管理,以便将 maximumSessions 设置为 1 并将 maxSessi
我正在使用 spring security 进行自定义身份验证。我没有使用任何 AuthenticationProvider,但使用 UsernamePasswordAuthenticationTok
也许应该配置 session 过期时间,或者我的代码中有错误? 我的 Controller 代码片段。即使已注销,它也会显示用户名。 @GetMapping("/") public String
我是一名优秀的程序员,十分优秀!