Skip to content

Commit 0c75b3a

Browse files
committed
Add TokenValidationParameters.TimeProvider
1 parent d112447 commit 0c75b3a

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/Microsoft.IdentityModel.Tokens/TokenValidationParameters.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ protected TokenValidationParameters(TokenValidationParameters other)
8383
SaveSigninToken = other.SaveSigninToken;
8484
SignatureValidator = other.SignatureValidator;
8585
SignatureValidatorUsingConfiguration = other.SignatureValidatorUsingConfiguration;
86+
#if SUPPORTS_TIME_PROVIDER
87+
TimeProvider = other.TimeProvider;
88+
#endif
8689
TokenDecryptionKey = other.TokenDecryptionKey;
8790
TokenDecryptionKeyResolver = other.TokenDecryptionKeyResolver;
8891
TokenDecryptionKeys = other.TokenDecryptionKeys;
@@ -349,7 +352,7 @@ public virtual ClaimsIdentity CreateClaimsIdentity(SecurityToken securityToken,
349352
/// This means that no default 'issuer' validation will occur.
350353
/// Even if <see cref="ValidateIssuer"/> is false, this delegate will still be called.
351354
/// If both <see cref="IssuerValidatorUsingConfiguration"/> and <see cref="IssuerValidator"/> are set, IssuerValidatorUsingConfiguration takes
352-
/// priority.
355+
/// priority.
353356
/// </remarks>
354357
public IssuerValidator IssuerValidator { get; set; }
355358

@@ -537,6 +540,16 @@ public string RoleClaimType
537540
/// </remarks>
538541
public SignatureValidatorUsingConfiguration SignatureValidatorUsingConfiguration { get; set; }
539542

543+
#if SUPPORTS_TIME_PROVIDER
544+
/// <summary>
545+
/// Gets or sets the time provider used for time validation.
546+
/// </summary>
547+
/// <remarks>
548+
/// If not set, validators will fall back to using the <see cref="DateTime"/> class to obtain the current time.
549+
/// </remarks>
550+
public TimeProvider TimeProvider { get; set; }
551+
#endif
552+
540553
/// <summary>
541554
/// Gets or sets the <see cref="SecurityKey"/> that is to be used for decryption.
542555
/// </summary>
@@ -646,7 +659,7 @@ public string RoleClaimType
646659
/// Gets or sets a boolean that controls if validation of the <see cref="SecurityKey"/> that signed the securityToken is called.
647660
/// </summary>
648661
/// <remarks>It is possible for tokens to contain the public key needed to check the signature. For example, X509Data can be hydrated into an X509Certificate,
649-
/// which can be used to validate the signature. In these cases it is important to validate the SigningKey that was used to validate the signature.
662+
/// which can be used to validate the signature. In these cases it is important to validate the SigningKey that was used to validate the signature.
650663
/// This boolean only applies to default signing key validation. If <see cref= "IssuerSigningKeyValidator" /> is set, it will be called regardless of whether this
651664
/// property is true or false.
652665
/// The default is <c>false</c>.
@@ -676,7 +689,7 @@ public string RoleClaimType
676689

677690
/// <summary>
678691
/// Gets or sets a boolean to control if the token replay will be validated during token validation.
679-
/// </summary>
692+
/// </summary>
680693
/// <remarks>
681694
/// This boolean only applies to default token replay validation. If <see cref= "TokenReplayValidator" /> is set, it will be called regardless of whether this
682695
/// property is true or false.

0 commit comments

Comments
 (0)