ADAL Azure Active Directory SignOut重定向URL不再工作

本文关键字:URL 不再 工作 重定向 SignOut Azure Active Directory ADAL | 更新日期: 2023-09-27 18:17:04

5周前为我的web应用程序实现了azure AD的身份验证,有一些最初的问题,即如果用户从另一个目录(在这种情况下是我的大学)缓存凭据,那么登录将无法正常工作。解决方案是实现以下代码:

public void SignIn(bool? signedOut)
    {
        // Send an OpenID Connect sign-in request.
        if (!Request.IsAuthenticated)
        {
            // If the user is currently logged into another directory, log them out then attempt to
            // reauthenticate under this directory
            if (signedOut == null || signedOut == false)
            {
                HttpContext.GetOwinContext().Authentication.SignOut(
                    new AuthenticationProperties { RedirectUri = Url.Action("SignIn", "Account", routeValues: new { signedOut = true }, protocol: Request.Url.Scheme) },
                    OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType);
            }
            else
            {
                HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = Url.Action("Dashboard", "User", routeValues: null, protocol: Request.Url.Scheme) },
                    OpenIdConnectAuthenticationDefaults.AuthenticationType);
            }
        }
    }

这实际上是强制用户注销然后立即重新登录,这个过程实际上只需要大约1.5秒,所以擦除任何缓存的凭据似乎是一个简洁的解决方案。这在过去的5周内一直有效,但在我的测试系统和实际系统上突然停止了工作。签到将工作没有故障,但重定向回登录url没有踢,因此滞留在屏幕上的用户在附件的截图。您可以在这里查看指定的网站,当您单击"登录"按钮时,问题就会出现。

在仔细检查源代码控制之后,我可以确认我最近对代码所做的任何更改都不会引起问题,看起来好像微软处理事情的方式发生了变化。

架构:运行在。net 4.5上的Azure Web应用

如果我能提供更多有用的信息,请提前感谢我,不要犹豫,请告诉我,

谢谢,克雷格

ADAL Azure Active Directory SignOut重定向URL不再工作

我不确定您在本地面临的问题是什么,但我在发布到Azure时遇到了问题,因为它覆盖了我的ida:Audience设置。看看你的网站。使用Kudu配置,看看它是否仍然是你想要的。

Azure AD + ADAL.js + App Service - claimsprprincipal . current . claims只有一个声明