【发布时间】:2018-11-09 18:37:07
【问题描述】:
我已将 google 配置为外部身份提供者。如何将 IdentityServer 配置为也注销此外部身份提供者以及我的所有客户端应用程序?
仅供参考,客户端应用程序退出已经在工作。只想让用户退出谷歌。
【问题讨论】:
标签: identityserver4 google-identity
我已将 google 配置为外部身份提供者。如何将 IdentityServer 配置为也注销此外部身份提供者以及我的所有客户端应用程序?
仅供参考,客户端应用程序退出已经在工作。只想让用户退出谷歌。
【问题讨论】:
标签: identityserver4 google-identity
回答
Google 不支持 Signout for Google External Identity Provider isn't working
背景信息:
当用户退出 IdentityServer,并且他们使用外部身份提供者登录时,他们很可能应该被重定向到也退出外部提供者。 Not all external providers support sign-out, as it depends on the protocol and features they support.
要检测用户必须被重定向到外部身份提供者才能退出,通常使用在 IdentityServer 的 cookie 中发出的 idp 声明来完成。此声明中设置的值是相应身份验证中间件的 AuthenticationScheme。在退出时会参考此声明以了解是否需要外部退出。
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Logout(LogoutInputModel model)
{
// build a model so the logged out page knows what to display
var vm = await _account.BuildLoggedOutViewModelAsync(model.LogoutId);
var user = HttpContext.User;
if (user?.Identity.IsAuthenticated == true)
{
// delete local authentication cookie
await HttpContext.SignOutAsync();
// raise the logout event
await _events.RaiseAsync(new UserLogoutSuccessEvent(user.GetSubjectId(), user.GetName()));
}
// check if we need to trigger sign-out at an upstream identity provider
if (vm.TriggerExternalSignout)
{
// build a return URL so the upstream provider will redirect back
// to us after the user has logged out. this allows us to then
// complete our single sign-out processing.
string url = Url.Action("Logout", new { logoutId = vm.LogoutId });
// this triggers a redirect to the external provider for sign-out
return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme);
}
return View("LoggedOut", vm);
}
【讨论】:
这就是我所做的。在注销的视图中,我添加了一个 iframe 和一个按钮,单击该按钮时会在 iframe 中加载谷歌注销 url。这似乎运作良好。
【讨论】: