【问题标题】:Upgraded to SecureSocial 2.0.12 and now sessions are not being persisted升级到 SecureSocial 2.0.12,现在会话没有被保留
【发布时间】:2013-05-18 14:24:57
【问题描述】:

我使用的是 SecureSocial 2.0.7,我实现了 UserServicePlugin,用户可以登录。我可以停止并重新启动服务器(或重新编译或其他),用户将保持登录状态。

自从升级到 2.0.12 后,登录会话不会在服务器重新启动后保持不变。

我在UserServicePlugin 中的每个方法中都添加了调试日志记录。用户在登录时是saved。但是,当服务器重新启动,并且我尝试以以前登录的用户身份访问页面时,我只会在日志中看到:

[info] play - database [default] connected at jdbc:postgresql://localhost/xxxxxx
[info] application - [securesocial] loaded templates plugin: sec.SecureSocialViews
[info] play - Starting application default Akka system.
[info] application - [securesocial] loaded user service: class sec.LoginUserService
[info] application - [securesocial] loaded password hasher bcrypt
[info] application - [securesocial] loaded identity provider: userpass
[info] play - Application started (Dev)
[debug] application - [securesocial] calling deleteExpiredTokens()
[debug] application - deleteExpiredTokens
[debug] application - [securesocial] anonymous user trying to access : '/supplier/requests'

有什么想法吗?我想知道是否由于某种原因,登录 cookie 甚至在检查现有登录会话之前就被核爆了……

我正在使用用户名/密码验证。

【问题讨论】:

  • 这可能与 SecureSocial 将内容存储在 Play Cache 中有关吗? (我只是使用默认的内存播放缓存。)
  • 我在 Play 2.1 和 Master 分支 Securesocial 上也发现了这一点。我有一个由数据库支持的用户服务,并已将 ehcache 配置为持久保存到磁盘。但是,重新启动服务器时,所有用户都将注销。令人沮丧。

标签: playframework-2.0 securesocial


【解决方案1】:

用户信息在会话中的存储方式发生了变化。该模块现在使用单独的,而不是使用 Play session cookie。此 cookie 有一个身份验证器 ID。用户信息现在存储在服务器端的 AuthenticatorStore 实现中。默认实现使用 Play 缓存,这就是您需要在重新编译时再次进行身份验证的原因。正在清除缓存中的数据。

如果您想让用户在重新编译/重启后保持登录状态,您可以:

  1. 创建持久化事物的 AuthenticatorStore 实现。
  2. 更改 ehcache.xml 文件以保留在文件系统中 (diskPersistent="true")。

【讨论】:

  • 您是否将 ehcache.xml 文件复制到您的 app/conf 目录?
  • 谢谢!刚刚有机会回到这个,看看。实现一个持久保存到我的数据库的 AuthenticatorStore 看起来相当简单。 V. 烦人的是它没有记录在任何地方!
猜你喜欢
  • 2019-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-28
  • 2012-07-05
  • 2016-03-31
  • 2016-06-15
相关资源
最近更新 更多