Skip to content
Workforce IdentityMarkdown

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). 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: for a signed assertion, the client can make and keep a key pair.
SecretSigned assertion (private_key_jwt)
The client holdsA shared secretA private key
The realm holdsThe secret’s hashThe public key only
A leak from the realm gives an attackerNothing usableNothing usable
A leak from the client gives an attackerThe secret, until you change itThe key, until you replace it
A captured request gives an attackerThe secretNothing: each assertion works once, for five minutes
Rotating itChange clientSecret, then the clientPublish a new key beside the old one, then drop the old
Required for—Agents, and clients held to FAPI 2.0
  1. The client makes a key pair and gives you the public key.

  2. 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 gives jwksUri (an https address) instead of jwks, never both.

  3. The client’s assertion names its client id as iss and sub, and the realm’s issuer https://foobar.cvyuh.com/oauth2 as aud: a single string, not the token address.

  4. To rotate later, PATCH the client’s jwks with both keys, move the client to the new one, then PATCH with the new key only.

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.

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:

Terminal window
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.

  • 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 a TOKEN_ISSUED record with result FAILED, under the client’s ID, with the reason. Find it in Audit → Authentication in the dashboard.
  • A secret change is a CLIENT_SECRET_ROTATED record, saying until when the old secret works. Each use of the old secret in that time is a CLIENT_SECRET_PREVIOUS_USED record: when they stop, the client has moved, and you can stop waiting.
SymptomCauseFix
invalid_client with the right secretThe client is locked out after wrong secrets, its status is inactive, or it sent the secret by another method than registeredWait out the lockout; check status and tokenEndpointAuthMethod
invalid_client with a signed assertionaud 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 registeredFix the assertion; register the key
The client fails at once after a secret changeNo overlap was setSet clientSecretRotationGraceSecs before the next change
Registering the key is refusedIt has private parts, two keys share a kid, or both jwks and jwksUri are givenSend public keys only, unique kids, one of the two

PATCH the client back to its earlier tokenEndpointAuthMethod with the matching credential, and the realm’s tokenEndpointAuthMethods back to its earlier list.