【问题标题】:Identity Server 4 - federated logout of google when used as an idpIdentity Server 4 - 用作 idp 时联合注销 google
【发布时间】:2018-11-09 18:37:07
【问题描述】:

我已将 google 配置为外部身份提供者。如何将 IdentityServer 配置为也注销此外部身份提供者以及我的所有客户端应用程序?

仅供参考,客户端应用程序退出已经在工作。只想让用户退出谷歌。

【问题讨论】:

    标签: identityserver4 google-identity


    【解决方案1】:

    回答

    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);
    }
    

    直接从文档Sign-out of External Identity Providers中翻录

    【讨论】:

      【解决方案2】:

      这就是我所做的。在注销的视图中,我添加了一个 iframe 和一个按钮,单击该按钮时会在 iframe 中加载谷歌注销 url。这似乎运作良好。

      【讨论】:

        猜你喜欢
        • 2019-01-03
        • 2019-07-02
        • 1970-01-01
        • 1970-01-01
        • 2020-10-06
        • 2022-01-23
        • 2020-04-10
        • 2021-03-14
        • 2018-03-06
        相关资源
        最近更新 更多