Class DPoPProofVerifier
java.lang.Object
com.codename1.backend.security.oauth2.jwt.DPoPProofVerifier
Checks a DPoP proof (RFC 9449): a JWT the client signs, per request, with the private half of the key its tokens are bound to. Both the authorization server's token endpoint and a resource server use it.
A proof is accepted when its header says typ dpop+jwt, names an
asymmetric algorithm and carries a public jwk the signature verifies
with; its htm and htu are the request's method and URI; its iat is
within a minute of now; its jti has not been seen before; and, at a
resource server, its ath is the hash of the access token sent with it.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA verified proof, not yet recorded as used.static interfaceRemembers which proofs were used. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionVerifiesproofasverify(String, String, String, String)does but records nothing: the caller passes the answer tofirstUse(DPoPProofVerifier.Proof)once the request it came with has otherwise succeeded.booleanfirstUse(DPoPProofVerifier.Proof proof) Records a proofcheck(String, String, String, String)accepted.Verifiesproofand answers the thumbprint of the key it was signed with (itsjkt).
-
Constructor Details
-
DPoPProofVerifier
- Parameters:
replay- where used proofs are remembered; null for a bounded in-memory cache, which is right for one process and wrong for several behind a load balancer
-
-
Method Details
-
verify
Verifiesproofand answers the thumbprint of the key it was signed with (itsjkt).- Parameters:
method- the request's methoduri- the request's URI, without its query or fragmentaccessToken- the token sent with the proof, whichathmust hash; null at the token endpoint- Throws:
BadJwtException- when the proof is not acceptable
-
check
Verifiesproofasverify(String, String, String, String)does but records nothing: the caller passes the answer tofirstUse(DPoPProofVerifier.Proof)once the request it came with has otherwise succeeded. An endpoint that anyone can reach with a proof of their own key (a token request from a public client) would otherwise let a flood of junk requests fill the replay cache, which refuses every proof once it is full of live ones.- Throws:
BadJwtException- when the proof is not acceptable
-
firstUse
Records a proofcheck(String, String, String, String)accepted.- Returns:
- false when the proof was used before
-