I am trying to implement Authentication in our website using the Azure AD, following the below reference. Our website uses the below stack ASP.NET, MVC5 hosted on IIS. basically use OpenId Connect protocol for website authentication and use oAuth2.0 protocol for delegated access to use the token for Authorization.
https://github.com/AzureADSamples/WebApp-WebAPI-OpenIDConnect-DotNet
Getting token from the Azure AD logic is there in the Startup.Auth.cs class, which is invoked from the OwinStartup class.
When I implement this in our site, Startup.Auth.cs ConfigureAuth is executed only once during the APP start and as per the above reference.
Decorating the controller classes with the [Authorize] or adding the SignIn() with check if the request is authenticated or not and call the Authenticate code again.
public void SignIn()
{
// Send an OpenID Connect sign-in request.
if (!Request.IsAuthenticated)
{
HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/" }, OpenIdConnectAuthenticationDefaults.AuthenticationType);
}
}
The issue is that The SignIn() method is not getting in our application and also curious on what the [Authorize] attributes does?
I highly appreciate any insight on these. Thanks much in advance.