【问题标题】:Identity Server 4: logout from external providerIdentity Server 4:从外部提供者注销
【发布时间】:2021-03-14 12:26:00
【问题描述】:

我有一个受 Identity Server 保护的 MVC 客户端应用程序 (APP1)。一旦用户注销 idsrv,我就使用反向通道机制注销客户端。和这个很相似:https://github.com/IdentityServer/IdentityServer4/blob/main/samples/Clients/src/MvcHybridBackChannel/Startup.cs

现在的问题是:我需要添加对外部提供商 Azure AD 的支持。反过来,它也应该支持自动注销:当用户从 Azure AD 注销时,他应该从 idsrv 和客户端应用程序中注销。

我的第一个想法是实现相同的方法:Azure 应用注册支持在注销时调用客户端端点的能力。但是当我需要设置自定义 CookieAuthenticationEvents 时,我正在努力解决这个问题。我在客户端应用程序 APP1 中的代码:

services.AddAuthentication(options =>
{
  options.DefaultScheme = "Cookies";
  options.DefaultChallengeScheme = "oidc";
}).AddCookie("Cookies", options =>
{
  options.EventsType = typeof(CookieEventHandler);
}

但相同的代码在 idsrv 中不起作用。但这我的意思是我的 cookie 没有被我的自定义 CookieEventHandler 验证。谁能指出我正确的方向?

【问题讨论】:

    标签: asp.net-mvc asp.net-core identityserver4


    【解决方案1】:

    一个想法是让 Azure AD 调用 AccountController 上的 Logout 方法来注销用户。 (或者如果您制作自己的“注销”端点)。

    注销方法受 ValidateAntiForgeryToken 保护,因此您可能需要通过创建“自己的”注销端点来解决这个问题。

    但基本上你需要做的是让 AzureAD 触发对 HttpContext.SignOutAsync();方法。

    【讨论】:

      猜你喜欢
      • 2017-08-02
      • 2020-06-21
      • 1970-01-01
      • 2019-01-03
      • 2014-04-01
      • 2020-04-10
      • 2021-03-06
      • 2020-10-06
      • 1970-01-01
      相关资源
      最近更新 更多