注销时绕过帐户选择屏幕@azure/msal-Angular V2

发布于 2025-01-12 00:55:31 字数 252 浏览 2 评论 0原文

我正在使用 @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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心房敞 2025-01-19 00:55:31

为此,首先您必须在 ID 令牌中设置 login_hint 可选声明。这需要在应用程序注册方面完成。 (Azure 门户 -> 应用程序注册 -> 令牌配置 -> 添加可选声明 -> ID -> login_hint)

该声明到位后,MSAL 会将其传递到 logoutRedirect()并将跳过帐户选择器提示。

const account = this.msalService.instance.getActiveAccount();
this.msalService.logoutRedirect({ account: account });

参考: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.

const account = this.msalService.instance.getActiveAccount();
this.msalService.logoutRedirect({ account: account });

Ref: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md#promptless-logout

扭转时空 2025-01-19 00:55:31

如文档中所述: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md#skipping-the-server-sign-out
您可以从您的应用程序注销,而不影响他们在其他应用程序中的登录状态

msalInstance.logoutRedirect({
    onRedirectNavigate: (url) => {
        // Return false if you would like to stop navigation after local logout
        return false;
    }
});

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

msalInstance.logoutRedirect({
    onRedirectNavigate: (url) => {
        // Return false if you would like to stop navigation after local logout
        return false;
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文