我已经实现了IdentityServer3来创建我自己的身份服务器,该服务器托管在azure云上。 我有几个客户端应用程序通过我的身份服务器进行身份验证。这两个应用程序都是MVC应用程序。其中一个在Azure上作为cloudapp运行,另一个在我的本地计算机上运行并在localhost上运行。正如预期的那样,当我登录其中一个时,我会自动进入另一个。 但是,当我退出其中任何一个时,我都无法自动从同一浏览器中打开的其他人退出。
非常感谢任何帮助...... :)
以下是我的客户端应用的身份验证配置
public void ConfigureAuth(IAppBuilder app)
{
JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>();
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
var options = new OpenIdConnectAuthenticationOptions
{
ClientId = ConfigHelper.GetAppSetting(ConfigConstants.ClientIdKeyName),
Authority = ConfigHelper.GetAppSetting(ConfigConstants.IdpUriKeyName),
RedirectUri = "https://myclient1.cloudapp.net/",
PostLogoutRedirectUri = "https://myclient1.cloudapp.net/account/logoutcallback",
ResponseType = "code id_token token",
Scope = "openid profile address roles email",
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name",
RoleClaimType = "role"
},
SignInAsAuthenticationType = "Cookies",
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthorizationCodeReceived = async n =>
{
var tokenClient = new TokenClient(
"https://myidp.cloudapp.net/core/connect/token",
"myclient-1",
"myclient-1-secret");
var tokenResponse = await tokenClient.RequestAuthorizationCodeAsync(
n.Code, n.RedirectUri);
if (tokenResponse.IsError)
{
throw new Exception(tokenResponse.Error);
}
var id = new ClaimsIdentity(n.AuthenticationTicket.Identity.Claims, n.AuthenticationTicket.Identity.AuthenticationType);
n.AuthenticationTicket = new AuthenticationTicket(new ClaimsIdentity(id.Claims, n.AuthenticationTicket.Identity.AuthenticationType, "name", "role"),
n.AuthenticationTicket.Properties);
}
}
};
app.UseOpenIdConnectAuthentication(options);
}
我正在打电话
this.Request.GetOwinContext().Authentication.SignOut();
注销身份服务器
当它返回到我的客户端应用程序时,它来到
public ActionResult LogoutCallback()
{
HttpCookie cookie = new HttpCookie("SecureCookieName");
cookie.HttpOnly = true;
cookie.Expires = new DateTime(1999, 10, 12);
Response.Cookies.Remove("SecureCookieName");
Response.Cookies.Add(cookie);
SessionManager.KillSession(); //Custom stuff to clear the session of client application.
return RedirectToAction("Index", "Home");
}
答案 0 :(得分:0)
解决问题的一种方法:
在eacheach客户端nammed logout端点上创建属性,或者具有每个客户端应具有/account/logout/
路由的约定。
然后,在每个应用程序中实现此路由,并使该路由删除应用程序cookie。在idsrv的logout.html
视图中,创建一个循环遍历所有客户端列表的javascript,并为每个客户端调用此端点。