question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Unable to authenticate using Azure front door and AAD

See original GitHub issue

Which version of Microsoft Identity Web are you using? Microsoft.Identity.Web 1.8.1

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 app that requires authentication + azure front door.

Repro I’m trying to simply place my authenticated web app behind Azure Front door.

I have an Azure front door with a single front end host. This maps to a single web app on the back end right now. The back end is configured as follows: image The rules are configured as follows: image

 services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
                .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"));

 "AzureAd": {
    "Instance": "https://login.microsoftonline.com/",
    "Domain": "<removed>",
    "ClientId": "<removed>",
    "TenantId": "organizations",
    "CallbackPath": "/signin-oidc",
  },

Expected behavior When the user hits the frontdoor endpoint their request is forwarded to origin to login. The logged in user is never redirected away from the front door end point and only ever sees the front door endpoint.

Actual behavior When the user hits the frontdoor endpoint they’re redirected to the login page. Once logged in via the login ui, they are redirected back to the app service endpoint and not the front door endpoint.

Possible solution

I did find a similar bug (https://github.com/AzureAD/microsoft-identity-web/issues/115), and conceptually I think a similar issue is happening but did not have success with implementing this. Futhermore looking for guidance in general. Essentially, I think the cdn makes a request to origin and origin only knows to reply with it’s own hostname so when we hit the login page, origin has already said ‘redirect to origin’. How can I reliably make this redirect back to the front door?.

Additional context / logs / screenshots Add any other context about the problem here, such as logs and screenshots.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
TaylorTheDevelopercommented, Apr 6, 2021

Ahh, that was it. I did have x-forwarded-for headers as well. Opting for just XForwardedHost + XForwardedProto did the trick without requiring me to override anything. Thanks!

0reactions
Tratchercommented, Mar 31, 2021

Do your requests have x-forwarded-for headers? A lot of the processing is tied to those. You can try disabling that with: options.ForwardedHeaders = ForwardedHeaders.XForwardedHost | ForwardedHeaders.XForwardedProto;

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solving Azure AD Sign In Failure with Azure Front Door
The problem is that we don't have a correct host header to pass to Azure AD, so how can we tell Azure Front...
Read more >
Front Door + App Service with built-in authentication not ...
Go to your App Service · Go to Custom Domains · Copy the Custom Domain Verification ID · Add a new DNS TXT...
Read more >
"Unable to authenticate your credentials" error when you ...
Describes an issue that triggers an Unable to authenticate your credentials. Make sure that your user name is in the format @ error....
Read more >
HTTP-500 error when connecting from FrontDoor with AAD ...
I created a Blazor Server app that uses the AAD authentication, referring to the following URL.
Read more >
How to authorize with Azure Front Door URL using ...
I'm trying to set up authorization via Front Door and got some problem here. After authentication I stuck on this url https://identity.2.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found