Skip to content
PlatformMarkdown

Sign in at either site

Serve a realm from two sites with a host name at each, so a user signs in once and stays signed in wherever they land.

API

Your realm is served from a site in each of two regions, and you want users to reach the nearer one, or the other if one is lost. With a host name at each site, a user signs in once: whichever site their browser or app reaches next, they are signed in, and signing out at either site ends the session at both.

Before you start: you administer the realm’s parent (creating a realm and changing its host names are done from the parent), you know the host name you want at each site, and your session is in $CVYUH_SESSION (Call the API). It’s done through the API. Which sites serve your realm is agreed with Cvyūh: see Multi-site realms.

  1. Give the realm a host name at each site. Here the realm is engineering, beneath yours, with one host name for the site in Europe and one for the site in the US. Send the realm’s whole list:

    Terminal window
    curl -X PATCH https://foobar.cvyuh.com/api/v0/am/global/realms/v1/<realm id> \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "hostnames": ["foobar-engineering-eu.cvyuh.com", "foobar-engineering-us.cvyuh.com"] }'

    The realm answers 200, naming the host names it claimed and freed. The realm’s id is in the realms list, GET https://foobar.cvyuh.com/api/v0/am/global/realms/v1. A new realm takes the same hostnames when you create it: see Realms and sub-realms.

  2. Decide what apps see as the issuer. By default each host name is its own issuer, so an app that signed in at foobar-engineering-eu.cvyuh.com must refresh there too. If apps should see one issuer whichever site they reach, set a base URL.

Nothing else to set: the realm, its apps, users and sessions are the same at every site.

Sign in at one host name, then open the other in the same browser a few seconds later: you are signed in. Sign out at the second, and the first asks you to sign in again once the sign-out has reached it. Introspection of the same token at either site gives the same answer.

  • 400, “a realm holds at most 3 hostnames”. Free a name you no longer need, or ask Cvyūh to raise the limit.
  • 409. Another realm holds the name. Choose another.
  • An app’s refresh fails at the second site. Each host name is its own issuer: set a base URL.

The change to the realm’s host names is recorded on its audit trail: see Host names.

Send the realm’s host names again without the one you no longer want. The host name is freed, and users reach the realm only at the others.