Make sign-in requests tamper-proof
Stop anyone handling the browser's address bar from reading or changing an app's sign-in request, and keep the code out of browser history.
APIRFC 9126, RFC 9101, OAuth 2.0 Form Post Response Mode
In a plain sign-in, the app’s request (its scopes, the API it wants, its return address) rides in the browser’s address bar. A browser extension, a proxy or a log can read it, and someone can alter it before it reaches the realm. For a confidential app handling sensitive data, such as banking, health or administration, three tools close that gap, and they work together. Users see nothing different.
| Tool | What it stops |
|---|---|
| Pushed request | The request never enters the browser; the browser carries only a one-time reference |
| Signed request object | The request is signed by the app; the realm ignores anything not under the signature |
| Form post | The code comes back as a form post, not in the address bar or browser history |
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: the app is registered as a confidential client, and you have its public key.
Lock the request down
Section titled “Lock the request down”-
Require pushed requests for the app:
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 '{ "requirePushedAuthorizationRequests": true }'To require them for every app in the realm, send the same field to
PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Settings/oauth2Settings. -
Let the app sign its requests:
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 '{"requestObjectSigningAlg": "ES256","jwks": { "keys": [{ "kty": "EC", "crv": "P-256", "kid": "app-key-1", "x": "…", "y": "…" }] }}'jwksholds the app’s public keys only; a private key is refused. Instead ofjwks, the app may publish its keys at anhttpsaddress given asjwksUri. Give one or the other, not both. -
Have the app send
response_mode=form_post. There’s nothing to set: the realm answers with a page that posts the code to the registered return address.
What the app does
Section titled “What the app does”- Pushed: the app’s server posts the request to
https://foobar.cvyuh.com/oauth2/par, authenticating as it does at the token endpoint. It gets arequest_urithat works once, within a minute, and sends the browser to/oauth2/authorize?client_id=…&request_uri=…. A bad request is answered to the server and never shown in the browser. - Signed: the app sends the request as a JWT signed with its registered key, in
request(or inside the push). It must name the app as sender and the realm as receiver, and carrynbfandexpno more than an hour apart. - Encrypted: the app may also encrypt the signed request to the realm’s encryption key (the
use: enckey in its key set, when the realm holds one), so the browser can’t read it either. Set the client’srequestObjectEncryptionAlgtoECDH-ES, andrequestObjectEncryptionEncif notA128CBC-HS256, the default. The signature is still checked once it is opened.
The realm never fetches a request from an address someone else names.
Check it worked
Section titled “Check it worked”Send the app’s browser straight to /oauth2/authorize with its parameters in the address, and no request_uri. The
realm refuses it, since the app must push its requests.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
| The user sees an error page at sign-in | The app sent its request in the address bar, not pushed | Push it to /oauth2/par first |
The push is refused invalid_client | The app’s server didn’t authenticate as it does at the token endpoint | Send its client credentials with the push |
The request_uri is refused | It was used before, or a minute passed | Push again for each sign-in |
| The signed request is refused | Wrong key or algorithm, the realm or the app not named, or nbf and exp more than an hour apart | Sign with the registered key and requestObjectSigningAlg |
Undo it
Section titled “Undo it”Set requirePushedAuthorizationRequests back to false on the client, or on the realm.
Related
Section titled “Related”- Pushed authorization requests: the push, its lifetime and errors.
- Signed request objects: signing and encryption.
- Sign users in to a web app: the sign-in this tightens.