# Hold a client to FAPI 2.0

> Hold a client to the FAPI 2.0 security profile with one setting, for banking, health and other high-value data.

Clients that handle money, health records or regulated data, and ecosystems that require FAPI 2.0, need every one of
its rules, not most of them. One setting holds a client to the whole profile: the realm refuses a registration that
can't meet it, and enforces it on every request. Users see nothing different from any sign-in.

| Rule | What it means for the client |
|---|---|
| Pushed requests only | Every sign-in request is first sent to `/oauth2/par` |
| Bound tokens only | Every token request carries a DPoP proof |
| `private_key_jwt` only | No secret, and never a public client |
| ES256 or PS256 | Never RS256: for assertions, request objects, ID tokens, userinfo and introspection answers |
| One minute | Clock tolerance, and how long a code lives |

**Before you start:**

- **Who can do it:** a realm administrator, in a group that holds `RealmOwner`
  ([Delegated administration](/platform/realms/delegated-administration/)). `RealmViewer` can read the settings but
  not change them.
- **Where:** today this is done through the API; [Call the API](/develop/api/) shows how to get `$CVYUH_SESSION`.
- **First:** have the client's public key, its redirect address, and the API it calls.

## Register the client

<Steps>

1. Register it under the profile:

   ```sh
   curl 'https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client?id=payments-app' \
     -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
     -H "Content-Type: application/json" \
     -d '{ "status": "active",
       "clientName": "Payments",
       "securityProfile": "fapi2",
       "tokenEndpointAuthMethod": "private_key_jwt",
       "tokenEndpointAuthSigningAlg": "ES256",
       "jwks": { "keys": [
         { "kty": "EC", "crv": "P-256", "kid": "pay-1", "x": "…", "y": "…" }
       ] },
       "grantTypes": ["authorization_code", "refresh_token"],
       "redirectUris": ["https://pay.example.com/callback"],
       "scopes": ["openid", "payments:initiate"],
       "defaultScopes": ["openid"],
       "allowedResources": ["https://pay.example.com/api"],
       "defaultAudience": "https://pay.example.com/api" }'
   ```

2. You need not set `requirePushedAuthorizationRequests` or `dpopBoundAccessTokens`: the profile forces both on.

</Steps>

A secret, `none`, attestation (`attest_jwt_client_auth`), `refreshTokenRotation: rotate`, or `RS256` in any
signing-algorithm field is refused when you write the client.

## Check it worked

- A sign-in request that isn't pushed is refused before anything in it is read.
- A token request without a proof is refused.
- The client's ID tokens are signed ES256 unless it asks for PS256.
- Each token's `TOKEN_ISSUED` record names the key it is bound to, in `bound`.

## Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| Registering the client is refused | It names a secret, `none`, attestation, `rotate`, or `RS256` somewhere | Remove the value the refusal names |
| Sign-ins fail at `/oauth2/authorize` | The app sends its request in the address bar | Push it to `/oauth2/par` first |
| Token requests fail after a minute | The code lives a minute under the profile | Redeem the code at once |
| Assertions are refused now and then | A clock more than a minute off | Keep the client's clock in sync |

## Undo it

`PATCH` the client with `{ "securityProfile": null }`. The client keeps the settings you gave it, and is held only
to them.

## Related

- [Security profiles](../../../applications/client-security/security-profiles/): every rule the profile holds.
- [Pushed authorization requests](../../../applications/client-security/pushed-authorization-requests/): the push every
  sign-in starts with.
- [Bind tokens to a key](../bind-tokens-to-a-key/): what the client does for each proof.
- [Rotate signing keys](../../../../platform/guides/rotate-signing-keys/): the realm's keys that sign its ID tokens.
