Owin Cookie 域 IIS 7 和 SSL
Owin CookieDomain IIS7 and SSL
我在我们的应用程序之间设置 SSO 时遇到问题,在创建 cookie 的应用程序中我有:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
// LogoutPath = new PathString("/Account/Logout"),
// ExpireTimeSpan = TimeSpan.FromDays(1),
CookieName = "mycookie",
CookieDomain = ".mydomain.com",
});
在本地测试时,我得到了预期的结果
Cookie = Name: mycookie, Domain: .mydomain.com
然而,当我进入我们的测试环境时,我得到
Cookie = Name: mycookie, Domain: oauth.mydomain.com
由于 cookie 具有域的根,因此它在其他应用程序中不起作用。我已经做了我能想到的一切,但它似乎不想使用配置中指定的域。
更新: 使用 SSL 从 IIS7 环境托管时,这似乎是一个问题。当在 IIS7 中不使用 SSL 或使用 IIS8 部署到我们的 UAT 环境时,它会按预期工作。
使用 SSL 时也无法正确重定向。我认为这个问题也是相关的。
当我点击 http://site.domain.com 时,我被重定向到
http://auth.domain.com/account/login?returnUrl=site.domain.com
符合预期,但是如果启用了 SSL,我将被重定向到
https://site.domain.com/account/login?returnurl=site.domain.com
所以看起来问题发生在 firewall/proxy 那些服务器后面。
我在我们的应用程序之间设置 SSO 时遇到问题,在创建 cookie 的应用程序中我有:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
// LogoutPath = new PathString("/Account/Logout"),
// ExpireTimeSpan = TimeSpan.FromDays(1),
CookieName = "mycookie",
CookieDomain = ".mydomain.com",
});
在本地测试时,我得到了预期的结果
Cookie = Name: mycookie, Domain: .mydomain.com
然而,当我进入我们的测试环境时,我得到
Cookie = Name: mycookie, Domain: oauth.mydomain.com
由于 cookie 具有域的根,因此它在其他应用程序中不起作用。我已经做了我能想到的一切,但它似乎不想使用配置中指定的域。
更新: 使用 SSL 从 IIS7 环境托管时,这似乎是一个问题。当在 IIS7 中不使用 SSL 或使用 IIS8 部署到我们的 UAT 环境时,它会按预期工作。
使用 SSL 时也无法正确重定向。我认为这个问题也是相关的。
当我点击 http://site.domain.com 时,我被重定向到
http://auth.domain.com/account/login?returnUrl=site.domain.com
符合预期,但是如果启用了 SSL,我将被重定向到
https://site.domain.com/account/login?returnurl=site.domain.com
所以看起来问题发生在 firewall/proxy 那些服务器后面。