The Azure AD API returns System.Security.Principal.GenericIdentity.IsAuthenticated as false always

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);
    }
+4
2

. . stackoverflow.

ASP.NET_SessionId + OWIN Cookies

Kentor.OwinCookieSaver -Version 1.1.0 nuget, .

0

, , . - 50.1.0 .

, Firefox .

:

enter image description here

0

Source: https://habr.com/ru/post/1666576/


All Articles