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.

AddIdentityServerJwt might accidentally use the wrong issuer URL.

See original GitHub issue

Describe the bug

When using AddIdentityServerJwt the IssuerURL seems to be derived from the actual request. The option management hooks into the events and enriches the options with the host name from the request:

https://github.com/dotnet/aspnetcore/blob/b795ac3546eb3e2f47a01a64feb3020794ca33bb/src/Identity/ApiAuthorization.IdentityServer/src/Authentication/IdentityServerJwtBearerOptionsConfiguration.cs#L63

When the first request that comes in is not the public host name, the options is enriched with the wrong host and all subsequent calls to authorize fail because the issuer URL does not match.

Consider a scenario where you have a health check running. The health service uses the internal IP (e.g. in kubernetes) to call the health endpoint and the issuer URL is configured with the IP address.

To Reproduce

  1. Create a new SPA sample (dotnet new react -au Individual)
  2. Login
  3. Restart the server
  4. Go to https://127.0.0.1:5001 before you go to any other URL
  5. Go to https://localhost:5001 and press fetch data

The result in Chrome:

Bearer error="invalid_token", error_description="The issuer 'https://localhost:5001' is invalid"

Further technical details

  • ASP.NET Core version 5

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mkArtakMSFTcommented, Dec 28, 2020

Thanks for contacting us, @SebastianStehle. Due to the holiday season please expect some delays in our responses. @HaoK can you please investigate this when you’re back? Thanks!

0reactions
HaoKcommented, Sep 17, 2021

Doc/release note issue filed to track this for 6.0 https://github.com/dotnet/aspnetcore/issues/36676

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I configure Identity Server to correctly validate ...
To configure the IdentityServer JWT Bearer you can use a configure call: services.Configure<JwtBearerOptions>(IdentityServerJwtConstants.
Read more >

github_iconTop Related Medium Post

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