Choose how a client proves itself
Pick between a secret and a signed assertion for a confidential client, set it up, and rotate it without downtime.
APIRFC 7523, RFC 6749
Every confidential client, such as a web app’s server, a back-end service or an agent, proves itself each time it
asks for a token. It can hold a secret the realm keeps a hash of, or a private key whose public half the realm
holds, signing a fresh assertion each time (private_key_jwt). Choose the signed assertion wherever the client can
manage a key: a captured request gives an attacker nothing. This guide is for anyone registering a confidential client.
Before you start:
- Who can do it: a realm administrator, in a group that holds
RealmOwner(Delegated administration).RealmViewercan 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: for a signed assertion, the client can make and keep a key pair.
Choose
Section titled “Choose”| Secret | Signed assertion (private_key_jwt) | |
|---|---|---|
| The client holds | A shared secret | A private key |
| The realm holds | The secret’s hash | The public key only |
| A leak from the realm gives an attacker | Nothing usable | Nothing usable |
| A leak from the client gives an attacker | The secret, until you change it | The key, until you replace it |
| A captured request gives an attacker | The secret | Nothing: each assertion works once, for five minutes |
| Rotating it | Change clientSecret, then the client | Publish a new key beside the old one, then drop the old |
| Required for | — | Agents, and clients held to FAPI 2.0 |
Register with a signed assertion
Section titled “Register with a signed assertion”-
The client makes a key pair and gives you the public key.
-
Register it:
Terminal window curl 'https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client?id=<client-id>' \-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \-H "Content-Type: application/json" \-d '{ "status": "active","tokenEndpointAuthMethod": "private_key_jwt","tokenEndpointAuthSigningAlg": "ES256","jwks": { "keys": [{ "kty": "EC", "crv": "P-256", "kid": "rb-key-1", "x": "…", "y": "…" }] },"grantTypes": ["client_credentials"],"scopes": ["reports:read"],"allowedResources": ["https://reports.example.com/api"],"defaultAudience": "https://reports.example.com/api" }'Public keys only: a key with private parts is refused, and no two keys may share a
kid. A client that publishes its own keys givesjwksUri(anhttpsaddress) instead ofjwks, never both. -
The client’s assertion names its client id as
issandsub, and the realm’s issuerhttps://foobar.cvyuh.com/oauth2asaud: a single string, not the token address. -
To rotate later,
PATCHthe client’sjwkswith both keys, move the client to the new one, thenPATCHwith the new key only.
Or register with a secret
Section titled “Or register with a secret”Register as in Let one service call another. To change the secret,
PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client/<client-id> with { "clientSecret": "<new secret>" }.
By default the old secret stops at once. To overlap, set the realm’s clientSecretRotationGraceSecs: the replaced
secret keeps working for that many seconds, or until its own clientSecretExpiresAt if that’s sooner.
Rule a method out for the whole realm
Section titled “Rule a method out for the whole realm”The realm accepts all four methods by default. To accept only some, for example no secrets, or no public clients, send the methods it should keep accepting. The list replaces the realm’s whole list:
curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings \ -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \ -H "Content-Type: application/json" \ -d '{ "tokenEndpointAuthMethods": ["private_key_jwt"] }'A client registered for a method the realm no longer accepts is refused at the token endpoint.
Check it worked
Section titled “Check it worked”- The client gets a token with the method you registered. Exactly one method is accepted per client.
- Any refusal is
invalid_client, with no hint why. It is on the trail as aTOKEN_ISSUEDrecord with resultFAILED, under the client’s ID, with the reason. Find it in Audit → Authentication in the dashboard. - A secret change is a
CLIENT_SECRET_ROTATEDrecord, saying until when the old secret works. Each use of the old secret in that time is aCLIENT_SECRET_PREVIOUS_USEDrecord: when they stop, the client has moved, and you can stop waiting.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
invalid_client with the right secret | The client is locked out after wrong secrets, its status is inactive, or it sent the secret by another method than registered | Wait out the lockout; check status and tokenEndpointAuthMethod |
invalid_client with a signed assertion | aud isn’t the issuer as a single string, the assertion expires further ahead than clientAssertionMaxLifetimeSecs (five minutes) or is reused, or its kid isn’t registered | Fix the assertion; register the key |
| The client fails at once after a secret change | No overlap was set | Set clientSecretRotationGraceSecs before the next change |
| Registering the key is refused | It has private parts, two keys share a kid, or both jwks and jwksUri are given | Send public keys only, unique kids, one of the two |
Undo it
Section titled “Undo it”PATCH the client back to its earlier tokenEndpointAuthMethod with the matching credential, and the realm’s
tokenEndpointAuthMethods back to its earlier list.
Related
Section titled “Related”- Client authentication: every method in full.
- Hold a client to FAPI 2.0: signed assertions and more, with one setting.