【发布时间】:2013-05-29 19:48:12
【问题描述】:
我正在使用 System.IdentityModel 在 ASP.NET MVC4 Web 应用程序中使用带有声明主体的表单身份验证对用户进行身份验证。 (本文代码:http://brockallen.com/2013/01/26/replacing-forms-authentication-with-wifs-session-authentication-module-sam-to-enable-claims-aware-identity/)
我的 ClaimsBasedAuthenticationService 类从 SessionSecurityToken 发出 SAM cookie,一切都很好......除了我刚才注意到它没有将会话 cookie 创建为 HTTPOnly 或要求它们需要 SSL。当我调试代码时,我可以看到 CookieHandler 对象上的这些属性在调试器中设置正确,但创建的最终会话 cookie 根本没有标记 HTTPOnly 和 Secure 标志。
我有 web.config 行来明确地将这些设置为 true:
<system.web>
<httpCookies httpOnlyCookies="true" requireSSL="true" />
<authentication mode="Forms">
<forms ... requireSSL="true" />
</authentication>
...
</system.web>
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="true" hideFromScript="true" />
</federationConfiguration>
</system.identityModel.services>
有人可以告诉我是否还缺少其他东西以便从脚本中隐藏我的 FedAuth cookie (HTTPOnly) 并需要 SSL?
【问题讨论】:
-
有人建议将属性 lockItem="true" 添加到 httpCookies 元素,但没有任何作用。
标签: asp.net-mvc-4 forms-authentication session-cookies wif claims-based-identity