-
Notifications
You must be signed in to change notification settings - Fork 417
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
ValidateTokenAsync: New code path #2771
Conversation
…ateJWEAsync Added InternalTokenValidationResult to hold the intermediate validation results. Moved result types to their own folder. Removed unused delegate from TokenValidationParameters
string token, | ||
ValidationParameters validationParameters, | ||
CallContext callContext, | ||
CancellationToken? cancellationToken) |
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.
should we allow this to be 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.
For now I have kept it optional and assigned CancellationToken.None
if it is not present.
We can make this mandatory over the next weeks if we think it is worth enforcing.
return new TokenValidationResult { Exception = LogHelper.LogArgumentNullException(nameof(validationParameters)), IsValid = false }; | ||
|
||
if (token.Length > MaximumTokenSizeInBytes) | ||
return new TokenValidationResult { Exception = LogHelper.LogExceptionMessage(new ArgumentException(LogHelper.FormatInvariant(TokenLogMessages.IDX10209, LogHelper.MarkAsNonPII(token.Length), LogHelper.MarkAsNonPII(MaximumTokenSizeInBytes)))), IsValid = false }; |
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.
please stack these parameters.
/// <exception cref="ArgumentNullException"></exception> | ||
public InternalTokenValidationResult(SecurityToken? securityToken, TokenHandler tokenHandler) | ||
{ | ||
_securityToken = securityToken; |
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.
Why should securityToken be allowed to be 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.
Because there are cases such as validating a token from a string where the reading / decrypting can fail and we end up without a security token, and yet we need to return a result to indicate what went wrong.
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.
Let's get this committed and then start writing tests and E2E developer experiences.
ValidateTokenAsync: New code path
Join all the refactored validators into a new
ValidateTokenAsync
entry point.Description
Tests to be added before marking ready for review.
Creation of
ClaimsIdentity
still needs a resolution, as the current implementation inTokenValidationResult
usesTokenValidationParameters
.Part of #2711