IdentityServer3,当应用程序在不同机器上时无法更新 cookie?
IdentityServer3, can't update cookie when apps are on different machine?
我使用 IdentityServer3 为 SSO 设置了几个测试站点,这些站点几乎是具有较小振动的千篇一律示例应用程序。它们运行良好,除了一件事:当尝试通过 cookie 单点注销 and/or 更新声明时,它仅在所有应用程序都在同一台机器上时才有效。
例如,这两个应用程序可以单点退出。
http://localhost:81
http://localhost:82
使用以下内容在一个应用程序中更新的声明也会显示在另一个应用程序中。
var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
authenticationManager.AuthenticationResponseGrant =
new AuthenticationResponseGrant(new ClaimsPrincipal(identity),
new AuthenticationProperties { IsPersistent = false });
如果我这样配置应用程序,它也可以工作:
http://mymachine/app1
http://mymachine/app2
但如果我将两者混合
http://localhost:81
http://mymachine/app2
那就不行了。 SignOut/SignIn 也试过了,结果一样。他们仍然单点登录,但不能一起退出。声明的更改不会显示在另一个中。当然,如果我将应用程序部署到不同的服务器也是如此。好像 cookie 更新发生在本地机器上,而不是在 IdSvr 上。
有什么提示我错过了吗?谢谢
Single Sign Off 不是开箱即用的,不幸的是,您在同一域中看到的行为有点像转移注意力。
开箱即用,当您注销 IdentityServer 时,您的客户端应用程序只有在向 IdentityServer 发出新请求后才会发现并注销自己(也许它们自己的应用程序 cookie 已过期,它们会重新登录,或者他们可能试图请求令牌)。
要实施单点注销,您的每个客户端应用程序都需要有一种方式来让 IdentityServer 告知它们需要注销。这可以使用 front-channel HTTP request or by session management.
来完成
查看关于该主题的IdentityServer Signout Support documentation for more details on how to do this or check out Brock Allen's post。
我使用 IdentityServer3 为 SSO 设置了几个测试站点,这些站点几乎是具有较小振动的千篇一律示例应用程序。它们运行良好,除了一件事:当尝试通过 cookie 单点注销 and/or 更新声明时,它仅在所有应用程序都在同一台机器上时才有效。
例如,这两个应用程序可以单点退出。
http://localhost:81
http://localhost:82
使用以下内容在一个应用程序中更新的声明也会显示在另一个应用程序中。
var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
authenticationManager.AuthenticationResponseGrant =
new AuthenticationResponseGrant(new ClaimsPrincipal(identity),
new AuthenticationProperties { IsPersistent = false });
如果我这样配置应用程序,它也可以工作:
http://mymachine/app1
http://mymachine/app2
但如果我将两者混合
http://localhost:81
http://mymachine/app2
那就不行了。 SignOut/SignIn 也试过了,结果一样。他们仍然单点登录,但不能一起退出。声明的更改不会显示在另一个中。当然,如果我将应用程序部署到不同的服务器也是如此。好像 cookie 更新发生在本地机器上,而不是在 IdSvr 上。
有什么提示我错过了吗?谢谢
Single Sign Off 不是开箱即用的,不幸的是,您在同一域中看到的行为有点像转移注意力。
开箱即用,当您注销 IdentityServer 时,您的客户端应用程序只有在向 IdentityServer 发出新请求后才会发现并注销自己(也许它们自己的应用程序 cookie 已过期,它们会重新登录,或者他们可能试图请求令牌)。
要实施单点注销,您的每个客户端应用程序都需要有一种方式来让 IdentityServer 告知它们需要注销。这可以使用 front-channel HTTP request or by session management.
来完成查看关于该主题的IdentityServer Signout Support documentation for more details on how to do this or check out Brock Allen's post。