-
Notifications
You must be signed in to change notification settings - Fork 401
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
[Bug] AspNetCore 7.0 WebApi Authentication Fails (JWT) - Missing Method #2059
Comments
Hello We are affected too, bumped version to > 6.27.0 and we now receive 401 on all endpoints requiring JWT authorization |
@dotnetallday @BlowaXD are you using the same versions of the assemblies? |
This happens with 6.30.0 also. |
@mcraiha @BlowaXD @dotnetallday this can happen when IdentityModel assemblies are not the same version. |
@brentschmaltz I made sure all ID assemblies were the same across all my projects in the solution when I did my testing. |
ABP, that uses OpenIddict, submitted a similar report, so it's likely a widespread issue (OpenIddict's latest 4.3.0 version references Wilson 6.30.0): openiddict/openiddict-core#1766. @dotnetallday do you still get an exception if you explicitly reference |
I use the latest OpenIddict package which is reference the 4.3.0 version. The only thing that worked for me was to downgrade OpenIdDict to version 4.2.0 which references version 6.25.1 of this assembly. The latest System.IdentityModel.Tokens.Jwt is broken! |
Same problem. solution - downgrade to 6.27.0 |
@Tentrun @satlom @kevinchalet @dotnetallday looks like a problem, i will investigate. There was a change from 6.27.0 and 6.28.0 in TokenUtilities.IsRecoverableConfiguration, the matching change was made in JwtSecurityTokenHandler and JsonWebTokenHandler. So is there a possibility that the versions are not in sync? |
@brentschmaltz yeah, verisions are not a sync |
@Tentrun you are not the only one to hit this, we have a work item to validate that all the IdentityModel assemblies are the same version on startup and either throw or log a warning. I will remind the team we need to complete that task. |
@brentschmaltz FYI, I had to release a new OpenIddict version referencing 6.25.1 as I kept receiving similar reports. Given that it's not the first time we see such issues in Wilson, you should strongly consider abandoning |
The problem is still happening to me, upgrading from Clearly 24 characters and not 32 SecretKey is my issue Even if My question is, what this is not a breaking change ? |
"Updating" System.IdentityModel.Tokens.Jwt to version 6.31.0 solved this for me. |
Following https://stackoverflow.com/questions/62198808/why-cant-i-create-a-jwt-token-with-sha256 (Although the issue is old and different), I'm now checking whether e.g. changing |
Solved by this in my case... And make sure that your key is at least 256 bits (in UTF8: 32 characters) long... |
Any update on this? |
@alecrodden for I've tried this https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/wiki/IDX10720 but this switch doesn't work for me, and it is unclear how it could work according to the source code of |
#2059 (comment) should work. |
@SeppPenner @VitaliyMF @alecrodden the issue with key size and KeyedHashAlgorithm can be resolved with release 6.35.0 We will not address in 7.x as the change follows the spec. |
Which version of Microsoft.IdentityModel are you using?
6.27.0 (the latest stable version throws the exception)
Where is the issue?
Is this a new or an existing app?
The app is in production and I have upgraded to a new version of Microsoft.IdentityModel.*
Repro
Expected behavior
After being issued a valid JWT token (verified by 3rd party site - jwt.io) and my current above code stop working after NuGet package updates, any web api controller with the [Authorize] attribute incorrectly responds with a 401, despite the valid token being passed as "Bearer". I noticed this issue only after I had updated a number of NuGet packages and finally determined that this package was the culprit through inspection of my console output. It appears the new package is missing a method:
Method not found: 'Boolean Microsoft.IdentityModel.Tokens.TokenUtilities.IsRecoverableConfiguration
Actual behavior
A 401 response is returned for all API requests, despite valid JWT tokens being passed.
Possible solution
I downgraded to 6.27.0 and this resolved my issue.
Additional context / logs / screenshots / links to code
None.
The text was updated successfully, but these errors were encountered: