Skip to content
Workforce IdentityMarkdown

Browser apps

Single-page apps call the realm straight from the browser, and each app's answers are readable only on the sites it lists.

AvailableAPIFetch (CORS), RFC 6454

A single-page app runs in the browser on its own site, so its calls to the realm are cross-origin. A browser lets the page read the realm’s answer only if the realm says that site may. The realm says so per app: each client lists the sites its pages run on, in webOrigins, and by default that is the sites of its return addresses. One app’s page can never read the answers to another app’s requests.

Use it for any app that calls the realm from a browser page. Such an app is a public client: it uses the browser sign-in with PKCE and holds no secret, and its refresh tokens always rotate.

  • Who can do it: a realm administrator (a group holding RealmOwner); RealmViewer can read a client’s sites 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 public client (tokenEndpointAuthMethod none) with its return addresses.
EndpointWhich sites may read the answer
Token, revocation, pushed authorization, userinfoThe sites the client the request was made as lists in its webOrigins
Discovery document, signing keys, status listsAny site, because they are public
Introspection, device authorization, backchannel authentication, first-party sign-in, registrationNone. They are for servers and native apps

Before a page at https://app.example.com posts to the token endpoint with a DPoP proof, the browser sends a preflight:

Terminal window
curl -X OPTIONS https://foobar.cvyuh.com/oauth2/token \
-H "Origin: https://app.example.com" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: content-type, dpop"

If an active client of the realm lists that site, the realm answers:

HTTP/1.1 204 No Content
Vary: origin
Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Headers: authorization, content-type, dpop
Access-Control-Max-Age: 600

The preflight carries no client, so the realm answers it for any site an active client of the realm lists. The request itself is answered only for the client it was made as: the client that authenticated at the token, revocation and pushed-authorization endpoints, and the access token’s client at userinfo. Its answer carries Access-Control-Allow-Origin again, only if that client lists the site, and Access-Control-Expose-Headers: dpop-nonce, www-authenticate.

A site the realm doesn’t allow gets the same answers with no Access-Control-* headers, so the browser keeps the answer from the page. The public documents answer any site with Access-Control-Allow-Origin: *.

Set webOrigins on the client (https://foobar.cvyuh.com/api/v0/am/objects/v1/oauth2Client; see Call the API):

FieldDefaultMeaning
webOrigins["+"]The sites this client’s pages call from; + for the sites of its redirectUris

A page served from a site that isn’t one of its return addresses, a sign-in on foobar.cvyuh.com for an app on app.example.com for example, needs that site in webOrigins.

Setting or limitDefaultRange
webOrigins["+"], the sites of the client’s redirectUrisexact sites, or +; never * or null
Plain http sitesrefusedallowed only for localhost, 127.0.0.1 and [::1]
A preflight’s answer kept by the browserten minutesfixed
SymptomCauseFix
The browser reports a CORS error on the token requestThe page’s site isn’t in the client’s webOrigins, nor the site of one of its return addressesAdd the exact site, such as https://app.example.com, to webOrigins
A CORS error even with the site listedThe request named no client or an unknown one, so no site is told anythingSend the right client_id; check the request in the network panel
Saving the client is refusedA site with a path, a trailing slash, *, null, or plain http on a public hostWrite the site exactly as the browser sends it in Origin

There’s no record of a browser’s cross-origin check itself. The token requests the page makes are TOKEN_ISSUED records, and a change to webOrigins is a change to the client in Audit → Config.

  • webOrigins holds sites, or +. A site is written exactly as a browser sends it: https://app.example.com, lowercase, with no path and no default port. Plain http is accepted only for localhost, 127.0.0.1 and [::1]. * and null are refused when the client is saved.
  • + means “the sites of my return addresses”. It is the default, so a client that sets nothing is allowed exactly where it receives its sign-in codes. List sites beside + to add more, or leave + out to allow only the sites you list.
  • When no client authenticated, a malformed request or an unknown client, no site is told anything, so the page sees a browser CORS error rather than the realm’s error.
  • A site not allowed is told nothing. The realm never answers with an error for the site alone.
  • No answer ever carries cookies or other credentials.
  • Headers and methods: the page may send Authorization, Content-Type and DPoP, with GET or POST, and may read DPoP-Nonce and WWW-Authenticate, which a browser app using DPoP needs. A browser may keep a preflight’s answer for ten minutes.