【问题标题】:Azure Active Directory skip account selection on logoutAzure Active Directory 在注销时跳过帐户选择
【发布时间】:2019-09-26 15:32:11
【问题描述】:

我有一个连接到 Azure Active Directory 的 ASP.Net Core 应用程序。登录效果很好,但在退出时我希望它立即发生,而无需通过 Azure AD 中的“选择帐户”屏幕。

我已经使用了示例应用程序(https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2)并修改了启动方法:

services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
   {

                options.Authority = options.Authority + "/v2.0/";
                options.SaveTokens = true;
   }

我读到 SaveTokens 应该导致在注销时设置 id_token_hint(假设这将绕过注销屏幕),但这没有发生。

如何让应用程序立即注销而不进入 Azure 的注销屏幕?

【问题讨论】:

  • 您在此存储库中使用了哪个特定示例?
  • @TiagoBrenck 我使用了 aspnetcore2-2 分支(它有一个项目)

标签: c# azure-active-directory openid-connect


【解决方案1】:

您需要在 OnRedirectToIdentityProviderForSignOut 事件中进行配置。示例代码active-directory-aspnetcore-webapp-openidconnect-v2

services.Configure<OpenIdConnectOptions>(options => {
    options.Events.OnRedirectToIdentityProviderForSignOut = async context =>
    {
       var user = context.HttpContext.User;

       // Avoid displaying the select account dialog
       context.ProtocolMessage.LoginHint = user.GetLoginHint();
       context.ProtocolMessage.DomainHint = user.GetDomainHint();
       await Task.FromResult(0);
    };
});

【讨论】:

  • 不幸的是,这不起作用。我仍然会看到帐户选择屏幕。但是,我确实在 URL 中看到了 login_hint 和 domain_hint 参数。
  • 你能检查一下 user.GetLoginHint() 是否返回正确的登录名
  • 确实如此。我使用我的企业电子邮件帐户登录,这是 GetLoginHint() 返回的那个
  • 我也得到了这个工作。必须在 ConfigureServices 函数中使用闭包调用 services.Configure 才能使其工作。在编辑中添加了该上下文。
【解决方案2】:

【讨论】:

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