I\'m using the following code example to plug in Azure AD login to my application (https://github.com/AzureADSamples/WebApp-OpenIDConnect-DotNet).
I\'m finding that
After some re going over the code I've found the solution to my issue.
Within Startup.Auth.cs:
app.UseCookieAuthentication(new CookieAuthenticationOptions {
LoginPath = new PathString("/Account/Login")
});
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions {
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
AuthenticationMode = AuthenticationMode.Passive
});
It's the inclusion of the AuthenticationMode = AuthenticationMode.Passive line which seems to stop OpenIdConnectAuth from performing the automatic 302 redirect to the AAD login pages.
Assuming Azure AD is your identity provider, you can Customize the login page, but you have to be running Azure AD Premium to do so.
This maybe what I'm looking for...
This sample allows a user to login to Azure AD without the need to use Azure AD's native browser based logins.
I understand this is somewhat considered an anti pattern as I'll be forgoing Azure's built in mechanisms for handling multi factor auth, password resets etc. but I'll retain full control of the experience.
==== Edit ==== This isn't the way I want to go as I'll be stripping out a lot of what AAD offers out the box. In essence I'd like to keep AAD's control flows but I just want to have the ability to control what page a user lands on when a user isn't logged in.
Currently the flow is: Not authorised -> 302 redirect -> AAD login
I'd like: Not authorised -> 302 redirect -> Self hosted login required page -> User login button press -> 302 redirect -> AAD login
Its this flow I can't seem to work out.