带有 Iframe 解决方案的 Azure AD Owin

Azure AD Owin with Iframe solution

我有一个设置为使用 Owin 和 Azure AD 的应用程序。它运行良好,但我现在需要在 iframe 中 运行 作为第三方解决方案的一部分。

除了安全之外,这还可以。 https://login.microsoftonline.com 不允许在 iframe 中使用 运行ning。我的控制器将检查用户是否通过身份验证,如果没有,请调用 'HttpContext.GetOwinContext().Authentication.Challenge(..............'

根据研究,我似乎不太可能在框架内做任何事情。我创建登录页面的唯一选择是重定向到包含 iframe 的客户端应用程序吗?如果这个过期了,那么iframe当前会显示一个错误,说明内容无法显示在一个框架中,这不是很优雅。

AAD 不允许对输入凭据的页面进行设计。此要求源于防止点击劫持式攻击的需要。参见:https://www.owasp.org/index.php/Clickjacking。相反,您可以先进行全帧身份验证,然后使用 prompt=none 进行帧身份验证以刷新票证。 Prompt=none 告诉 AAD 不允许停止并请求凭据,因此此流程将始终在 iframe 中运行。

作为已接受答案的补充,我能够通过确保 iframe URL 的大小写与我在 Azure AD 中的应用程序注册中提供的内容完全匹配来解决该问题。例如。如果 Azure AD 有 https://mydomain/My-App/ as one of my reply URLs then ensure that the iframe URL is spelled exactly the same way. I initially had my iframe URL as https://mydomain/my-app/my-page and was encountering the same issue described above till I changed the casing to https://mydomain/My-App/my-page.