[英]Azure Active Directory skip account selection on logout
我有一個連接到 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 的注銷屏幕?
您需要在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);
};
});
事實證明,v2 端點不再可能出現這種行為: https : //github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/issues/126
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.