AddIdentityServerJwt might accidentally use the wrong issuer URL.
See original GitHub issueDescribe 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:
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
- Create a new SPA sample (dotnet new react -au Individual)
- Login
- Restart the server
- Go to https://127.0.0.1:5001 before you go to any other URL
- 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:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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!
Doc/release note issue filed to track this for 6.0 https://github.com/dotnet/aspnetcore/issues/36676