Skip to content
Workforce IdentityMarkdown

Sign-in chains

Put sign-in methods in order and say what each answer means, so a passkey alone is enough, or a password must be followed by a code.

AvailableDashboard and API

A chain is the recipe for a sign-in: which methods run, in what order, and what each answer means. “A passkey alone, or a password and then a code from an authenticator app” is one chain. Every realm starts with a chain like that, checked to be safe, so most realms never write their own.

Write a chain when you want a different recipe: a password alone for a test realm, a separate sign-in for administrators, or a branch that sends a user with no passkey straight to the password page.

  • Who can do it: a realm administrator, in a group that holds RealmOwner (Delegated administration). RealmViewer can read chains.
  • Where: chains are written through the API; pointing the realm at one is in the dashboard under Authentication → Settings, or through the API (Call the API shows how to get $CVYUH_SESSION).
  • First: the module instances the chain names must exist (Sign-in modules).

A chain is an authChain object: an ordered list of entries, each naming a module instance and what its answer means. Most entries use a flag:

FlagWhen the module succeedsWhen it fails
mustGo onGo on; the sign-in fails at the end
gateGo onThe sign-in fails now
enoughThe sign-in succeeds now, unless a must entry already failedGo on
optionalGo onGo on

A module that steps aside, having nothing to check for this user, always goes on to the next entry.

As the sign-in walks the chain:

  • The first module to succeed names the user. Later modules confirm that user.
  • Each module that succeeds adds its level. The session’s level is the highest of them.
  • A password is typed once. An entry can share what it collected with later entries (shareCredentials), and a later entry can reuse it (reuseCredentials, with reuseMode: reuseOnly to fail rather than ask again).
  • The chain is fixed when the sign-in starts. A change saved halfway through doesn’t change the rules an in-progress sign-in is judged by.

For a branch, write an entry’s routes in place of a flag: where to go for each answer (succeeded, ignored, failed), as next, succeed, fail, or another entry by its instance name or position. A severity says whether the entry’s failure is decisive (it binds the outcome, as with must and gate) or deferred (it counts only if nothing succeeds). An entry written with a flag behaves exactly like the routes that flag stands for.

This entry signs in a user who has a passkey, and sends one who has none to the nativeStore entry:

{ "module": "webauthnAuth",
"on": { "succeeded": "succeed", "ignored": "nativeStore", "failed": "next" },
"severity": "deferred" }

Every new realm is created with these chains and module instances, and its default chain and administrators’ chain both point at universalLogin:

ChainEntriesUsed for
universalLoginwebauthnAuth enough, nativeStore gate, totp gateSigning in: a passkey alone, or a password then an authenticator app
webauthnRegChainconfirmIdentity gate, webauthnReg mustAdding a passkey to a signed-in account
nativeStoreChainnativeStore mustA password alone

A new realm also requires a second step (twoFactorMandatory: true) and allows all five modules.

Write the chain through the API, then choose it as the default or administrators’ chain, in the dashboard under Authentication → Settings or through the API:

  1. Write the chain:

    Terminal window
    curl 'https://foobar.cvyuh.com/api/v0/am/objects/v1/authChain?id=passwordThenApp' \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "chain": [
    { "module": "nativeStore", "flag": "gate", "options": { "shareCredentials": "true" } },
    { "module": "totp", "flag": "gate" }
    ] }'

    The realm checks the chain as it saves it, and refuses one that breaks a rule below with 400.

  2. Point the realm at it. defaultChain is what a sign-in runs when none is named; adminChain is what it runs when it starts with ?realmAdmin. Both are links, so a chain that doesn’t exist can’t be named:

    Terminal window
    curl -X PATCH https://foobar.cvyuh.com/api/v0/am/objects/v1/authSettings/authSettings \
    -H "Cookie: x-cvyuh-token=$CVYUH_SESSION" \
    -H "Content-Type: application/json" \
    -d '{ "defaultChain": [{ "id": "<chain-id>" }] }'

To run a named chain for a user who is already signed in, start the sign-in with ?service=<chain>. See Making a session stronger.

The sign-in page shows one module’s prompts at a time, in the chain’s order: a passkey prompt, a username and password form, a code field. A module that stands aside shows nothing. When a decisive entry fails, the sign-in is refused with 401 and the user starts again; the realm doesn’t say which step failed beyond the module’s own message. A user who takes longer than pageTimeoutSecs on a page, or loginTimeoutSecs overall, is told the sign-in expired and starts again.

Setting or limitDefaultRange
defaultChain, adminChainuniversalLoginany chain in the realm
loginTimeoutSecs: a whole sign-in1201 to 86400
pageTimeoutSecs: one page120
returnToAllowlistempty: only the realm’s own hosts, over httpsURL patterns
loginSuccessUrlthe dashboarda path or an allowed URL
SymptomCauseFix
Saving a chain answers 400It breaks one of the rules in Good to knowRead the message: it names the rule
Deleting a module answers 400A chain still names itTake it out of every chain first
Nobody can sign in after a changeThe default chain can’t succeed for your usersSign in with ?realmAdmin, which runs adminChain, and point defaultChain back
A sign-in lands on the dashboard, not the appIts returnTo isn’t on the realm’s host and matches no returnToAllowlist patternAdd the app’s address pattern to returnToAllowlist

A change to a chain or to authSettings is recorded as CREATED, UPDATED, PATCHED or DELETED in Audit → Config (Change history). Each sign-in through a chain writes LOGIN_STARTED, one MODULE_COMPLETED per entry with how it went, and LOGIN or LOGIN_FAILED (Audit → Authentication).

  • A chain is checked when it’s saved, not when someone signs in. Saving refuses a chain with no entries, an entry with neither a flag nor routes, a route to a name that isn’t in the chain or is listed twice (address that one by position), and a last enough entry after a must or gate one, which could never fail the sign-in.
  • Routes only go forward. A route back to an earlier entry is refused, so a chain can’t loop.
  • A decisive failure vetoes success. Even a route you wrote to succeed isn’t taken after a must or gate entry failed.
  • A route names an entry, not a slot. Inserting an entry doesn’t repoint a route written by name.
  • Return addresses are checked. A returnTo on the sign-in is followed only when it’s a path on the same host, or matches a pattern in returnToAllowlist. With an empty list, only the realm’s own host names over https are allowed. Other schemes, such as javascript:, are always refused.
  • The administrators’ chain is your way back in. Keep adminChain on a chain the realm can run by itself, so administrators can still sign in if the default chain is broken.
WhereSettingWhat it does
authChainchainThe entries: [{ "module", "flag", "options" }], or [{ "module", "on", "severity", "options" }]
authSettingsdefaultChainThe chain a sign-in runs when none is named
authSettingsadminChainThe chain a sign-in runs when it starts with ?realmAdmin
authSettingsloginTimeoutSecs (120), pageTimeoutSecs (120)How long a whole sign-in may take, and how long one page may wait
authSettingsloginSuccessUrl (the dashboard), loginFailureUrlWhere a sign-in lands when nothing else is asked for
authSettingsreturnToAllowlistURL patterns a returnTo address may match