Azure Active Directory在注销时跳过帐户选择

时间:2019-05-08 20:24:42

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

我有一个连接到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的注销屏幕?

2 个答案:

答案 0 :(得分:0)

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

中的代码
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);
};

答案 1 :(得分:0)