-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET 9: dotnet user-jwts
not working
#58996
Comments
can you add more details please... like how the jwt token used in this call look like, and the appsettings.developement authentication details |
I'm aware of these possible concerns as I understand these security concepts and I had it working on .NET 8. I have attached the code from following the instructions in the above documentation https://github.com/Zhiyuan-Amos/MyJWT for ease of repro: Just create the JWT using Edit: I downgraded my project to .NET 8 (also downgraded |
you are right it's not working on dotnet9 I debugged deeply I found 2 issues: in dotnet9 the IssuersigningKeys is not loaded from secrets.json, because of a parameter called ValidIssuers. the difference reside in this commit: this can be fixed by adding this to your asppsettings: I am not sure now jsonwebTokenValidator is checking also kid which is empty when you assign IssuerSigninKey by byte[] |
+1 I also had to rollback to the latest version of 8.x.x to resolve this problem. Works fine on 8.x.x |
the problem is that with this change the |
If anyone else is looking for a quick and dirty work around, the following worked for me. builder.Services.AddAuthentication("Bearer").AddJwtBearer(o =>
{
o.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuers = [builder.Configuration.GetSection("Authentication:Schemes:Bearer:ValidIssuer").Get<string>()],
ValidAudiences = builder.Configuration.GetSection("Authentication:Schemes:Bearer:ValidAudiences").Get<string[]>(),
IssuerSigningKey = new SymmetricSecurityKey(Convert.FromBase64String(builder.Configuration.GetSection("Authentication:Schemes:Bearer:SigningKeys:0").GetValue<string>("Value")))
};
}); |
Thanks. I've also ran into this issue and this workaround solved it for me. |
Replacing the ValidIssuer with ValidIssuers array instead, in the appsettings.Development.json file fixed this for me, Thank you. |
Tokens are generated through the Firebase Authentication. This is the configuration on my side, but I got
I'm using these packages and I read somewhere that there could be an issue with the versioning - but I'm not sure.
Is anyone facing a similar issue with Firebase? If it works for you, please send me the version of your packages so that I can also use them. |
Is there an existing issue for this?
Describe the bug
I followed the MSDN and upon sending the HTTP Request with the Bearer token, the server returns 401. The
WWW-Authenticate
response header showsBearer error="invalid_token", error_description="The signature key was not found"
.Expected Behavior
Server returns 200.
Steps To Reproduce
Followed the exact steps in the MSDN
Exceptions (if any)
No response
.NET Version
9.0.100
Anything else?
RID: win-arm64
It used to work on .NET 8.
The text was updated successfully, but these errors were encountered: