注销时绕过帐户选择屏幕@azure/msal-Angular V2
我正在使用 @azure/msal-angular 版本 2 和 Angular 版本 13。情况是当登录应用程序的用户需要对用户进行授权,如果用户没有访问权限,则需要从应用程序中注销用户。这将通过调用 msalService.logoutRedirect() 在后台发生。调用注销功能时,将显示 Microsoft 帐户选择屏幕以注销而不是自动注销。有没有办法跳过帐户选择屏幕以退出。
I am using the @azure/msal-angular version 2 and Angular version 13. The scenario is when the user signed in to the application need to authorize the user if he doesn't have access need to sign out the user from the application. which will be happened in background by calling msalService.logoutRedirect(). While calling the logout function the microsoft account selection screen is displayed to signout instead of auto signout. Is there any way to skip the account selection screen to siignout.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为此,首先您必须在 ID 令牌中设置
login_hint
可选声明。这需要在应用程序注册方面完成。 (Azure 门户 -> 应用程序注册 -> 令牌配置 -> 添加可选声明 -> ID -> login_hint)该声明到位后,MSAL 会将其传递到
logoutRedirect()
并将跳过帐户选择器提示。参考:https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md#promptless-logout
To do this, first you have to setup the
login_hint
optional claim in the ID token. That needs to be done on the app registration side of things. (Azure Portal -> App Registration -> Token Configuration -> Add Optional Claim -> ID -> login_hint)Once that claim is in place, MSAL will pass that into
logoutRedirect()
and will skip the account picker prompt.Ref: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md#promptless-logout
如文档中所述: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md#skipping-the-server-sign-out
您可以从您的应用程序注销,而不影响他们在其他应用程序中的登录状态
As mentioned here in the documentation: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md#skipping-the-server-sign-out
You may logout from your application without affecting their login status in other applications