我有一个受天蓝色广告保护的网站并使用 msal,我想在 iframe 中访问它,但它看起来不起作用。有办法让它发挥作用吗?是否与重定向网址或其他问题有关?
最佳答案
您无法在 iframe 内对用户进行身份验证,这意味着您无法使用重定向 API 来进行用户与身份提供商的交互。
您可以从创建自己的客户页面开始,并允许用户输入凭据,然后对用户进行身份验证。当用户输入凭据并单击登录时,服务器将返回“确定”(如果电子邮件/密码正确)。之后,您应该将 token 保存在本地存储中,然后设置 isAuthenticated = true。
如果您使用身份验证代码流程,那么您应该在外部真实页面而不是 iframe 内进行身份验证。然后,一旦您通过身份验证,您将必须登录。这个概念是,您必须完全重定向到天蓝色广告中的身份验证页面,而不是 iframe 中的身份验证页面。
You can achieve single sign-on between iframed and parent apps with the same-origin and with cross-origin if you pass an account hint from the parent app to the iframed app.
了解更多 here
关于azure-active-directory - iframe 中的 Azure AD MSAL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67324152/