c# - FormsAuthentication.FormsCookiePath

标签 c# asp.net security authentication forms-authentication


第一季度 我读过,在设置身份验证 cookie 的超时时,我们应该记住,cookie 持续的时间越长,cookie 被盗用和滥用的可能性就越大。


A) 但是假设我们通过为整个应用程序启用 SSL 来保护我们的应用程序免受重放攻击,并且由于表单例份验证模块也在身份验证 cookie 中加密身份验证数据,那么我认为这个 cookie 没有被滥用的机会,因此保留更长时间的 cookie 应该不会带来任何安全风险?!


第二季度

FormsAuthentication.FormsCookiePath 指定身份验证 cookie 的存储位置。默认值为“/”。

A) 假设使用默认值 '/',那么 cookie 保存在哪里?

B) 此选项是否仅用于持久性 cookie?


谢谢

最佳答案

2A cookie路径是cookie关联的服务器上的路径,不是cookie存放的路径。

来自 http://www.quirksmode.org/js/cookies.html

The path gives you the chance to specify a directory where the cookie is active. So if you want the cookie to be only sent to pages in the directory cgi-bin, set the path to /cgi-bin. Usually the path is set to /, which means the cookie is valid throughout the entire domain. This script does so, so the cookies you can set on this page will be sent to any page in the www.quirksmode.org domain (though only this page has a script that searches for the cookies and does something with them).

您正在使用 ASP.Net。另请参阅“CookieLess” session 和身份验证选项,例如 http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.formscookiepath.aspx如果您担心 cookie。这会使用 URL session ID 来跟踪您的 session 。

您还可以使用 SQL Server 来跟踪 session 状态或状态服务器。 例如

<sessionState mode="SQLServer" sqlConnectionString="SQLSessionDB" cookieless="false" timeout="65" cookieName="MSESSID"/>

1A。 SSL 加密传输。因此,您的 cookie 在前往客户或返回客户的途中被盗的可能性较小。这并不意味着客户端计算机上的恶意程序无法窃取它。但这不太可能。

关于c# - FormsAuthentication.FormsCookiePath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/879321/

相关文章:

c# - 在 C# 中比较二进制文件

c# - 非静态字段、方法或属性需要对象引用 'MyClass.SetImageUrl()'

c - 格式化字符串漏洞和输入字符串

javascript - 哈希安全漏洞 - 如何修复?

c# - 类方法内的 `this` 是否引用被调用或默认实例?

c# - 进行 DPI 缩放的简单方法?

c# - 存在哪些安全机制来防止其他人访问 DLL 的某些方法?

c# - Linq 自动修剪我的字符串!

asp.net - 将 asp.net 部署到 IIS 结果然后在目录列表中启动站点结果

无需重定向的 ASP.NET 表单例份验证