Expand description
DPoP (RFC 9449): sender-constraining access and refresh tokens with a key the client holds.
A proof is a short JWT signed with that key and naming the request it is for (htm, htu, a fresh jti, iat,
and ath when an access token goes with it). The service (services/dpop.rs) accepts ES256, PS256 and RS256, so
those are the only algorithms here, and it binds the issued tokens to the key’s RFC 7638 thumbprint (cnf.jkt): a
bound token is useless without a proof from the same key.
What this module never does: put the private key in anything it returns (a DpopKey prints the algorithm and the
thumbprint only), reuse a jti, or retry more than once. The proof goes in the DPoP header, never in a URL or a
body. The htu is computed with the same url crate function the service uses, so the two agree on every path.
Nonces (RFC 9449 section 8). The service does not hand out nonces yet; when it does (or any other server does),
DpopSession handles it: a use_dpop_nonce challenge with a DPoP-Nonce header is retried once with a new proof
carrying the nonce, and the latest nonce is remembered per origin. Nothing is retried for any other error, for a nonce
that is not a valid nonce, or a second time.
Structs§
- DpopKey
- A DPoP key pair. The private half is held out of reach: it signs proofs and cannot be read back.
- Dpop
Proof Params - What goes into one proof.
- Dpop
Request - What a request carries besides its DPoP proof.
- Dpop
Session - Sends requests with DPoP proofs: a fresh proof per request, the remembered nonce, one retry on a nonce challenge.
- Http
Reply - A fully read HTTP answer. Header names are lower-case.
Functions§
- assert_
dpop_ supported - The service must advertise the key’s algorithm (
dpop_signing_alg_values_supported) before a client sends a proof. - create_
dpop_ proof - A DPoP proof JWT for one request.
- dpop_
access_ token_ hash ath: base64url SHA-256 of an access token (RFC 9449 section 4.2).- dpop_
htu htu: the request URL without query or fragment, scheme and host lower-cased, default port dropped. Computed with the service’s own normalisation.- dpop_
thumbprint - RFC 7638 thumbprint (base64url SHA-256) of a public JWK given as JSON (EC P-256 or RSA).
- generate_
dpop_ key - A new key pair: ES256 (P-256), or PS256 / RS256 (RSA 2048; slow to generate, so prefer ES256).
- import_
dpop_ key - Use a key you already hold: a private JWK or a PKCS#8 PEM.