Skip to content
Workforce IdentityMarkdown

Bind tokens to a key

Make a client's tokens useless to anyone who copies them, by binding each token to a key only the client holds.

APIRFC 9449

A stolen bearer token works for whoever holds it until it expires. A token bound with DPoP works only beside a fresh proof signed by the client’s private key, which never leaves the client, so a token copied from a log, a proxy or a browser extension can’t be used. For public apps, the refresh token is bound too. This guide is for browser and mobile apps, whose tokens are the easiest to steal, and any client whose APIs check proofs.

Before you start:

  • Who can do it: a realm administrator, in a group that holds RealmOwner (Delegated administration). RealmViewer can read the settings but not change them.
  • Where: today this is done through the API; Call the API shows how to get $CVYUH_SESSION.
  • First: have the client’s ID, and a client library that makes DPoP proofs.
  1. Require bound tokens for the client:

    Terminal window
    curl -X PATCH 'https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client/<client-id>' \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "dpopBoundAccessTokens": true }'

    Without this, a client that sends a proof still gets a bound token; with it, sending one is compulsory and the client can never fall back to a bearer token. An agent’s client needs no change: it’s held to FAPI 2.0 by default, which binds its tokens.

  2. Leave the realm’s nonces on (oauth2Settings.dpopNonceRequired) unless a client can’t handle the retry. To turn them off: PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings with { "dpopNonceRequired": false }.

  1. It makes a key pair. In a browser, a non-exportable key in the browser’s key store.

  2. With each token request, it sends a DPoP header: a small JWT signed by its key, naming the request’s method and address.

  3. The first request is answered use_dpop_nonce with a DPoP-Nonce header. It signs a new proof including the nonce and sends again. Every answer after that carries the next nonce.

  4. Its tokens come back with token_type: DPoP, each naming the key.

  5. It calls APIs with Authorization: DPoP <token> and a fresh proof naming the token. Each proof works once.

  • At the realm’s own APIs, such as userinfo, the bound token sent as a plain bearer token is refused.
  • Introspection shows the key the token is bound to, in cnf.jkt, for an API that checks proofs itself.
  • At the gateway, a bound token without a matching proof is refused invalid_dpop_proof.

Each bound token’s TOKEN_ISSUED record names the key it is bound to, in bound. Find it in Audit → Authentication in the dashboard.

SymptomCauseFix
Every first token request is refused use_dpop_nonceExpected: the realm hands out a nonceRetry with a new proof carrying the DPoP-Nonce it sent
invalid_dpop_proofThe proof names another method or address, was used before, is too old, or the clock is offSign a fresh proof for each request, with the exact method and address
invalid_dpop_proof, “this client is issued DPoP-bound tokens only”The client sent no proof, and bound tokens are now requiredHave the client send a DPoP header
A bound token is refused at an API as a bearer tokenExpected: it must be sent as DPoP with a proofSend Authorization: DPoP <token> and a proof naming it

PATCH the client with { "dpopBoundAccessTokens": false }. Tokens already bound stay bound until they expire.