# Realm OAuth settings

> The realm-wide lists and lifetimes every app works within, which grants, scopes and client methods the realm accepts, and how long each token lives, in one place.

Your realm's OAuth settings decide what every app may use: which grants and client methods the realm accepts, which
scopes it offers, which user details it releases, and how long codes and tokens live. An app's own registration can
only narrow these, never widen them. Every new realm starts with safe values, so most realms change only the scopes and,
now and then, a lifetime.

## Before you begin

- **Who can do it:** a realm administrator (a group holding `RealmOwner`); `RealmViewer` can read every setting but
  change none.
- **Where:** today this is done through the API ([Call the API](/develop/api/) shows how to get
  `$CVYUH_SESSION`).
- **First:** nothing. Every realm starts with the defaults below.

## How it works

The settings are one object, `oauth2Settings`, in each realm. A setting you never set takes its default, and a read
shows every setting with its default filled in.

```sh
curl https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings \
  -H "Cookie: x-cvyuh-token=$CVYUH_SESSION"
```

Change only the fields you send ([Call the API](../../../develop/api/) shows how to get a session):

```sh
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 '{ "accessTokenLifetimeSecs": 600 }'
```

A list you send replaces the realm's whole list, so read it first and send back every value you want to keep. A map,
such as `scopeClaims`, is merged key by key.

## Limits and defaults

Every setting's default is in brackets in the [Reference](#reference). The ranges:

| Setting | Range |
|---|---|
| `accessTokenLifetimeSecs` | 1 to 86,400 |
| `idTokenLifetimeSecs` | 1 to 3,600 |
| `refreshTokenLifetimeSecs`, `refreshTokenIdleSecs` | 1 (0 for idle: no idle limit) to 31,536,000 |
| `refreshTokenRetrySecs` | 0 to 60 |
| `authorizationCodeLifetimeSecs` | 1 to 600 |
| `parLifetimeSecs` | 10 to 600 |
| `consentChallengeLifetimeSecs` | 60 to 3,600 |
| `logoutChallengeLifetimeSecs` | 10 to 3,600 |
| `logoutTokenLifetimeSecs` | 1 to 300 |
| `deviceCodeLifetimeSecs` | 10 to 1,800 |
| `devicePollIntervalSecs`, `cibaPollIntervalSecs` | 1 to 60 |
| `deviceMissesPerSession`, `deviceMissesPerAddress`, `deviceMissesPerRealm` | 1 to 10,000 |
| `cibaLifetimeSecs` | 60 to 1,800 |
| `clientAssertionMaxLifetimeSecs`, `bootstrapAssertionLifetimeSecs` | 1 to 3,600 |
| `clockSkewSecs` | 0 to 300 |
| `dpopProofMaxAgeSecs` | 1 to 300 |
| `dpopNonceLifetimeSecs` | 10 to 3,600 |
| `maxClients` | 1,000; raised by support |

A value outside its range is refused when you save it, naming the setting.

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| A scope, grant or method disappeared after a change | A list you sent replaced the realm's whole list | Read the settings, and send back every value you want to keep |
| A client's grant or scope is refused though the client lists it | The realm's list doesn't hold it | Add it to the realm's list too |
| Saving `maxClients` or `clientIdMetadataDocuments` is refused | Those are set by support | Ask support |

## Audit record

Every change to `oauth2Settings` is a `PATCHED` or `UPDATED` record with the values before and after. See it in
**Audit → Config**, or in [Change history](/audit-reports/audit-trail/change-history/).

## Good to know

- **A client works within the realm.** A grant, scope or client method a client names takes effect only where the
  realm's list holds it too.
- **Short tokens are the default on purpose.** An access token lives five minutes, which bounds how long a revoked user
  or agent keeps access. Apps stay signed in with refresh tokens instead.
- **A realm holds up to 1,000 clients.** Raising it is a support matter, not a setting.
- **Accepting apps identified by a URL is turned on by support.** Once it is, the `cimd…` settings are yours.

## Reference

Values in brackets are the defaults; times are in seconds.

### What the realm accepts

| Setting | What it does | More |
|---|---|---|
| `grantTypes` (`client_credentials`, `authorization_code`, `refresh_token`) | The grants the token endpoint accepts | [Register an app](../register-an-app/) |
| `tokenEndpointAuthMethods` (`none`, `client_secret_basic`, `client_secret_post`, `private_key_jwt`) | How clients may prove who they are | [Client authentication](../client-security/client-authentication/) |
| `tokenEndpointAuthSigningAlgs` (`ES256`, `RS256`) | The algorithms a client's signed assertion may use | [Client authentication](../client-security/client-authentication/) |
| `clientAssertionMaxLifetimeSecs` (`300`), `clockSkewSecs` (`60`) | How far ahead an assertion may expire, and the leeway on its times | [Client authentication](../client-security/client-authentication/) |
| `clientSecretRotationGraceSecs` (`0`) | How long a replaced secret keeps working after a rotation | [Client authentication](../client-security/client-authentication/) |
| `scopes` | The realm's scopes; a client's must come from them | [Register an app](../register-an-app/) |
| `authorizationDetailsTypes` (none) | The structured permission types the realm accepts, each with its schema | [Rich authorization requests](../../authorization/rich-authorization-requests/) |
| `requireResource` (`false`) | Refuse a token request that names no API | [Resource indicators](../tokens/resource-indicators/) |
| `requirePushedAuthorizationRequests` (`false`) | Take every sign-in request only as a pushed one | [Pushed authorization requests](../client-security/pushed-authorization-requests/) |
| `maxClients` (`1000`) | The most clients the realm holds; raised by support | [Register an app](../register-an-app/) |

### Sign-in and consent

| Setting | What it does | More |
|---|---|---|
| `authorizationCodeLifetimeSecs` (`60`) | How long a sign-in's code may be redeemed, once | [Authorization code with PKCE](../single-sign-on/authorization-code/) |
| `consentChallengeLifetimeSecs` (`600`) | How long a browser has to sign in and answer consent | [Consent](../../../customer-identity/consent/) |
| `rememberConsent` (`true`) | A user who allowed an app isn't asked again for the same scopes | [Consent](../../../customer-identity/consent/) |
| `consentSkipAllowed` (`false`) | Let an app marked `consentImplied` skip the consent page | [Consent](../../../customer-identity/consent/) |
| `firstPartyAppsAllowed` (`false`) | Let the realm's own apps sign users in with their own screens | [First-party app sign-in](../single-sign-on/first-party-apps/) |
| `parLifetimeSecs` (`60`) | How long a pushed request may be used, once | [Pushed authorization requests](../client-security/pushed-authorization-requests/) |
| `deviceCodeLifetimeSecs` (`600`), `devicePollIntervalSecs` (`5`) | How long a device's code lasts, and how often it may ask | [Device authorization](../single-sign-on/device-authorization/) |
| `deviceMissesPerSession` (`5`), `deviceMissesPerAddress` (`10`) | How many wrong device codes one session or one address may send in 15 minutes | [Device authorization](../single-sign-on/device-authorization/) |
| `deviceMissesPerRealm` (`100`) | The level at which the realm records an alert | [Device authorization](../single-sign-on/device-authorization/) |
| `acrValues`, `amrValues` (none) | Which chain earns each `acr`, and which `amr` each sign-in method adds | [Step-up and re-authentication](../single-sign-on/step-up/) |
| `logoutChallengeLifetimeSecs` (`600`), `logoutTokenLifetimeSecs` (`120`) | How long a user has to confirm a sign-out, and how long a logout notice is valid | [Logout](../single-sign-on/logout/) |

### Tokens

| Setting | What it does | More |
|---|---|---|
| `accessTokenLifetimeSecs` (`300`) | How long an access token lives | [Access tokens](../tokens/access-tokens/) |
| `idTokenLifetimeSecs` (`300`) | How long an ID token is valid | [OpenID Connect sign-in](../single-sign-on/openid-connect/) |
| `refreshTokenGrants` (`authorization_code`, device code) | The grants whose tokens come with a refresh token | [Refresh tokens](../single-sign-on/refresh-tokens/) |
| `refreshTokenLifetimeSecs` (`86400`), `refreshTokenIdleSecs` (`3600`) | How long a refresh token lives from sign-in, and unused | [Refresh tokens](../single-sign-on/refresh-tokens/) |
| `refreshTokenRetrySecs` (`0`) | How long a spent refresh token may be presented again, for a client retrying a lost answer | [Refresh tokens](../single-sign-on/refresh-tokens/) |
| `statusListedResources` (none) | APIs that check tokens offline: their tokens carry a status list entry | [Status lists](../revoke-access/status-lists/) |
| `dpopSigningAlgs` (`ES256`, `RS256`), `dpopProofMaxAgeSecs` (`60`) | What a DPoP proof may be signed with, and how old it may be | [DPoP](../client-security/dpop/) |
| `dpopNonceRequired` (`true`), `dpopNonceLifetimeSecs` (`300`) | Whether a proof must carry the realm's nonce, and how long a nonce lasts | [DPoP](../client-security/dpop/) |
| `mtls` (`false`) | Serve the realm at `mtls.foobar.cvyuh.com`, where clients sign in with a certificate | [Certificate-bound tokens](../client-security/certificate-bound-tokens/) |

### User details

| Setting | What it does | More |
|---|---|---|
| `claims` | The user details the realm ever releases | [OpenID Connect sign-in](../single-sign-on/openid-connect/) |
| `scopeClaims` | The details each scope releases | [Choose which details an app receives](../../guides/sign-in-to-apps/choose-user-details/) |
| `claimAttributes` | The user attribute each detail is read from | [Name users by your own directory's attributes](../../guides/sign-in-to-apps/name-people-by-directory-attributes/) |
| `idTokenScopeClaims` (`false`) | Put the released details in the ID token as well as at userinfo | [OpenID Connect sign-in](../single-sign-on/openid-connect/) |

### Apps that register themselves

| Setting | What it does | More |
|---|---|---|
| `registration` (off) | Whether developers may register apps, and how long and how often a registration token may be used | [Dynamic registration](../registration/dynamic-registration/) |
| `clientIdMetadataDocuments` (`false`) | Accept apps identified by the URL of a document they publish; turned on by support | [Client metadata documents](../registration/client-metadata-documents/) |
| `cimdScopes` (`openid`, `profile`), `cimdResources` (none), `cimdBlocked` (none) | What such apps may be granted, which APIs they may get tokens for, and which are refused | [Client metadata documents](../registration/client-metadata-documents/) |

### Agents and workloads

| Setting | What it does | More |
|---|---|---|
| `bootstrapAssertionLifetimeSecs` (`300`) | How long a one-time bootstrap assertion for an agent's client lasts | [Client authentication](../client-security/client-authentication/) |
| `spiffeTrustDomains` (none) | The SPIFFE trust domains whose workload credentials the realm trusts | [Client authentication](../client-security/client-authentication/) |
| `clientAttesters` (none) | The attesters whose client attestations the realm trusts | [Client attestation](../client-security/attestation/) |
| `cibaLifetimeSecs` (`300`), `cibaPollIntervalSecs` (`5`) | How long an agent's request for its owner's approval waits, and how often it may ask | [Have an agent ask its owner](../../guides/agents/agent-asks-its-owner/) |
| `ssfEnabled` (`false`) | Send security events to the receivers that registered a stream | [Send signals](../../signals/shared-signals/) |

## Related

- [Register an app](../register-an-app/): what each app sets within these.
- [Set how long tokens live](../../guides/services/set-token-lifetimes/): choose lifetimes for your apps.
- [Discovery document](../registration/discovery/): what apps read of these settings.
