【问题标题】:Scala Play security issueScala Play 安全问题
【发布时间】:2013-11-18 11:24:43
【问题描述】:

我正在尝试开发网站,使用 scala play 并在“登录页面”期间发现 1 个问题。

我要求登录名和密码,然后我在此代码的帮助下存储密码:

重定向(routes.UserPage.form(useremailverify.username)).withSession("name" -> useremailverify.username,"guid" -> md5hash1)

但突然间我发现这是全球会议!它对所有用户都是全球性的。您只需导航http://pickti.me/emailVerificationForm 即可查看它,您将在右上角看到您已经登录!有没有人知道如何为每个用户创建新的会话?

UDP 1: 在表单上,​​我检查用户是否以这种方式登录:

request =>
  request.session.get("name").map { userName =>
    username = userName
  }

所以如果用户名不为空 - 用户已登录

更新 2: 如果我会尝试:

重定向(routes.UserPage.form(useremailverify.username)).newSession.withSession("name" -> useremailverify.username,"guid" -> md5hash1)

我得到编译错误:

value newSession 不是 play.api.mvc.SimpleResult[play.api.mvc.Results.EmptyContent] 的成员

UPD 3: 代码: 重定向(routes.UserPage.form(usersignin.email)).withNewSession("name" -> usersignin.email,"guid" -> md5hash1)

错误:

play.api.mvc.PlainResult 不带参数

只有没有错误(但此代码不保存超过 1 个导航的数据): 重定向(routes.UserPage.form(usersignin.email)).withNewSession.flashing("name" -> usersignin.email,"guid" -> md5hash1)

UPD 4:

使用 withNewSession 的正确方法(但它并没有解决主要问题......): 重定向(routes.UserPage.form(useremailverify.username)).withNewSession.withSession("name" -> useremailverify.username,"guid" -> md5hash1)

UPD 5:

Cookie PLAY_SESSION 包含:“043455c05b1481c501a61167f5dd09e7ec73e693-name=starbucks%40picktime.ru&guid=d7d4c9c3f078d150effbef5e0706c557”,因此数据是从 cookie 中收集的... =(

UDP 6:

将 Play Framework 的版本更改为 2.2.1,但问题仍然存在。

【问题讨论】:

  • 代码看起来正确,应该是用户特定的。我还会添加一个.newSession.withSession(...),以确保用户从一个新会话开始。您如何检查在 emailVerifcationForm 页面上登录的用户?您能否使用该代码 sn-p 更新您的答案?
  • 在问题内容中添加了更多描述。我会尝试添加 .newSession
  • 在 Zentaks 应用程序中使用Secured trait 检查构建示例。几乎你已经完成了,但使用了play.api.mvc.Security helper。
  • 在描述中添加了 UPD 2 部分
  • 你应该使用withNewSession而不是newSession

标签: security scala playframework playframework-2.0


【解决方案1】:

withSession 不会为所有用户设置 cookie。所以我认为你的支票不行。 我正在开发一个名为 PlayGuard 的新游戏安全框架! 您可以使用此框架,也可以查看其代码并解决您的问题。

https://github.com/psycho-ir/PlayGuard-module

【讨论】:

  • 您说的是哪张支票?我可能不希望你使用其他框架和插件。即使它们不安全。
  • 所以你的答案不是解决方案
  • 刚刚添加了 PLAY Cookie,以证明这一点。
  • 我说你可以看到它的代码,显示你如何使用 cookie ( session ) 进行身份验证。不要使用这个框架,但它的简单代码可以帮助你
猜你喜欢
  • 2015-04-30
  • 1970-01-01
  • 2014-02-25
  • 2016-05-27
  • 2013-10-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多