Cuthbert
Cuthbert

Reputation: 1322

Automatic redirect of unauthenticated users

I have a site which uses OpenID Connect OWIN middleware to authenticate users from an Azure Active Directory tenant. Is it possible to redirect an unauthenticated user to the Azure AD login page automatically, without them having to first hit a protected endpoint or click a sign in button?

Upvotes: 2

Views: 394

Answers (1)

Erik Oppedijk
Erik Oppedijk

Reputation: 3551

With skipping Home Realm discovery this will work, sending all users to a single AD. If ADFS is configured correctly and the user is signed in onto the domain, true Single Sign On is performed, otherwise the company login page is displayed.

If you have a mixed set of users(different AD domains), all users will be sent to the same AD login page.

From Vittorio's post: http://www.cloudidentity.com/blog/2014/11/17/skipping-the-home-realm-discovery-page-in-azure-ad/

app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
    ClientId = clientId,
    Authority = authority,
    PostLogoutRedirectUri = postLogoutRedirectUri,
    Notifications = new OpenIdConnectAuthenticationNotifications()
    {
        RedirectToIdentityProvider = (context) => 
        {                                                        
            context.ProtocolMessage.DomainHint = "mydomain.com"; 
            return Task.FromResult(0); 
        }, 
    }
});

Upvotes: 2

Related Questions