Validating proofs at the server
A proof protects nothing until someone checks it. The photo service's authorization serverIn OAuth, the service that handles a person's sign-in and approval and decides which tokens to issue to a client. It may belong to the same company as the API, but its job is separate. decides whether to bind new tokens to the key in a proof, and the photo APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests. decides whether the proof in front of it comes from the key its tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret. was bound to. Both start from the same checks on the proof itself, then add their own.
Checking a proof
Creating a DPoP proof read the proofs the printer's phone app sends while it works with Ava's photos. For every request that carries a DPoP header, the server that receives it confirms that:
- There is exactly one
DPoPheader, and it holds a single, well-formed JWTA JSON Web Token: a compact token made of Base64url-encoded parts that carries claims and is usually signed. Anyone holding it can decode and read the claims, so the signature shows who issued it but hides nothing.. - The required claims are present:
jti,htm,htuandiat. - The
typheader isdpop+jwt. - The
algheader names an asymmetric signatureA value made with a private key that lets anyone holding the matching public key check that a message came from the key's holder and has not been changed. It proves origin and integrity; it does not hide the message. algorithm this server accepts.noneand shared-key algorithms are always refused. - The signature verifies with the public keyThe half of a key pair that can be shared freely. It checks signatures made with the matching private key and can encrypt data that only that private key can decrypt. in the
jwkheader, and that key contains no private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner. members. htmmatches the method of this request, andhtumatches the address it was sent to, ignoring any query string and fragment.- The proof was created recently enough, judged from
iat. A server may also require a value of its own in the proof, which Nonces and replay handling describes.
The order does not matter, and any failure rejects the request.
Step five may look alarming. Token formats and validation warned never to verify an access tokenA token that a client presents to an API to use access it has been granted, usually limited in what it allows and how long it lasts. It authorizes API calls; it does not tell the client who signed in. with a key embedded in the token itself, because an attacker can embed their own. A DPoPAn OAuth extension, RFC 9449, that binds tokens to a key pair the client holds. The client signs a fresh proof for each request, so a stolen token is useless without the private key. proof is verified with exactly that kind of key, and it is safe here because the signature is not what makes the proof trustworthy. It only shows that the sender holds the private key matching the public key in the header. Trust comes from a later comparison: whether that public key is the one the authorizationDeciding whether a requested action is permitted, such as whether a signed-in account may delete a particular photo. Authentication says which account is asking; authorization decides what it can do. server bound to the token. Someone who copied Ava's token and signed a proof with their own key passes step five perfectly, then fails that comparison.
Proof from Ava's phone key
- typ is dpop+jwt
- Signature verifies with the jwk header
- htm and htu match this request
- iat is recent
- ath is the hash of this token
- Key thumbprint equals cnf.jkt
Accepted
Proof from a key of their own
- typ is dpop+jwt
- Signature verifies with the jwk header
- htm and htu match this request
- iat is recent
- ath is the hash of this token
- Key thumbprint equals cnf.jkt
401 invalid_dpop_proof
It only shows that the sender holds the private key matching the public key in the header.
Step six has a practical trap. The htu claim holds the address the client used, such as https://api.photos.example/albums/42/photos. A server behind a load balancer, a front server that spreads requests across several machines, often sees an internal host name or a different scheme. It has to compare against the public address, after normalizing details such as letter case in the host name and default ports. Comparing against the internal address fails every honest proof.
At the token endpoint
When a proof passes, the authorization server computes the thumbprint of its public key and binds the tokens it issues to that thumbprint, as Binding a token to a key showed. When it fails, the token endpointThe authorization server address where clients exchange an authorization code, refresh token, or other grant for tokens, in a direct request rather than through a browser redirect. answers with an ordinary OAuthA framework that lets a person give an application limited access to their resources at another service, using tokens instead of sharing their password. OAuth is about access; OpenID Connect adds sign-in. error response. All domains, codes, and tokens in these examples are fictional:
HTTP/1.1 400 Bad Request
Content-Type: application/json
Cache-Control: no-store
{
"error": "invalid_dpop_proof"
}Refreshing works the same way. The phone app is a public client, so its refresh token was bound to its key when it was issued, and every refresh must carry a proof from that same key. The proof is shortened here for display:
POST /token HTTP/1.1
Host: auth.photos.example
Content-Type: application/x-www-form-urlencoded
DPoP: eyJ0eXAiOiJkcG9wK2p3dCIsImFsZyI6IkVTMjU2IiwiandrIjp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYi...
grant_type=refresh_token
&refresh_token=demo-app-refresh-token-1
&client_id=photo-printer-appIts htm is POST and its htu is the token endpoint, exactly as in the code exchange. The server checks the proof, then checks that its key's thumbprint equals the one recorded for this refresh token. A refresh token copied out of the phone's storage cannot be redeemed without the key, however long it remains valid.
Confidential clients are treated differently. The printer's web server authenticates every time it uses a refresh token, so its refresh tokens are already tied to it, and the authorization server does not also bind them to a DPoP key. That lets the server change its DPoP key without losing the grants it holds; each new access token is bound to whichever key the refresh proof carried.
Two further features tighten the binding. Client metadata, the settings recorded when a client is registered, as Redirect URIs and client metadata described, can include dpop_bound_access_tokens. A client registered with that value set to true has declared that it always uses DPoP, so the server must reject any token request from it that has no proof. And the optional dpop_jkt authorization request parameter carries the key's thumbprint at the start of the flow, so the authorization code itself is bound to the key. A code stolen on its way back to the printer is then refused unless the token request carries a proof from that key.
At the photo API
When the photo API sees Authorization: DPoP demo-app-access-token-1, the scheme tells it to expect a bound token and a proof. It validates the token exactly as it would any access token, checks the proof as listed above, then makes the two comparisons only an API can make:
athin the proof equals the Base64url SHA-256 hash of the token in theAuthorizationheader.- The thumbprint of the proof's public key equals the token's
cnf.jkt.
For a JWT access token, cnf.jkt is in the token's claims. For an opaque token, it comes from the introspection response. The authorization server does not check the proof during introspection: the API sends only the token, receives the thumbprint, and makes the comparison itself.
A failure gets a challenge in the WWW-Authenticate header, using the error codes Using access tokens described, with the DPoP scheme and an algs parameter listing the algorithms the API accepts for proofs:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: DPoP error="invalid_dpop_proof", algs="ES256"The same answer covers a proof from a key other than the token's and a proof that is malformed or wrongly signed. Some APIs report the key mismatch as error="invalid_token" instead, treating it as a fault in the token's binding; the DPoP specification allows either.
One more case needs a deliberate rule. Suppose someone copies Ava's bound token and sends it as Authorization: Bearer demo-app-access-token-1, with no proof at all. An API that supports both schemes must notice that the token is bound, from its cnf claim or the introspection result, and reject it. Accepting it would turn the binding into an option the copier can decline.
That rule exists only where an API knows about DPoP. An older API that understands only bearer tokens ignores the unfamiliar cnf claim and accepts the copied token. A binding protects a token exactly where it is checked, so every API that receives DPoP-bound tokens needs these comparisons before the protection is real.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Watch the tenant check DPoP proofs at the token endpoint and the photo APISend proofs that fail the lesson's checklist, require DPoP for lab-printer, bind a code with dpop_jkt, change a confidential client's key on refresh, and make the photo API refuse bearer tokens.