-
Notifications
You must be signed in to change notification settings - Fork 422
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
Add TryAllDecryptionKeys flag to whether decrypt if no key IDs match #3128
Conversation
55ad3e3
to
35aaac2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 8 changed files in this pull request and generated no comments.
Files not reviewed (3)
- src/Microsoft.IdentityModel.Tokens/PublicAPI.Unshipped.txt: Language not supported
- src/Microsoft.IdentityModel.Tokens/LogMessages.cs: Evaluated as low risk
- test/Microsoft.IdentityModel.JsonWebTokens.Tests/JsonWebTokenHandlerTests.cs: Evaluated as low risk
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.CreateToken.cs
Show resolved
Hide resolved
Any performance tests needed given the additional logic for key handling? |
Don't think so. It's just one extra bool flag check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks @pmaytak
There are formatting issues (IDE0055) that need to be addressed, probably in a different PRs (see at the bottom of the PR, as you have not touched that file)
35aaac2
to
f9daa79
Compare
SummarySummary
CoverageMicrosoft.IdentityModel.JsonWebTokens - 80.3%
|
Fixes #3129
TryAllDecryptionKeys
toTokenValidationParameters
to indicate whether all decryption keys should be tried during token decryption when a key is not matched to the token 'kid' or if the token 'kid' is empty. This property defaults totrue
. [1] [2]GetContentEncryptionKeys
andDecryptToken
methods to use the newTryAllDecryptionKeys
property for determining when to try all decryption keys. [1] [2]The precedence of decryption methods:
TokenValidationParameters.TokenDecryptionKeyResolver
, if set.TokenValidationParameters.TokenDecryptionKey
, if set and key ID matches.TokenValidationParameters.TokenDecryptionKeys
, if set and contains any keys where key ID matches.TokenValidationParameters.TryAllDecryptionKeys
is set to 'true',TokenValidationParameters.TokenDecryptionKey
,TokenValidationParameters.TokenDecryptionKeys
, andTokenDecryptionKeys
from configuration.Note: I will add more tests if this approach is agreed on.