无需通过电子邮件发送密码即可恢复密码

发布于 2024-07-25 14:32:50 字数 511 浏览 3 评论 0原文

因此,我一直在使用 asp:PasswordRecovery 并发现我真的不喜欢它,原因如下:

1) 即使无法访问 Alice 的电子邮件,Alice 的密码也可以重置。 密码重置的安全问题缓解了这个问题,但并不能真正令我满意。

2) Alice 的新密码以明文形式发回给她。 我宁愿向她发送一个指向我的页面的特殊链接(例如 example.com/recovery.aspx?P=lfaj0831uefjc 之类的页面),这将让她更改密码。

我想我可以通过创建某种过期密码恢复页面表并将这些页面发送给要求重置的用户来自己完成此操作。 不知何故,这些页面还可以在幕后更改用户密码(例如,通过手动重置密码,然后使用新密码的文本来更改密码,因为在不知道旧密码的情况下无法更改密码)。 我确信其他人以前也遇到过这个问题,而且这种解决方案让我觉得有点老套。 有一个更好的方法吗?

理想的解决方案不会通过直接访问数据库来违反封装,而是使用数据库中现有的存储过程......尽管这可能是不可能的。

So, I've been playing with asp:PasswordRecovery and discovered I really don't like it, for several reasons:

1) Alice's password can be reset even without having access to Alice's email. A security question for password resets mitigates this, but does not really satisfy me.

2) Alice's new password is sent back to her in cleartext. I would rather send her a special link to my page (e.g. a page like example.com/recovery.aspx?P=lfaj0831uefjc), which would let her change her password.

I imagine I could do this myself by creating some sort of table of expiring password recovery pages and sending those pages to users who asked for a reset. Somehow those pages could also change user passwords behind the scenes (e.g. by resetting them manually and then using the text of the new password to change the password, since a password cannot be changed without knowing the old one). I'm sure others have had this problem before and that kind of solution strikes me as a little hacky. Is there a better way to do this?

An ideal solution does not violate encapsulation by accessing the database directly but instead uses the existing stored procedures within the database...though that may not be possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

新一帅帅 2024-08-01 14:32:51

我目前正在 Spring + SpringSecurity 之上实现一个开源 用户管理系统 ,这就是我解决丢失密码问题的方法。

  1. 用户的帐户必须有预先注册的电子邮件地址。
  2. 要请求重置,用户需要在表单中输入其帐户名。
  3. 生成临时“重置代码”并将其附加到帐户,并通过嵌入超链接的电子邮件发送给用户。
  4. 收到电子邮件后,用户单击链接进入输入新密码的页面。
  5. 在接受新密码之前,将根据存储的代码检查重置代码(来自链接),以确保其正确且未过期。

这可以避免在电子邮件中发送密码(明文)。 它还可以防止一个人重置另一个人的密码只是为了造成麻烦,因为密码重置仅在使用链接后才会发生。

但它确实依赖于用户电子邮件帐户的安全,以及电子邮件在传输过程中不被窥探。 对于某些应用程序来说,这可能是不可接受的风险。

另一个因素是,您在更改用户的注册电子邮件地址时需要非常小心。 至少,用户必须在请求更改地址时输入当前密码……以防止通过无人值守的登录会话进行黑客攻击。

I'm currently implementing an open source user management system on top of Spring + SpringSecurity, and here's how I'm addressing the lost password problem.

  1. The user's account must have a preregistered email address.
  2. To request a reset, the user enters their account name into a form.
  3. A temporary "reset code" is generated and attached to the account, and emailed to the user embedded in a hyperlink.
  4. On receiving the email, the user clicks the link which takes them to a page to enter their new password.
  5. Before accepting the new password, the reset code (from the link) is checked against the stored code, to make sure it is correct and that it hasn't expired.

This avoids sending a password (in clear) in an email message. And it also protects against one person resetting another person's password just to be a nuisance, because the password reset only takes place after the link has been used.

But it does rely on the user's email account being secure, and in the email not being snooped while in transit. For some applications, this maybe an unacceptable risk.

Another piece of the equation is that you need to be really careful about changing a user's registered email addresses. At the very least, the user must enter their current password with the request to change address ... to prevent against hacking via unattended login sessions.

再浓的妆也掩不了殇 2024-08-01 14:32:51

我建议添加额外的检查级别,这里有一些选项可供选择。

  1. 首先,您可以将请求者的 IP 地址保存在数据库中,然后当他们单击重置链接时,将其与当前计算机的 IP 地址进行比较,如果匹配,则重置密码。 如果电子邮件被拦截,则尝试重置密码的人必须拥有匹配的 IP 地址。
  2. 使用 cookie 并存储唯一值,可能是 GUID、MD5 哈希值或其他值。 因此,当用户发出密码重置请求时,cookie 会存储在他们的计算机和数据库中,当用户单击链接时,本地 cookie 必须与数据库值匹配,否则他们将无法重置密码。

一般来说,我完全反对在电子邮件中发送密码,因此我更喜欢密码重置链接选项,而不是新的纯文本密码。

I recommend adding an additional level of checking, here are some options to choose from.

  1. First you can save the requester's IP address in a database, then when they click the reset link compare that with the IP address of their current machine, if they match then reset the password. If the email is intercepted then the person attempting to reset the password must have a matching IP address.
  2. Use a cookie and store a unique value, maybe a GUID, MD5 hash or something. So when the user makes a password reset request a cookie is stored on their machine and in the database, when the user clicks the link the local cookie must match the database value or they will not be able to reset their password.

In general I am totally against ever sending a password in Email, so I like the password reset link option more than a new plain-text password.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文