简体   繁体   中英

.NET OpenIdConnect reauthenticate to App B when authentication failed for App A

I was wondering if it is a possibility to reauthenticate to another Azure app when the authentication failed of the first app. In multiple .NET apps, I'm using OpenIdConnect to authenticate to an Azure app. When a user is not assigned, it will trigger the AuthenticationFailed event.

In Azure I've created two apps and I would like to check authentication of those apps in a single web app. For the user at the frontend there should not change a thing. They should stay at the same website. This would mean that you should change the client id at runtime.

AuthenticationFailed = context =>
{
       // set new client id and authenticate again
}

So, I would like to know if it is possible to reauthenticate to another app at the AuthenticationFailed event. A redirect to another webapp would be the last option. What would be the best solution for this?

The apps will not have access to each other's directories and if they are under the same tenant then the authentication would need to be successful for both. So from my understanding the second authentication would need to be done separately, but you should be able to just redirect to a new site if Request.IsAuthenticated = false. https://docs.microsoft.com/en-us/azure/application-gateway/redirect-overview

private void Page_Load(object sender, EventArgs e)
{
    // Check whether the current request has been
    // authenticated. If it has not, redirect the 
    // user to the new page.
    if (!Request.IsAuthenticated)
    {
        Response.Redirect("mysite.cpm");
    }
}

Redirect to external URI from ASP.NET MVC controller

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