Class DPoPProofReplayValidator

java.lang.Object
org.springframework.security.oauth2.jwt.DPoPProofReplayValidator
All Implemented Interfaces:
org.springframework.security.oauth2.core.OAuth2TokenValidator<Jwt>

public final class DPoPProofReplayValidator extends Object implements org.springframework.security.oauth2.core.OAuth2TokenValidator<Jwt>
An OAuth2TokenValidator that mitigates DPoP Proof Replay.

This validator mitigates DPoP Proof Replay by ensuring the DPoP Proof:

  • contains the iat (issued at) claim, and it's within an acceptable time window (configured via setClockSkew(Duration))
  • contains the jti (JWT ID) claim, and it has not been used previously

This implementation uses a Cache to store the jti claim (along with other information in CacheValue) to enforce single-use. The jti is retained in the cache until the DPoP Proof expires, which is calculated as iat + clockSkew.

Since:
6.5.12
See Also:
  • Constructor Details

    • DPoPProofReplayValidator

      public DPoPProofReplayValidator(org.springframework.cache.Cache cache)
      Constructs a DPoPProofReplayValidator using the provided parameters.
      Parameters:
      cache - the Cache used to store DPoPProofReplayValidator.CacheValue which contains information of the used DPoP Proof Jwt's
  • Method Details

    • validate

      public org.springframework.security.oauth2.core.OAuth2TokenValidatorResult validate(Jwt jwt)
      Specified by:
      validate in interface org.springframework.security.oauth2.core.OAuth2TokenValidator<Jwt>
    • setClockSkew

      public void setClockSkew(Duration clockSkew)
      Sets the clock skew. The default is 30 seconds.
      Parameters:
      clockSkew - the clock skew
    • setClock

      public void setClock(Clock clock)
      Sets the Clock used in Instant.now(Clock).
      Parameters:
      clock - the clock