microsoft-identity-web icon indicating copy to clipboard operation
microsoft-identity-web copied to clipboard

Issuer validation failed in Azure app service only [Bug]

Open oakular opened this issue 6 years ago • 5 comments

Which version of Microsoft Identity Web are you using? 0.2.1-preview

Where is the issue?

  • Web app
    • [x] Sign-in users
    • [ ] Sign-in users and call web APIs
  • Web API
    • [ ] Protected web APIs (validating tokens)
    • [ ] Protected web APIs (validating scopes)
    • [ ] Protected web APIs call downstream web APIs
  • Token cache serialization
    • [ ] In-memory caches
    • [ ] Session caches
    • [ ] Distributed caches
  • Other (please describe)

Is this a new or an existing app? This is a new application.

Repro Below is the Azure AD config with sensitive data removed:

"AzureAd": {
    "Instance": "https://login.microsoftonline.com",
    "Domain": "<azure-ad-domain>",
    "TenantId": "<azure-ad-tenant-id>",
    "ClientId": "<app-registraction-id>",
    "CallbackPath": "/.auth/login/aad/callback"
}

Here is how the Azure AD is registered in Startup.cs

            services.Configure<CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.Unspecified;
                options.HandleSameSiteCookieCompatibility();
            });

            // AD Auth
            services.AddMicrosoftWebAppAuthentication(Configuration);

            services.AddMvc(options =>
              {
                  var policy = new AuthorizationPolicyBuilder()
                      .RequireAuthenticatedUser()
                      .Build();
                  options.Filters.Add(new AuthorizeFilter(policy));
              })
            .AddMicrosoftIdentityUI();

Expected behavior In the production environment of the Azure App Service, the website should correctly validate the token from the issuer supplied in appsettings.json.

Actual behavior The production website fails to validate the token issuer with this error message: IDX10205: Issuer validation failed. Issuer: '[PII is hidden]'. Did not match: validationParameters.ValidIssuer: '[PII is hidden]' or validationParameters.ValidIssuers: '[PII is hidden]'.

This error does not occur in the development environment, which is using the exact same Azure AD configuration.

Additional context / logs / screenshots I am aware the callback path is not /signin-oidc as suggested in the docs for Azure AD, but I received callback path mismatch errors using that path. I discovered the AD authenticator was trying to return to /.auth/login/aad/callback, so have used that path instead which seems to at least be attempting authentication.

oakular avatar Aug 04 '20 13:08 oakular

Hello, @oakular.

If possible, you can show PII, as described here.

Also if deployed apps are behind a load balancer, for example, that can mess with redirects. More info here.

pmaytak avatar Aug 05 '20 07:08 pmaytak

Did you enable Authentication on app services, @oakular ? See https://github.com/AzureAD/microsoft-identity-web/wiki/deploying-to-app-services

jmprieur avatar Aug 05 '20 07:08 jmprieur

@oakular : I suppose you've enabled the authentication in app services. I'm closing this issue, but feel free to reopen if I'm wrong.

jmprieur avatar Aug 10 '20 07:08 jmprieur

Hi @jmprieur, yes I have enabled authentication in App Services.

@pmaytak I have also set ShowPII = true at the top of ConfigureServices in Startup.cs, but I am still seeing the same error message in Azure: {"code":400,"message":"IDX10205: Issuer validation failed. Issuer: '[PII is hidden]'. Did not match: validationParameters.ValidIssuer: '[PII is hidden]' or validationParameters.ValidIssuers: '[PII is hidden]'."}

@jmprieur please reopen this issue as it is not resolved.

oakular avatar Aug 11 '20 10:08 oakular

@oakular Have you been able to resolve this issue?

Also I think can you try to disable the App Service Authentication in AAD?

pmaytak avatar Aug 21 '20 04:08 pmaytak