简体   繁体   中英

ADAL Azure Active Directory SignOut Redirect URL not working anymore

Implemented authentication for my web-app with azure AD 5 weeks ago, had a few initial problems whereby if a user had cached credentials from another directory (in this case my university's) the signin wouldn't work properly. The solution was to implement the following code:

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);
            }
        }
    }

What this essentially does is force the user to signout then immediately sign back in, the process really only takes about 1.5 seconds so it seemed like a neat solution to wipe any cached credentials. This has been working for the past 5 weeks but has all of a sudden stopped working on both my test and live systems. Signout will work without fault but the redirect back to the signin url doesn't kick in, hence stranding the user on the screen in the attached screenshot . You can view the specified site here , the issue presents itself when you click the Sign In button.

After double checking source control, I can confirm that any changes that I have made to the code recently cannot have caused the issue, it almost appears as if there has been a change in the way that microsoft handles things on their side.

Architecture: Azure Web App running on .NET 4.5

Thanks in advance and don't hesitate to let me know if I can provide anymore useful information,

Thanks, Craig

I'm not sure what could be the problem that you're facing locally, but I had problems when I've published to Azure, because it was overwriting my ida:Audience setting. Take a look at your web.config using Kudu and see if it is still as you want.

Azure AD + ADAL.js + App Service - Only one claim on ClaimsPrincipal.Current.Claims

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM