Add SignatureValidatorWithToken delegate with opt-in/decline pattern#3485
Closed
iNinja wants to merge 1 commit into
Closed
Add SignatureValidatorWithToken delegate with opt-in/decline pattern#3485iNinja wants to merge 1 commit into
iNinja wants to merge 1 commit into
Conversation
Introduce a new signature validation delegate that allows callers to either handle signature validation in full or decline, letting the handler fall through to its built-in logic. This replaces the approach in the abandoned PR #3483 which risked recursive loops. New public API surface: - SignatureValidationDelegateResult readonly struct (Success / NotHandled) - SignatureValidatorWithToken delegate - TokenValidationParameters.SignatureValidatorWithToken property The new delegate runs after the existing SignatureValidator and SignatureValidatorUsingConfiguration delegates (which retain priority). When the new delegate returns NotHandled, the handler proceeds with its default signature validation as if no delegate were set. Also fixes configuration passthrough: BaseConfiguration is now correctly forwarded to SignatureValidatorUsingConfiguration and IssuerSigningKeyValidator in the delegate code path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
Abandoning in favour of the approach introduced in #3489 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces a new signature validation delegate that allows callers to either handle signature validation in full or decline, letting the handler fall through to its built-in logic.
This replaces the approach in the abandoned PR #3483, which risked recursive loops when the delegate needed to fall back to default validation.
New public API
SignatureValidationDelegateResult(readonly struct)Success(SecurityToken token)— delegate handled validation successfullyNotHandled— delegate declines; handler proceeds with default logicSecurityTokenInvalidSignatureException)SignatureValidatorWithToken(delegate)TokenValidationParameters.SignatureValidatorWithToken(property)Behaviour
SignatureValidator/SignatureValidatorUsingConfigurationdelegates retain absolute prioritySignatureValidatorWithTokenis evaluatedNotHandled, the handler validates the signature using its default logic as if no delegate were setSuccess, the validated token is used directlyAdditional fix
BaseConfigurationis now correctly forwarded toSignatureValidatorUsingConfigurationandIssuerSigningKeyValidatorin the delegate code path (previously passed asnull).Tests
14 new tests covering:
NotHandled,Success, null guard)All 671+ existing tests pass across all 6 TFMs (net462, net472, net6.0, net8.0, net9.0, net10.0).