Class DPoPProofReplayValidator
java.lang.Object
org.springframework.security.oauth2.jwt.DPoPProofReplayValidator
- All Implemented Interfaces:
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 viasetClockSkew(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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA representation of the value to which theCachemaps a (hashed)(jti)claim as the key.static final classAn in-memoryCacheimplementation backed by aConcurrentHashMap. -
Constructor Summary
ConstructorsConstructorDescriptionDPoPProofReplayValidator(org.springframework.cache.Cache cache) Constructs aDPoPProofReplayValidatorusing the provided parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidSets theClockused inInstant.now(Clock).voidsetClockSkew(Duration clockSkew) Sets the clock skew.Verify the validity and/or constraints of the provided OAuth 2.0 Token.
-
Constructor Details
-
DPoPProofReplayValidator
public DPoPProofReplayValidator(org.springframework.cache.Cache cache) Constructs aDPoPProofReplayValidatorusing the provided parameters.- Parameters:
cache- theCacheused to storeDPoPProofReplayValidator.CacheValuewhich contains information of the used DPoP ProofJwt's
-
-
Method Details
-
validate
Description copied from interface:OAuth2TokenValidatorVerify the validity and/or constraints of the provided OAuth 2.0 Token.- Specified by:
validatein interfaceOAuth2TokenValidator<Jwt>- Parameters:
jwt- an OAuth 2.0 token- Returns:
- OAuth2TokenValidationResult the success or failure detail of the validation
-
setClockSkew
Sets the clock skew. The default is 30 seconds.- Parameters:
clockSkew- the clock skew
-
setClock
Sets theClockused inInstant.now(Clock).- Parameters:
clock- the clock
-