Adb2c SSO in MVC apps

Prateek Rathore 21 Reputation points
2021-09-13T07:53:48.407+00:00

I have 3 mvc apps and i am integrating adb2c sso.

My requirement is when i logged in 1st app and open 2nd app in same browser it will first check the azure session and if it presents then it will automatically logged in 2nd app and redirect to home page and if there is no azure session then it should just simply redirect to home page of web app.

Can any one help me on the above requriement?

Currently what happening if user not logged in any 3 apps and when i check azure session it will open sign form instead of redirecting to home page. as i am using below code on page load and on the behalf of this code either it will open sign in form or logged in the user and redirect to callback path.

if (!Request.IsAuthenticated)
{
HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/") });
}

otherwise, SSO works fine if i remove this code from page load and when user logged in 1st app and when user open 2nd app and click on login it automatically logged in without sign in form

Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,706 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Hazem Elshabini 86 Reputation points
    2021-09-27T14:58:25.08+00:00

    Are you using Microsoft.Identity.Client?
    It should be able to automatically do that for you via cookies.

    In the Startup.Auth.cs, make sure you include:
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
    app.UseCookieAuthentication(new CookieAuthenticationOptions());

    Here is a full sample.