Skip to content
Workforce IdentityMarkdown

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.

ToolWhat it stops
Pushed requestThe request never enters the browser; the browser carries only a one-time reference
Signed request objectThe request is signed by the app; the realm ignores anything not under the signature
Form postThe 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). 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: the app is registered as a confidential client, and you have its public key.
  1. 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.

  2. 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": "…" }
    ] }
    }'

    jwks holds the app’s public keys only; a private key is refused. Instead of jwks, the app may publish its keys at an https address given as jwksUri. Give one or the other, not both.

  3. 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.

  • 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 a request_uri that 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 carry nbf and exp no more than an hour apart.
  • Encrypted: the app may also encrypt the signed request to the realm’s encryption key (the use: enc key in its key set, when the realm holds one), so the browser can’t read it either. Set the client’s requestObjectEncryptionAlg to ECDH-ES, and requestObjectEncryptionEnc if not A128CBC-HS256, the default. The signature is still checked once it is opened.

The realm never fetches a request from an address someone else names.

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.

SymptomCauseFix
The user sees an error page at sign-inThe app sent its request in the address bar, not pushedPush it to /oauth2/par first
The push is refused invalid_clientThe app’s server didn’t authenticate as it does at the token endpointSend its client credentials with the push
The request_uri is refusedIt was used before, or a minute passedPush again for each sign-in
The signed request is refusedWrong key or algorithm, the realm or the app not named, or nbf and exp more than an hour apartSign with the registered key and requestObjectSigningAlg

Set requirePushedAuthorizationRequests back to false on the client, or on the realm.