注销后重定向到登录(Identity Server 3)
Redirecting to login after logout (Identity Server 3)
这是我第一次使用 Identity Server。从 Identity Server 注销后如何重定向到登录页面?
请指导我正确的方向。
所以这有点烦人,
IDS 不支持自动重定向。
您需要做 4 件事
因此,要在注销时获得某种重定向,您必须添加以下内容:
RedirectToIdentityProvider = n =>
{
if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.LogoutRequest)
{
var idTokenHint = n.OwinContext.Authentication.User.FindFirst("id_token");
if (idTokenHint != null)
{
n.ProtocolMessage.IdTokenHint = idTokenHint.Value;
}
}
return Task.FromResult(0);
}
到客户端代码
然后您需要将 post 注销 uri 添加到客户端设置
然后
也这样做
Request.GetOwinContext().Authentication.SignOut(new AuthenticationProperties
{
RedirectUri = "https://localhost:44306/"
});
我想就是这样
我还向客户端添加了 LogoutUri,但我认为没有必要
这是我第一次使用 Identity Server。从 Identity Server 注销后如何重定向到登录页面?
请指导我正确的方向。
所以这有点烦人,
IDS 不支持自动重定向。
您需要做 4 件事
因此,要在注销时获得某种重定向,您必须添加以下内容:
RedirectToIdentityProvider = n =>
{
if (n.ProtocolMessage.RequestType == OpenIdConnectRequestType.LogoutRequest)
{
var idTokenHint = n.OwinContext.Authentication.User.FindFirst("id_token");
if (idTokenHint != null)
{
n.ProtocolMessage.IdTokenHint = idTokenHint.Value;
}
}
return Task.FromResult(0);
}
到客户端代码
然后您需要将 post 注销 uri 添加到客户端设置
然后
也这样做
Request.GetOwinContext().Authentication.SignOut(new AuthenticationProperties
{
RedirectUri = "https://localhost:44306/"
});
我想就是这样
我还向客户端添加了 LogoutUri,但我认为没有必要