-
Notifications
You must be signed in to change notification settings - Fork 457
Convert validation delegates to interfaces in Experimental namespace #3399
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
Merged
Merged
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
8685b55
Initial plan
Copilot eaa9568
Convert delegates to interfaces for validators - Core implementation
Copilot c22a14d
Update all usages to call interface methods instead of delegates
Copilot bf0cefe
Add delegate adapters and update test code for interface-based valida…
Copilot 982d813
Fix delegate-to-interface conversion issues in AadValidationParameter…
Copilot aa52a8b
Merge branch 'dev' into copilot/change-delegate-to-interface
westin-m 4d65904
Fix CS0029 errors: Wrap delegate assignments with interface adapters …
Copilot a0d56dc
Convert Custom*ValidationDelegates to use interface implementations
Copilot f1d26e9
Remove backup file
Copilot 6ef27c7
Fix MessageDetail names in throws validators to match method names
Copilot 710116e
Remove delegate adapters, use direct interface implementations
Copilot ab6c45d
Merge branch 'dev' into copilot/change-delegate-to-interface
westin-m 80437e8
Fix SkipValidationDelegates references in Validators tests
Copilot db921ad
fix using
westin-m 31b9f23
file renames, api file fixes
westin-m 2c36111
Merge branch 'dev' into copilot/change-delegate-to-interface
westin-m 81f6b93
Merge branch 'dev' into copilot/change-delegate-to-interface
westin-m 1ba9f04
review feedback
westin-m e1dc208
Merge branch 'copilot/change-delegate-to-interface' of https://github…
westin-m 6cdc7ca
Merge branch 'dev' into copilot/change-delegate-to-interface
westin-m 4a9fd7d
small fix
westin-m 61f509c
Merge branch 'dev' into copilot/change-delegate-to-interface
westin-m d2fe263
Merge branch 'dev' into copilot/change-delegate-to-interface
westin-m be2333e
Merge branch 'dev' into copilot/change-delegate-to-interface
westin-m ee2272f
Merge branch 'dev' into copilot/change-delegate-to-interface
westin-m 28ddc35
Merge branch 'dev' into copilot/change-delegate-to-interface
westin-m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
126 changes: 126 additions & 0 deletions
126
src/Microsoft.IdentityModel.Tokens/Experimental/DefaultValidators.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using System.Threading; | ||
| using System; | ||
|
|
||
| #nullable enable | ||
| namespace Microsoft.IdentityModel.Tokens.Experimental | ||
| { | ||
| /// <summary> | ||
| /// Default implementation of <see cref="IAlgorithmValidator"/> that uses the static Validators.ValidateAlgorithm method. | ||
| /// </summary> | ||
| internal class DefaultAlgorithmValidator : IAlgorithmValidator | ||
| { | ||
| /// <inheritdoc/> | ||
| public ValidationResult<string, ValidationError> ValidateAlgorithm( | ||
| string? algorithm, | ||
| SecurityToken securityToken, | ||
| ValidationParameters validationParameters, | ||
| CallContext callContext) | ||
| { | ||
| return Validators.ValidateAlgorithm(algorithm, securityToken, validationParameters, callContext); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Default implementation of <see cref="IAudienceValidator"/> that uses the static Validators.ValidateAudience method. | ||
| /// </summary> | ||
| internal class DefaultAudienceValidator : IAudienceValidator | ||
| { | ||
| /// <inheritdoc/> | ||
| public ValidationResult<string, ValidationError> ValidateAudience( | ||
| IList<string> tokenAudiences, | ||
| SecurityToken? securityToken, | ||
| ValidationParameters validationParameters, | ||
| CallContext callContext) | ||
| { | ||
| return Validators.ValidateAudience(tokenAudiences, securityToken, validationParameters, callContext); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Default implementation of <see cref="IIssuerValidator"/> that uses the static Validators.ValidateIssuerAsync method. | ||
| /// </summary> | ||
| internal class DefaultIssuerValidator : IIssuerValidator | ||
| { | ||
| /// <inheritdoc/> | ||
| public Task<ValidationResult<ValidatedIssuer, ValidationError>> ValidateIssuerAsync( | ||
| string issuer, | ||
| SecurityToken securityToken, | ||
| ValidationParameters validationParameters, | ||
| CallContext callContext, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| return Validators.ValidateIssuerAsync(issuer, securityToken, validationParameters, callContext, cancellationToken); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Default implementation of <see cref="ISignatureKeyValidator"/> that uses the static Validators.ValidateSignatureKey method. | ||
| /// </summary> | ||
| internal class DefaultSignatureKeyValidator : ISignatureKeyValidator | ||
| { | ||
| /// <inheritdoc/> | ||
| public ValidationResult<ValidatedSignatureKey, ValidationError> ValidateSignatureKey( | ||
| SecurityKey signingKey, | ||
| SecurityToken securityToken, | ||
| ValidationParameters validationParameters, | ||
| CallContext callContext) | ||
| { | ||
| return Validators.ValidateSignatureKey(signingKey, securityToken, validationParameters, callContext); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Default implementation of <see cref="ILifetimeValidator"/> that uses the static Validators.ValidateLifetime method. | ||
| /// </summary> | ||
| internal class DefaultLifetimeValidator : ILifetimeValidator | ||
| { | ||
| /// <inheritdoc/> | ||
| public ValidationResult<ValidatedLifetime, ValidationError> ValidateLifetime( | ||
| DateTime? notBefore, | ||
| DateTime? expires, | ||
| SecurityToken? securityToken, | ||
| ValidationParameters validationParameters, | ||
| CallContext callContext) | ||
| { | ||
| return Validators.ValidateLifetime(notBefore, expires, securityToken, validationParameters, callContext); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Default implementation of <see cref="ITokenReplayValidator"/> that uses the static Validators.ValidateTokenReplay method. | ||
| /// </summary> | ||
| internal class DefaultTokenReplayValidator : ITokenReplayValidator | ||
| { | ||
| /// <inheritdoc/> | ||
| public ValidationResult<DateTime?, ValidationError> ValidateTokenReplay( | ||
| DateTime? expirationTime, | ||
| string securityToken, | ||
| ValidationParameters validationParameters, | ||
| CallContext callContext) | ||
| { | ||
| return Validators.ValidateTokenReplay(expirationTime, securityToken, validationParameters, callContext); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Default implementation of <see cref="ITokenTypeValidator"/> that uses the static Validators.ValidateTokenType method. | ||
| /// </summary> | ||
| internal class DefaultTokenTypeValidator : ITokenTypeValidator | ||
| { | ||
| /// <inheritdoc/> | ||
| public ValidationResult<ValidatedTokenType, ValidationError> ValidateTokenType( | ||
| string? type, | ||
| SecurityToken? securityToken, | ||
| ValidationParameters validationParameters, | ||
| CallContext callContext) | ||
| { | ||
| return Validators.ValidateTokenType(type, securityToken, validationParameters, callContext); | ||
| } | ||
| } | ||
| } | ||
| #nullable restore | ||
171 changes: 0 additions & 171 deletions
171
src/Microsoft.IdentityModel.Tokens/Experimental/Delegates.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.