Skip to content

Commit

Permalink
Add TokenValidationParameters.TimeProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
trejjam committed Aug 7, 2024
1 parent c8b478f commit 20bcf69
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Microsoft.IdentityModel.Tokens/TokenValidationParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ protected TokenValidationParameters(TokenValidationParameters other)
SaveSigninToken = other.SaveSigninToken;
SignatureValidator = other.SignatureValidator;
SignatureValidatorUsingConfiguration = other.SignatureValidatorUsingConfiguration;
#if SUPPORTS_TIME_PROVIDER
TimeProvider = other.TimeProvider;
#endif
TokenDecryptionKey = other.TokenDecryptionKey;
TokenDecryptionKeyResolver = other.TokenDecryptionKeyResolver;
TokenDecryptionKeys = other.TokenDecryptionKeys;
Expand Down Expand Up @@ -349,7 +352,7 @@ public virtual ClaimsIdentity CreateClaimsIdentity(SecurityToken securityToken,
/// This means that no default 'issuer' validation will occur.
/// Even if <see cref="ValidateIssuer"/> is false, this delegate will still be called.
/// If both <see cref="IssuerValidatorUsingConfiguration"/> and <see cref="IssuerValidator"/> are set, IssuerValidatorUsingConfiguration takes
/// priority.
/// priority.
/// </remarks>
public IssuerValidator IssuerValidator { get; set; }

Expand Down Expand Up @@ -537,6 +540,16 @@ public string RoleClaimType
/// </remarks>
public SignatureValidatorUsingConfiguration SignatureValidatorUsingConfiguration { get; set; }

#if SUPPORTS_TIME_PROVIDER
/// <summary>
/// Gets or sets the time provider used for time validation.
/// </summary>
/// <remarks>
/// If not set, validators will fall back to using the <see cref="DateTime"/> class to obtain the current time.
/// </remarks>
public TimeProvider TimeProvider { get; set; }
#endif

/// <summary>
/// Gets or sets the <see cref="SecurityKey"/> that is to be used for decryption.
/// </summary>
Expand Down Expand Up @@ -646,7 +659,7 @@ public string RoleClaimType
/// Gets or sets a boolean that controls if validation of the <see cref="SecurityKey"/> that signed the securityToken is called.
/// </summary>
/// <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,
/// 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.
/// 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.
/// This boolean only applies to default signing key validation. If <see cref= "IssuerSigningKeyValidator" /> is set, it will be called regardless of whether this
/// property is true or false.
/// The default is <c>false</c>.
Expand Down Expand Up @@ -676,7 +689,7 @@ public string RoleClaimType

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

0 comments on commit 20bcf69

Please sign in to comment.