-
Notifications
You must be signed in to change notification settings - Fork 409
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
Decrypt token: Remove exceptions + use new ValidationParameters #2729
Conversation
…alidationParameters
… understand its use and potential for exception throwing if used wrong.
src/Microsoft.IdentityModel.JsonWebTokens/TokenDecryptingResult.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs
Outdated
Show resolved
Hide resolved
# Conflicts: # src/Microsoft.IdentityModel.Tokens/Validation/ValidationFailureType.cs
src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/Results/TokenDecryptingResult.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/Results/TokenDecryptingResult.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.DecryptToken.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.DecryptToken.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.DecryptToken.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.DecryptToken.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JwtTokenUtilities.DecryptTokenResult.cs
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JwtTokenUtilities.DecryptTokenResult.cs
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JwtTokenUtilities.DecryptTokenResult.cs
Outdated
Show resolved
Hide resolved
… exception. Updated iterating over list.
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, you'll need to rebase as my changes went it on Friday
# Conflicts: # src/Microsoft.IdentityModel.Tokens/Validation/ValidationParameters.cs
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.DecryptToken.cs
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.DecryptToken.cs
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JwtTokenUtilities.DecryptTokenResult.cs
Outdated
Show resolved
Hide resolved
/// <param name="decryptionParameters">The decryption parameters container.</param> | ||
/// <param name="callContext">The call context used for logging.</param> | ||
/// <returns>The decrypted, and if the 'zip' claim is set, decompressed string representation of the token.</returns> | ||
internal static TokenDecryptionResult DecryptJwtToken( |
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.
nit: any possibility of splitting this into smaller helper methods?
string zipAlgorithm = null; | ||
foreach (SecurityKey key in decryptionParameters.Keys) | ||
{ | ||
var cryptoProviderFactory = validationParameters.CryptoProviderFactory ?? key.CryptoProviderFactory; |
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.
can the decryption logic be extracted to a helper method?
(exceptionStrings ??= new StringBuilder()).AppendLine(ex.ToString()); | ||
} | ||
|
||
if (key != null) |
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.
do we need to implement any key management or caching (not related to the purpose of keysAttempted
but more around overall impact on performance.
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.
A few nits, nothing blocking.
Decrypt token: Remove exceptions + use new ValidationParameters
Description
Raising this as a draft PR to discuss the approach and validate the plan.
I will add tests before making it official.
Part of #2711.