ASP.Net_SessionId 使用 IE11 跨子域的 cookie

ASP.Net_SessionId cookie across subdomains using IE11

我有两个 ASP.NET 网站:new.somecompany.com 和 legacy.somecompany.com。

"New" 是使用 Windows 身份验证的 Intranet 应用程序。 "Legacy"既是互联网又是内网;它使用表单身份验证。

在 "New" 网站中,我的老板希望能够单击 link 并打开浏览器 window 到 window 上已登录的网页=36=] 网站。 (他希望在不更改旧站点的情况下完成此操作。)

我有一个解决方案适用于 Chrome(版本 39.0.2171.95 m)和 Firefox(版本 33.1.1),但不适用于 Internet Explorer(版本 11.0.9600.17501)。在高层次上,解决方案是:

  1. "new" 上的控制器使用 HttpWebRequest 使用存储的凭据登录到 "legacy"。
  2. 控制器从 "legacy" 响应中获取 "ASP.Net_SessionId" cookie 并将其用于 在浏览器中为域“.somecompany.com”设置 "ASP.Net_SessionId" cookie。
  3. 从浏览器转到 https://legacy.somecompany.com/somepage.aspx

在 Chrome 和 Firefox 中,https://legacy.somecompany.com/somepage.aspx 显示为适合用于登录的已存储凭据。使用 IE 11,将显示登录页面。

我使用了 Microsoft 的 Message Analyzer 工具来查看正在来回传递的内容。使用 Chrome,我看到 ASP.Net_SessionId cookie 在 somepage.aspx 的 HTTP 请求中发送。在 IE 11 中,cookie 没有被发送,我得到了一个重定向到登录页面的响应。

我可以做些什么来让它在 IE 11 中运行?

我也遇到过类似的情况。最近我开发了一个 Web 应用程序,我想在 Windows 身份验证和匿名站点中编写一次代码并部署(在 iFrame 中)。

用户必须通过 Active Director 登录或登录到外部站点。

我就是这样处理的。在这两种情况下,iFrame 站点都在同一域上运行(如您所示)site1.company.com 或 site2.company.com

我就是这样处理的。

  1. 站点A:用户登录,将用户名加密保存在cookie中。 (我用私钥进行AES加密)。

  2. 站点 B:读取 cookie,解密用户 ID,并将用户登录到站点。

cookie 中还有一个加密值(日期时间),该值会在 3 秒内过期。

这个blog给了我答案。特别是这段:

Problem #3 occurs on Windows Vista and above, when you have configured one subdomain to run outside of Protected Mode (e.g. put it in the Trusted Zone) and another related subdomain to run inside of Protected Mode (e.g. left it in the Internet Zone). This isn’t terribly common, but might occur if you, for instance, put login.live.com in the Trusted Zone but didn’t put mail.live.com in the Trusted Zone. The root cause of this obscure problem is that Protected Mode and non-Protected Mode do not share cookies, and hence a cookie set by a site outside of Protected Mode will not be visible to a site running inside Protected Mode, and vice versa.

在我的例子中,"new.somecompany.com" 在 IE 设置中的本地 Intranet 区域中,但 "legacy.somecompany.com" 不是。将 "legacy.somecompany.com" 添加到 Intranet 区域后,我的代码在 IE 11 中运行。