Spr*_*per 9 reactjs azure-active-directory
我将 Azure AD 与 React JS 结合使用。当我使用多个帐户登录并调用 msal logout 时,它会向我显示一个选项来选择需要注销的帐户。我只想显示当前活动帐户的注销选项,而不是所有登录用户的注销选项。
我尝试使用以下代码片段传递活动帐户,但我仍然可以选择注销所有登录帐户。您能否告诉我如何获得仅注销活动帐户而不是所有登录帐户的选项?
const myMsal = new PublicClientApplication(config);
// you can select which account application should sign out
const logoutRequest = {
account: myMsal.getAccountByHomeId(homeAccountId)
}
myMsal.logoutRedirect(logoutRequest);
Run Code Online (Sandbox Code Playgroud)
您可以使用无提示注销:
const currentAccount = msalInstance.getAccountByHomeId(homeAccountId);
// The account's ID Token must contain the login_hint optional claim to avoid the account picker
await msalInstance.logoutRedirect({ account: currentAccount});
Run Code Online (Sandbox Code Playgroud)
您需要将login_hint声明添加到 Azure 门户上应用程序令牌配置中的令牌可选声明:
小智 0
msal logout 显示一个选项来选择需要注销的帐户
您看到的注销提示来自 AAD 服务,因为它需要知道在身份验证服务器端终止哪个用户的会话
不幸的是,这是 AAD 服务的一个已知问题。此时,无法绕过注销时的注销帐户选择屏幕
根据此文档:https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logout.md和代码描述,MSAL 清除缓存并客户端(浏览器)的会话数据
有 github 问题,您可以参考它以获取更多详细信息:
https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/2922
| 归档时间: |
|
| 查看次数: |
7856 次 |
| 最近记录: |