I am trying to integrate my web service for authentication using Azure AD. The response from Azure AD changes every time. When I open my site in a regular Firefox browser, IsAuthenticated as true.
IsAuthenticatedAsTrue
Opening in a private browser IsAuthenticated is false.
IsAuthenticatedAsFalse
The only difference I see is IsAuthenticated true from ClaimsIdentity, and IsAuthenticated false from GenericIdentity.
Below is the .auth startup code.
public partial class Startup
{
private static string clientId = ConfigurationManager.AppSettings["ClientId"];
private static string aadInstance = ConfigurationManager.AppSettings["AADInstance"];
private static string tenantId = ConfigurationManager.AppSettings["TenantId"];
private static string postLogoutRedirectUri = ConfigurationManager.AppSettings["PostLogoutRedirectUri"];
private static string authority = aadInstance + tenantId;
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri
});
}
}
The following is my code to send an authentication request to AzureAD
public void LoginUsingAzure()
{
HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/" },
OpenIdConnectAuthenticationDefaults.AuthenticationType);
}