这是实现“记住我”的合理方式吗? 功能性

发布于 2024-07-16 03:07:06 字数 563 浏览 3 评论 0原文

如果用户登录网站并说“记住我”,我们就会获取该用户的唯一标识符,使用 RijndaelManaged 对其进行加密,密钥大小为 256,并将其放置在 httponly cookie 中,设置有效期为 120 天。 ,每次成功向服务器请求都会刷新过期时间。

我们可以选择根据用户代理和部分 ipv4 地址(最后两个八位字节)生成初始化向量。

显然,这里没有内置真正的过期系统,从技术上讲,用户可以永远使用这个加密密钥(假设我们不更改服务器端密钥)。

我考虑了这样一个事实:为了允许此功能,我需要允许用户能够绕过登录并给我他们唯一的ID(这是一个guid),我认为单独的guid真的很难猜测真正的用户guid,但会使网站容易受到生成guid的僵尸程序的攻击(我没有知道他们找到一个合法的 GUID 是多么现实).. 所以这就是为什么服务器知道加密密钥的加密方式,并且可选地 iv 特定于浏览器和 ip 部分。

我是否应该考虑采用不同的方法,其中服务器发出与用户关联的票证,并且这些票证具有已知的到期日期,以便服务器保持对到期的控制? 我真的应该关心过期吗? 记住我到底是记住我吗?

期待被谦卑;), 干杯。

If a user logs into the site, and says 'remember me', we get the unique identifier for the user, encrypt this with RijndaelManaged with a keysize of 256 and place this in a httponly cookie with a set expiration of say.. 120 days, the expiration is refreshed each successful request to the server.

Optionally we generate the initialization vector based upon the user agent and part of the ipv4 address (the last two octets).

Obviously theres no real expiration system built into this, the user could technically use this encrypted key forever (given we don't change the server side key)..

I considered the fact that to allow this feature I need to allow the user to be able to bypass the login and give me their unique id (which is a guid), I figured the guid alone was really hard to guess a real users guid, but would leave the site open to attack by botnots generating guids (I've no idea how realistic it is for them to find a legit guid).. so this is why theres encryption where the server knows the encryption key, and optionally the iv is specific to the browser and ip part.

Should I be considering a different approach where the server issues tickets associated to a user, and these tickets would have a known expiration date so the server stays in control of expiration? should I really care about expiration? remember me is remember me after all?

Looking forward to being humbled ;),
Cheers.

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

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

发布评论

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

评论(3

旧城烟雨 2024-07-23 03:07:06

非常相似的问题。

您的解决方案问题在这篇博客文章

“持久登录 Cookie 最佳
实践”描述了一个相对
安全的方法来实施
熟悉的网络“记住我”选项
网站。 在这篇文章中,我提出了一个
保留所有的改进
这种方法的好处,而且
使得能够检测到何时
持久登录 cookie 已
被攻击者窃取和使用。

正如 Jacco 在评论中所说:有关安全身份验证的深入信息,请阅读 网站身份验证权威指南

Very similar question.

The solution to your question is in this blog post

"Persistent Login Cookie Best
Practice," describes a relatively
secure approach to implementing the
familiar "Remember Me" option for web
sites. In this article, I propose an
improvement that retains all the
benefits of that approach but also
makes it possible to detect when a
persistent login cookie has been
stolen and used by an attacker.

As Jacco says in the comments: for in depth info about secure authentication read The Definitive Guide To Website Authentication.

慵挽 2024-07-23 03:07:06

您是否考虑过类似 Open Id 之类的东西? 正如SO所使用的那样。

Did you consider something like Open Id? As SO uses.

萌能量女王 2024-07-23 03:07:06

被记住的信息有多重要? 如果不是非常个人或重要的内容,只需将 GUID 放入 cookie 中即可。

在计算中包含 IP 地址可能是一个坏主意,因为它会让使用公共网络的用户立即被遗忘。

使用暴力来查找 GUID 是荒谬的,因为有 2128 种可能性。

How important is the information that is being remembered? If it's not going to be anything very personal or important, just put a GUID in the cookie.

Including the IP address in the calculation is probably a bad idea, as it would make users using public networks be instantly forgotten.

Using brute force to find GUIDs is ridiculous, as there are 2128 possibilities.

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