Skip to content
PlatformMarkdown

Realm base URL

Give your realm one issuer and one set of addresses, whichever host name an app arrives on.

AvailableAPIRFC 8414

A realm can answer on several host names: one per site, such as foobar.cvyuh.com beside foobar-eu.cvyuh.com. By default each host name is its own issuer, the name the realm signs its tokens under, so tokens from foobar-eu.cvyuh.com name https://foobar-eu.cvyuh.com/oauth2. Set a base URL and every address the realm hands out is built on it instead: apps see one issuer, whichever host they reach.

You’d want it when apps or APIs check the issuer strictly and may arrive by more than one host name, or when a sign-in may start on one host name and finish on another. If your realm has one host name, you don’t need it.

  • Privilege: MODIFY on the realm’s baseUrl setting, which RealmOwner gives.
  • Where: the API.
  • First: the host name you’ll use must be one of the realm’s host names, and your session is in $CVYUH_SESSION (Call the API).

Without a base URL, the issuer is built from the host name the request came in on, in lower case and without any port. A sign-in code issued under one host name is refused under another (invalid_grant), since each is its own issuer; the code isn’t spent, so the app can still redeem it where it got it.

With a base URL, the issuer, the endpoints in the discovery documents and the return links all start with it, exactly as stored, so the issuer never varies by a character. It is also how a port other than 443 appears in the realm’s addresses: without a base URL, the port is left out.

Write the realm’s baseUrl setting, whose id is baseUrl:

Terminal window
curl "https://foobar.cvyuh.com/api/v0/am/objects/v1/baseUrl?id=baseUrl" \
-H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
-H "Content-Type: application/json" \
-d '{ "url": "https://foobar.cvyuh.com" }'

Change it later with a PATCH to https://foobar.cvyuh.com/api/v0/am/objects/v1/baseUrl/baseUrl, and check the result in https://foobar.cvyuh.com/oauth2/.well-known/openid-configuration: its issuer is the base URL plus /oauth2.

AnswerCauseWhat to do
400Not an https origin: a path, query, fragment, trailing slash, upper case, or httpSend only https:// and the host, with a port if it isn’t 443
400, “url names the default https port; leave it out so the issuer is the same either way”The URL ends in :443Leave the port out
409, SINGLETON_EXISTSYou created it a second timePATCH the existing one

What apps see when it changes: every token from then on names the new issuer. An app or API that checks the issuer refuses tokens until it’s told the new one, and refresh tokens issued under the old issuer are refused.

WhatDefaultCan it change
Base URLNone: each host name is its own issuerSet one
Formhttps:// and a lower-case host, optional port other than 443No
  • Apps refuse tokens straight after the change. They still expect the old issuer. Update their configured issuer, or let their library rediscover it from the discovery document.
  • Requests to the base URL reach no realm. Its host isn’t one of the realm’s host names. Add it to the host names.
  • Users are asked to sign in again on another host name. The base URL doesn’t move the sign-in cookie: see Good to know.

Each change to the base URL is a change record naming who made it, before and after. Read it as the setting’s change history: GET https://foobar.cvyuh.com/api/v0/am/objects/v1/baseUrl/baseUrl/history.

  • Changing it changes the issuer every app sees. Tell the apps and APIs that check the issuer before you change it.
  • It doesn’t move the sign-in cookie. The cookie is set for the host the user signed in on, or for the cookie domains your realm is set up with. It reaches another of the realm’s host names only when both sit under one of those domains.