【发布时间】:2017-07-15 22:25:34
【问题描述】:
我的想法:由 FormsAuthentication.SetAuthCookie 创建的 cookie 始终是加密的。
这是我在查看 Microsoft 网站时的理解,其中说票证是使用 Machine.config 中的 machineKey 加密的: https://support.microsoft.com/en-ca/help/910443/understanding-the-forms-authentication-ticket-and-cookie
为了 100% 确定它是加密的,我运行了以下代码:
在一页上:
FormsAuthentication.RedirectFromLoginPage(user.user_name, false);
在下一页:
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
FormsAuthenticationTicket authTicket =
FormsAuthentication.Decrypt(authCookie.Value);
我看到 cookie 的值是加密的,而且解密得很好。
但是,在这里查看最佳答案时:FormsAuthentication: Is it secure? 似乎不建议在 cookie 中存储敏感信息。在上面的链接中,他甚至说“我认为你是以纯文本形式存储 cookie”。
在此处查看第二级答案时也是如此:Storing more information using FormsAuthentication.SetAuthCookie
如果 cookie 是使用 machineKey 自动加密的,为什么假定他们以纯文本形式存储它,? 为什么在此处存储敏感信息会出现问题?
附:我需要存储有关已登录用户的敏感信息。
【问题讨论】:
-
只是因为它被加密并不意味着有人无法用足够的时间和精力来解密它。解密临时身份验证令牌并没有那么糟糕,因为当您发现它时,它已经过期了。另一方面,解密用户密码...
-
谢谢。抱歉,我对此有点陌生,但这是否意味着通过 HTTPS 发送用户密码也不那么安全?
标签: c# asp.net asp.net-mvc forms-authentication