电子邮件激活安全校验和

发布于 2024-11-16 22:42:12 字数 589 浏览 0 评论 0原文

我一直在我的网站上询问一些反馈,收到的一条评论如下

“我注册了 [电子邮件受保护] 并设法通过 http://www.mysite.co.uk/[电子邮件受保护]

您需要校验和才能阻止它。"

有人可以详细说明这一点以及我如何将它们实施到我的激活中吗?


理论上,如果我要在数据库中创建名为“rand_key”的行,并且当用户注册时,随机密钥存储在该列中,那么我可以使用它作为激活而不是电子邮件吗?从而使其不可猜测?

Ive been asking around for some feedback on my website and one comment I received was the following

"I signed up with [email protected] and managed to active my account with http://www.mysite.co.uk/[email protected]

You need checksums to stop it."

Can anybody elaborate on this and how I can implement them into my activation?


In theory, If I was to create a row named "rand_key" in my DB and when a user registers a random key is stored in the column, could I then use this as the activation as opposed to the email? thus making it un guessable?

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

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

发布评论

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

评论(3

冰之心 2024-11-23 22:42:12

您需要创建一个唯一的用户密钥,该密钥不应与用户数据相关。通常,您可以执行一些操作,例如对随机生成器函数的输出进行哈希处理,以使其唯一并使用它。然后你将他们指向链接:

http://www .mysite.co.uk/activateuser.php?userid= generated-unique-hashed-key

此唯一用户密钥应作为额外字段添加到存储用户信息或与用户相关的表中以其他方式。通过保持密钥与用户数据无关,您可以确保没有人可以发现用户的密钥并代替您的用户恶意激活/执行其他操作。

然后,您应该在到达时测试用户密钥的某些条件:

  • 尚未授权 - 授权
  • 已授权 - 一些错误
  • 错误的密钥 - 一些错误

另外,应该有一个与您的用户关联的到期日期,在此日期后您只需停用该用户即可他的钥匙。

You need to create a unique user key, which shouldn't be related to user data. Usually you could do something like hashing the output of a random generator function in order to make it unique and use that. Then you point them to the link:

http://www.mysite.co.uk/activateuser.php?userid=generated-unique-hashed-key

This unique user key should be added as an extra field to the table where you store your user info, or related to the user in some other way. By keeping the key unrelated to user data you make sure nobody can discover a user's key and maliciously activate/do another action instead of your user.

Then you should test the user key on arrival for some conditions:

  • not authorized yet - authorize
  • authorized already - some error
  • wrong key - some error

Also, there should be an expiration date associated with your user, upon which you just deactivate the user along with his key.

夏末 2024-11-23 22:42:12

此人意味着您可以通过访问该网址并将电子邮件地址放入该网址来激活您的地址。您可以在没有实际收到激活电子邮件的情况下执行此操作。

通过使用校验和,您可以强制用户单击该链接。例如
[电子邮件受保护]&check=A1234b23

发送电子邮件时,您会生成一个随机代码。将其存储在数据库中的某个位置。将其附加到给定用户的 url 中。当用户单击该链接时,您会检查该代码是否与为该电子邮件地址存储的代码相匹配。如果匹配,请验证电子邮件。否则不。

The person means you can activate your address by going to that url and simply putting the email address in thr url. You could do this without actually getting the activation email.

By using a checksum, you force thr user to click the link. E.g.
[email protected]&check=A1234b23

At the time of sending the email you would geneate a random code. Store this in your database somewhere. Append it to the url the user is given. When the user clicks the link, you check that the code matches the code stored for that email address. If it matches, validate the email. Else do not.

天涯沦落人 2024-11-23 22:42:12

理论上,如果我要创建一行
在我的数据库中命名为“rand_key”,当
用户注册存储随机密钥
在专栏中,我可以使用这个吗
作为激活而不是
电子邮件?从而使其不可猜测?​​

是的。请记住,您不一定需要随机性,而需要唯一性(以避免两个电子邮件地址意外获得相同的激活码)。

你可以这样做:

$key = mt_rand().'-'.uniqid('', true);

echo 'http://mysite.com/activate?key='.urlencode(base64_encode($key));

这很难猜测,并且保证是唯一的。

In theory, If I was to create a row
named "rand_key" in my DB and when a
user registers a random key is stored
in the column, could I then use this
as the activation as opposed to the
email? thus making it un guessable?

Yes. Keep in mind that you don't necessarily want random as much as you want unique (in order to avoid two email addresses accidentally getting the same activation code).

You could do something like:

$key = mt_rand().'-'.uniqid('', true);

echo 'http://mysite.com/activate?key='.urlencode(base64_encode($key));

That would be tough to guess and would be guaranteed unique.

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