Authentication
How a person or a machine proves who they are. For what they may then do, see authorization. The hard rules this page relies on are catalogued in constraints; the residual risks are collected in known limitations.
Principals
| Principal | Credential | Where it lives | Used by |
|---|---|---|---|
| Session | Opaque HttpOnly cookie naming a server-side record in Redis |
Browser cookie jar; platform secure storage on the phone | The web application and the Android companion |
| Personal access token | pat_-prefixed high-entropy bearer, stored as a hash with a display prefix |
Wherever the owner put it: a script, a scheduler, an agent | Automation outside the clients |
| Workload token | rwt_-prefixed 256-bit bearer, stored as a SHA-256 digest |
Mounted into the sidecar workload | A workload talking to its gateway and self-scope endpoints |
A workload token is read from the Authorization header only and fails closed: an unknown, expired,
revoked or malformed token resolves to no principal and never throws. It carries no permission codes;
it scopes the call to its own instance and the endpoint enforces the recorded consent. PAT and workload
principals share one raw-token shape check, and the two prefixes differ so the principals never
collide. Tokens are covered in authorization.
A refused bearer writes an audit entry only when it names a token the backend knows: a revoked or expired personal access token, or one presented from outside its address allowlist. A value of the wrong shape, an unknown token, a refused workload token and an unknown second-factor challenge are logged at debug level and write nothing, so a caller without credentials cannot grow the audit log at request rate.
Sessions
Web and mobile sign-in produces a server-side session record behind an opaque HttpOnly,
SameSite=Lax cookie, marked Secure when the request arrived over HTTPS. There is no refresh
endpoint and no client-held bearer token; a cold start revalidates the cookie against the
current-user endpoint. Signed tokens survive only as an internal access-token envelope and as the
one-shot bootstrap password-change token. The phone uses the same session, mirrored into platform
secure storage. See the constraint.
Keeping no token in browser storage removes the exfiltration target and makes revocation immediate: sign-out and password change delete the session record, which a self-contained token cannot express. The price is a re-authentication round trip on every page load. Clients never store a token.
Session lifetime comes from configuration (Redis:SessionLifetimeDays); the browser cookie expiry is one
constant shared by every site that appends the cookie. Both slide while the session is used. The stored
record is written with fixed serializer options and under fixed Redis key namespaces; changing either
makes every live session unreadable.
The session id is the cookie value and therefore a live bearer credential. It never reaches a log line;
a log line that must correlate one session across replicas carries its fingerprint, the first eight hex
characters of the SHA-256 of the id. Redis exception messages can name the command but contain no key;
their Exception.Data["Redis-Message"] can still contain the raw key, so do not add a log sink or
enricher that captures Exception.Data unless it drops that entry.
Requests another site sends with the session
SameSite=Lax keeps the cookie off cross-site writes, but a page on another port of the same host, or on a
sibling subdomain, is the same site and gets the cookie attached. So the backend refuses, before
authentication, any request that carries the session cookie (and no pat_ or rwt_ bearer), changes state
(every method but GET, HEAD, OPTIONS and TRACE) or opens a WebSocket (every realtime hub), and whose
browser says Sec-Fetch-Site: same-site or cross-site, unless its Origin is listed in
Cors:AllowedOrigins. The answer is 403 with errorCode: cross_site_request_refused, and the backend logs a
warning naming the method, path, fetch site and origin; nothing is audited, because the request has no
authenticated user yet and a hostile page could otherwise grow the audit log at request rate.
same-origin (the application itself, also behind the development proxy) and none (an address typed or
bookmarked by the user) pass. A request without Sec-Fetch-Site passes too: browsers send Fetch Metadata
only to secure origins (HTTPS or localhost), so on a plain-HTTP LAN address the check never fires, and the
phone app and scripts send none. Personal access tokens and workload tokens are not session-authenticated and
are not affected. See known limitations.
The session is read on every request; only the slide is throttled
Reading the record is what makes a deleted record refuse the very next request, so it is never cached.
Sliding (resetting both Redis TTLs and re-issuing the cookie) happens at most once per
Redis:SessionSlideIntervalMinutes per session on each replica, remembered in that replica's memory. A
replica that has not seen the session, or has evicted the entry, slides once more. Between slides both
lifetimes run down by up to one interval, so an idle session expires somewhere between the lifetime minus
the interval and the full lifetime. Start-up refuses an interval that is not below both the session
lifetime and the cookie lifetime; keep it far below them.
A slide also re-reads the user's roles and permissions from the database. The session holds a snapshot taken at sign-in, and the claim-gated policies, hubs and controllers read that snapshot. A grant changed without a purge (the boot-time seeder giving a role a new default, a migration) would otherwise wait for the next sign-in, which a 30-day sliding session may never need. On a slide the handler compares the database's grants with the snapshot and, if they differ, rewrites the snapshot and answers that request from the new set; every replica reads it from Redis from then on. A grant or a revocation made by any path other than the admin API therefore reaches a live session within one slide interval, and at the first request a freshly started replica serves for that session. A user the database does not know, or who is not Active, has the session refused and removed at that check. When the database cannot answer (a transient connection failure), the slide is skipped: the request is answered from the stored snapshot, neither lifetime is extended, and the session's requests on that replica try the slide again a minute later, so a database that does not answer at all stalls only the requests of a session that arrive before its read gives up, once a minute, rather than every request. Revocation does not wait on it, because every purge below deletes the record that each request reads.
Changes that purge sessions at once
Because the snapshot is what claim-gated endpoints authorize from, every change to what a user may do purges that user's sessions in the same operation: disabling or deleting the user, a password reset or change, a role's permission delta (a name-only edit excepted), and detaching a wrongly attached identity link (the cookie handler never re-checks the link). Changing how an account is entered also invalidates every cookie issued before it.
Live SignalR revocation
Every hub connection is indexed locally by a session fingerprint or PAT id and user id. A successful revocation publishes a Redis cluster hint after the durable change; each replica applies it locally and aborts matching sockets on receipt. A connection authenticated just before its filter registers it can miss that hint; the next backstop pass closes this connect-then-hint race. See the constraint. Live camera streams join the same index by their session, so a hint ends them too; the Matter-bridge stream has no session and is indexed by its bridge user only, which hints reach and the backstop pass skips (camera media).
The raw session id stays in the connection registry's process-local entry only so the backstop can read the raw-id Redis key. It is never logged or sent in a cluster hint; Redis session keys and set members keep their raw-id schema.
Each replica revalidates live credentials at SignalR:CredentialRevalidation:Interval (60 seconds by
default). Authority is evaluated by credential kind:
| Credential | Revoked when | Verified when | Ages toward abort when |
|---|---|---|---|
| Session | Redis has no record, the record belongs to another user, or a successful Postgres read says the user is not Active | Redis read succeeds with a record for the connection's user; a Postgres outage does not change this | Redis read fails or the record cannot be deserialized |
| PAT | A successful Postgres read finds it missing, revoked, expired, owned by another user, or its user not Active | Postgres read succeeds and finds a live PAT for an Active user | Postgres read fails |
The stores are independent for this decision: Postgres can accelerate session revocation while readable, but Redis is authoritative for sessions. A Postgres outage therefore does not age valid Redis sessions; a Redis outage does not age PATs whose Postgres records remain valid. An unreadable credential is aborted on the first pass at or after two intervals from its last successful verification; no per-connection delay is added. A credential that cannot be verified from connect is aborted in about three intervals plus the sequential Redis and Postgres read durations and scheduler delay. Lost hints are detected within one interval plus the sequential read durations of two ticks. Failed store reads are logged with the exception type only, because Redis timeout details can include the raw session key. Malformed records are counted separately, and unverified aborts produce one aggregate warning per tick.
Credential expiry is checked in the backstop, so expiry without an explicit revocation hint closes within the lost-hint bound. Hints cover logout, logout-all, password change, OIDC refresh termination, PAT revoke and revoke-all, user disable, and user deletion. A user hint closes all credentials for that user.
A credential re-check inside a live session
An endpoint that answers 401 about a credential inside an already-authenticated session (a mistyped current password on a password change or a factor disable) must be flagged as a credential re-check. Both clients treat an unflagged 401 as the end of the session and tear it down, which signs the user out mid-dialog. On the phone every call and the hub connection ride one shared cookie-carrying HTTP client; a second client has its own cookie jar and every call it makes comes back unauthorised. See the constraint.
Primary and second factors
Primary authentication is a password or a federated identity. TOTP and WebAuthn credentials are second factors and step-up proofs, never a way in on their own.
The invariant that every account keeps a way in counts passwords and live provider links only (the provider still configured and enabled), never a raw row count. A passkey is bound to one handset, so an account whose only entry lived on one device would be one lost phone from unrecoverable; and counting stored rows rather than live links would call an account safe when the provider behind its only link had been deleted. Removing the last way in is refused. See the sign-in rules.
Disabling a second factor or revoking a credential requires a purpose-bound step-up token, plus the current password when, and only when, the account actually has one. Whether a password is owed is read from the account, never from an implicit required field that would let model binding refuse first. Demanding a password from a passwordless account makes the check impossible to satisfy.
Password verification never throws, so a wrong password and a missing account are indistinguishable. It mirrors the change-password path so the two cannot disagree, and it checks for a blank password only after the lookup, so a blank is no timing shortcut. An account with no credential has not proved one; answering otherwise would tell a caller holding a hijacked session that the account is passwordless. Setting a first password on an account that already has one is refused rather than treated as a reset.
Step-up tokens
A step-up token records the single ceremony it authorises: disabling two-factor authentication,
revoking a credential, regenerating backup codes, adding a factor, setting a first password, or revealing
one stored secret (reveal_secret, which audits the field location and never the value). The purpose is
stored by name, parsed case-sensitively against the defined values, and compared at redemption; user and
purpose are one string, so a peek cannot be laxer than the redemption. The token lifetime is defined once,
so the store expiry and the advertised expiresAt cannot drift.
Without that binding, a user talked into stepping up for a low-stakes action hands over a token good for any of them: a token minted to replace a lost code sheet would register an attacker's passkey. Adding a way in and removing one are the same confused deputy in opposite directions. Each sensitive ceremony has its own purpose. Setting a first password is separate because its token can be minted by an account holding no second factor at all.
Peek first, redeem at the commit gate. A handler peeks the proof before anything else and redeems it
only at the final commit, so a typo or a policy-rejected password does not burn a proof that may have cost
a forced identity-provider round trip, and a caller without a proof cannot destroy the real browser's
in-flight challenge. The peek precedes any password check, so a hijacked session cannot use the endpoint
as a password oracle. If the commit fails after the redeem, the proof stays spent: it is spent exactly
when the account changes. A request with no body reaches the handler and gets step_up_required rather
than a binding 400.
A step-up challenge shares a store with login challenges and is told apart in both directions by ordinal comparison: a login door that answered a step-up challenge would mint a full session from a narrow proof, and a step-up challenge can never be answered at the login door. A password step-up is only the floor for an account with no second factor. An account that owns a factor the host cannot verify (WebAuthn relying party unset) is gated on raw ownership, so a password never stands in for a hidden passkey. The method chooser offers only what the host can verify; an empty list carries a reason only when there is nothing to offer.
Step-up through an identity provider is offered only for providers whose round trip can be forced. It
uses a signed HttpOnly cookie carrying the PKCE payload, separate from the login flow's cookie so one
ceremony cannot complete or destroy the other. Identity comes only from the assertion's issuer and subject
pair, both compared because a subject is unique only within its issuer. The state must agree with the
browser that began the ceremony. Freshness rests on the callback, not on prompt=login (a hint in a URL
the caller navigates): max_age=0 is requested and auth_time must be later than the ceremony's start,
less a deliberately tight one-minute drift tolerance; a missing auth_time fails closed. PKCE material is
single-use even when a leg fails. Validation precedes the token lookup, and no log row names the other
account. An unknown challenge and "no forceable link" give the same answer.
The second-factor login challenge
After a successful primary authentication on an account with a confirmed second factor, no session cookie is issued. The response carries an opaque challenge token containing no user identity, plus the methods the account has enrolled (otherwise the screen assumes TOTP and dead-ends a security-key-only user). The password step does not report how many backup codes are left: that would disclose recovery state to someone who has proved only a password.
The client mints a high-entropy verifier first and the server stores only its hash; the raw verifier must be presented at redemption and is compared in fixed time. An attacker can hand a victim a link, but cannot make the victim's client hold the attacker's verifier. The verifier must never be read from a URL, a redirect, a route parameter, an intent extra or any header an attacker can cause the victim to send, and each client holds it in exactly one process-wide place. A verifier-less challenge is refused at mint; missing or empty commitments fail closed; an absent and a wrong verifier give one indistinguishable refusal.
A peek never counts an attempt: tokens travel in URLs, so the binding is checked before the challenge is
resolved, or a leaked token could exhaust the legitimate browser's attempts. Five wrong second-factor
attempts destroy the challenge; challenges also expire after a few minutes, and a missing and an expired
challenge are indistinguishable. The wire error for an expired challenge stays challenge_expired,
because the clients match it to say "sign in again"; wrong_code is also a 401 and means the opposite, so
clients decide on the machine-readable detail, never the status.
TOTP accepts plus or minus one 30-second step and compares in constant time. The step counter is recorded on the enrolment row rather than on challenge state, so the same six digits cannot be replayed through a freshly minted challenge. Only a step later than the last accepted one is accepted, so an older code still inside the window cannot be used after a newer one. This is indistinguishable from a wrong code and spends an attempt the same way; the one legitimate case it can catch is two authenticator apps sharing a secret, with opposite clock skew, used within about a minute of each other. The later app's step is accepted first, and the earlier app's next code then works.
Two-factor enrolment and backup codes
Enrolment returns the ten one-shot backup codes exactly once, in the response that creates them, and only when the account held none: an account with an unused set gets an empty set, because replacing it would kill codes the user may have written down. A confirmed account is refused with 409; re-enrolling means turning the factor off and on. Recovery codes minted by a first passkey are created only after the credential is persisted, under the same rule.
Regenerating a set refuses while the user still holds unused codes, and refuses when no confirmed factor exists: the raw values cannot be recovered from the stored hashes, so there is no way back from replacing a sheet the user wrote down, and codes with no factor could never be redeemed. The one path that may replace a live set returns the replacement in the same response. An exhausted set is replaced, not added to. Codes are deleted only when no factor remains, so they survive an admin clear while a passkey remains. Unknown and used codes are one indistinguishable failure.
"Has a confirmed factor" is answered from the credential tables directly, never from the WebAuthn service, which reports no credentials whenever the relying party is unconfigured on the host. An operator clearing that configuration for a moment would otherwise prune or refuse backup codes for every passkey-only account. Pruning, regeneration and the low-codes warning all read that one answer.
A non-system administrator cannot clear or reset the second factor of a more privileged user, and an administrator cannot clear another administrator's (an account holding a system role, or the built-in administrator): only the built-in administrator can. Nobody else can clear the built-in administrator's factor in the application, so a lost one is recovered with the database procedure in troubleshooting. Clearing is idempotent: it is audited and answers 204 when nothing is enrolled. Adding or removing a second factor (enrolling or confirming TOTP, registering or revoking a passkey, an administrator clearing either, a redeemed reset link) and generating recovery codes commit the change, its audit rows and any recovery codes minted or pruned with it in one save, so a failed audit write leaves the factors as they were. An admin clearing passkeys while a TOTP enrolment stands does not prune recovery codes. Credential listings include token ids but never plaintext, and the admin token endpoint refuses another user's token even given a stolen id.
Credential storage
| Credential | Storage |
|---|---|
| Password | PBKDF2; the hasher version and iteration count are recorded with the hash and read back from it |
| Backup code | Argon2id at interactive parameters, XXXXX-XXXXX over an exactly-32-symbol alphabet (50 bits), a 12-byte salt per code |
| TOTP secret | Encrypted at rest through its own protector purpose |
| WebAuthn credential | Public key and credential id; no secret material |
| Personal access token | Hash only, plus a short display prefix |
| Workload token | SHA-256 digest only, returned once at mint or rotate |
The default password policy is eight characters with at least three of the four character classes; a whitespace-only password is refused. A password provided at user creation, even an empty one, is always policy-checked, and a missing password does not make an account "OIDC-only", because creation cannot attach an identity link and would produce an account with no way in.
These parameters are part of the stored data and must never be changed in place: the backup-code scheme (alphabet, length, salt size, Argon2id parameters), the protector purpose of TOTP secrets, the session record's serializer options and the Redis key namespaces. Re-tuning the backup-code scheme makes every stored code unverifiable, and a fast hash would let codes this short be ground from a database dump.
Timing and the failed-login lock
Failure paths in the login door cost the same work as the success path. A shared dummy hash is verified against whenever there is no real credential row, and it encodes the hasher's current version and iteration count on purpose. Heavy relations are loaded only after password verification succeeds, so response time cannot distinguish "no such account" from "wrong password". A failed attempt is recorded even if the client hangs up after proving the password.
Repeated failed password sign-ins block the source address, never the account
(constraint). Each
POST /api/auth/login that gets past the DisableLocalLogin refusal takes a permit for its address,
before the account is looked up except on a safe-mode replica (below), from a fixed window of
Auth:Lockout:DurationSeconds (900) that the address's first counted attempt starts. Past
Auth:Lockout:MaxAttempts (5) the request is refused. The permit is kept on a wrong password, an unknown
name, an inactive account or an error before the verdict, and returned when the password is right. A
safe-mode refusal of a member never takes one. A success does not clear earlier failures: with any valid
account at the same address, an attacker could otherwise reset his own budget. Concurrent guesses cannot
overshoot: at most MaxAttempts permits are held per address at once, so no more than that many can be
waiting on a verdict together. A returned permit is handed to whichever window is running when the verdict
lands; if the window turned over after the permit was taken, the return frees a slot in the next one.
Timed that way, a caller with a valid account can move unused budget forward, so one window can verify up
to twice MaxAttempts passwords, while the average stays at most MaxAttempts per window length.
Auth:Lockout:Enabled=false turns the lock off; the auth rate limit stays.
Accepted: because a correct password holds its permit until its verdict, more than MaxAttempts
correct sign-ins racing from one address can briefly see 429 until the earlier ones hand their permits
back, and a return that keeps losing to concurrent takes leaves its permit spent. That is the price of
never holding more than MaxAttempts permits per address at once.
A blocked address gets 429 with Retry-After set to the seconds left in its window, the problem detail
"Too many failed sign-in attempts from this address. Try again later.", the audit event
auth.login.blocked (no user id; the address in the description) and the metric outcome locked. The
decision is taken before any account lookup or hash, so on a healthy replica the answer is the same for
every name and password and tells nothing about either. Failed-login audit entries carry the source
address in their description. No one can lock another person's password sign-in; a stream of wrong passwords
blocks only the address it is counted as. That is the client's own only when the forwarded-headers chain
reaches it: when a proxy is not trusted, not counted, or hides the client, the counted address is a
proxy's, and a block on it refuses everyone behind that proxy.
The address is HttpContext.Connection.RemoteIpAddress after the forwarded-headers middleware, never a
header read directly and never a body value. An IPv4-mapped IPv6 address counts as its IPv4 address, IPv4
is counted per address, IPv6 per /64, and a request with no address shares one unknown bucket. The /64
stops rotation inside one end site's subnet, not across a larger delegation: a /56 or /48 holds 256 or
65,536 /64s, each with its own budget, and the per-address auth limit shares the same key. The same key
partitions every per-address rate-limit policy. Only this endpoint counts into the lock: the second-factor,
step-up, password-change, passkey and reset-link doors keep their own limits. Wrong second-factor codes,
including the five that destroy a challenge, do not count against the address lock.
Wrong authenticator codes at sign-in count against the account instead. A fresh challenge costs only
the password, so the challenge's own five attempts and the per-address 2FA buckets alone let a password
holder try about 50 codes a minute from one address. Each POST /api/auth/2fa/verify with a TOTP code
takes a permit keyed by the user id, from the same Auth:Lockout window and budget as the address lock
(MaxAttempts 5 per DurationSeconds 900), whatever address and challenge it comes from. A right code
returns its permit; a wrong or replayed code keeps it, and a success does not clear earlier failures. Past
the budget a TOTP code is refused before it is checked, with 429, Retry-After, the problem detail
totp_locked and the audit reason account_locked. Backup codes and passkeys are neither counted nor
refused: they cannot be guessed, and they are the way back in. Auth:Lockout:Enabled=false turns this
count off with the address lock.
Accepted: someone who has the password can keep the account's authenticator-code sign-in locked by
spending its budget every window. The account still signs in with a backup code or a passkey, and an
administrator who sets a new password ends the attacker's supply of challenges. That is the price of
bounding guesses at one account to MaxAttempts per window, about 480 a day, from any number of addresses.
Every counter and one-time token holds across replicas
Behind a balancer with no session affinity, concurrent requests for one account land on different replicas. Every piece of security state is therefore counted or consumed in one atomic step in shared storage, never read, changed in memory and written back, which lets two requests read the same value. Stores live in Redis because the halves of a ceremony may land on different pods.
| State | Where | How it is spent |
|---|---|---|
| Second-factor attempts on a challenge | Redis | One INCR on a counter beside the entry, in a transaction that runs only while the entry exists; the attempt past five deletes the challenge; an aborted EXEC is retried a few times |
| Second-factor challenge, on success | Redis | A delete that reports whether it removed the entry; only the request that removed it (TOTP, backup code, passkey, password or provider) signs in or mints a step-up token |
| TOTP step counter | PostgreSQL | A concurrency token: of two verifies that read one step, the second to save is a replay |
| Backup codes | PostgreSQL | A concurrency token on the set; a conflicting consume re-reads and re-matches, so a code is spent once and no concurrent consume undoes another |
| Passkey enrolment and assertion challenges | Redis | GETDEL |
| Step-up proof | Redis | GETDEL |
| Admin-issued TOTP reset link | Redis | GETDEL |
| OIDC hand-off | Redis | GETDEL; a wrong verifier burns the hand-off |
| An OIDC session's identity-provider refresh token | Redis, in the session entry | Refreshed under a PostgreSQL slot lease of limit one per session; the token the provider issues is written as soon as it answers, and a refused one deletes the session, by a transaction conditioned on the entry still holding the token spent |
| Failed-login permits per source address | Redis, through the rate-limit storage | INCR and PEXPIRE ... NX in one transaction take a permit and start the window; a DECR in a transaction conditioned on the key existing and being above zero returns one |
Single-use always means one GETDEL, never a GET then a DEL, and a malformed payload counts as
absent. The passkey, step-up, admin-reset-link and OIDC hand-off stores live in Redis on every replica
count; there is no in-memory variant. Every named rate-limit policy counts through the rate-limit storage
in Redis, shared by every replica (see rate limiting).
When Redis is unreachable these doors fail closed: the rate limiter, the failed-login lock and the challenge stores throw, and the request is answered with an error rather than let through uncounted. A factor change that races a verify on the same account (a disable, an admin reset or a code-sheet regeneration saved just after a verify spent a step or a code) is answered 409, and repeating it succeeds.
Forwarded headers and trusted networks
Behind a proxy the counted address is only right when forwarded headers are trusted for it. The Compose
stack and the Helm chart turn forwarded headers on, and a backend with forwarded headers on and no trust
list configured trusts loopback, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 and fc00::/7, so that
one attacker behind the ingress does not block sign-in for everyone.
One optional setting replaces that default: ForwardedHeaders:TrustedNetworks in the backend,
TRUST_SUBNETS in the Compose .env, forwardedHeaders.trustedNetworks in the chart. KnownNetworks
and KnownProxies also work and are unioned with TrustedNetworks; any entry in any of them replaces
the default. An entry that does not parse fails the boot, because dropping it would silently trust the
rest or the default. Only the middleware may set X-Original-For. When a peer outside the list sends
X-Forwarded-For, the log warns that it was ignored: the signal that the proxy is outside the list.
The counted address is the X-Forwarded-For entry ForwardLimit hops from the right, so every hop
between the client-facing edge and the backend must be both counted and trusted, and none may hide the
client. The chart's forwardLimit is 1, which counts the address the ingress controller saw. The Compose
stack's is 1, the frontend's nginx; a TLS proxy in front of it needs the limit raised by one. When the counted
address is itself trusted and X-Forwarded-For still names an earlier hop, the backend logs a warning at most
every ten minutes: a trusted proxy is counted as the client, or a client on a trusted network sent the header
itself. A TCP proxy
without PROXY protocol in front of the ingress makes every client count as that proxy, with no warning.
Behind a CDN whose entry is counted, the origin must accept only the CDN's address ranges, or a direct
caller chooses its own counted address. ForwardedHeaders:ForwardedForHeaderName reads the address from
another header instead, such as a CDN's single-value CF-Connecting-IP with ForwardLimit 1; the same
trust rules apply, and the origin must again accept only the CDN's ranges, or the header can be forged.
Anything on a private network that reaches the backend without the proxy can name its counted address;
an operator whose backend is reachable that way sets the trusted networks to the proxy's address or
narrowest subnet. Operator settings are in configuration.
Passkeys
The relying-party id and the allowed origins come only from configuration, never from the request
Host header, and no raw credential bytes reach a log. The origin policy alone validates the shape of
an origin, because the WebAuthn library passes an android: origin through and then rejects every real
assertion. Android origins are the APK key-hash form: the android:apk-key-hash: prefix plus a
43-character base64url digest. The colon-separated hex fingerprint form is refused with or without the
prefix, because a bare fingerprint counts as a configured web origin and suppresses the derived browser
origin too.
The accepted set is not the typed list: blanks are dropped, https://<RpId> is derived only when the list
is all-Android, and an empty list derives nothing. Availability is gated on the relying-party id alone. An
Android origin outside the effective set is refused naming the value that arrived, since debug and
release builds are signed differently. With no relying-party configuration the server answers "not
configured" for that method rather than pretending it is available. The validators are deliberately
narrow so a half-configured host still boots.
The relying-party id is part of every credential, so changing the deployment domain forces re-enrolment. That is protocol behaviour, not a defect.
Ceremony rules:
requireUserVerificationis false at the login door, because demanding it would lock out roaming authenticators that cannot do it. Only the step-up ceremony that removes a factor requires it, and its options are stored with the challenge, since rebuilding them from configuration would drop step-up to the global default. An assertion lacking user verification is a retriable error, distinct from a 401 that would trip the client's session teardown.- Registration excludes active credentials (revoked ones may be re-enrolled) and binds the user handle to the user id, since the key is a second factor only.
clientDataJSONis client-supplied and parsed without ever throwing.- The single-use proof is spent after every refusal unrelated to the human proving themselves, and inside the write, so two concurrent finishes cannot both leave a credential. Only the verify whose delete removed the parent challenge may succeed.
- Fetching assertion options does not consume a parent-challenge attempt, or five calls would lock the challenge. The credential-id allow-list in those options is gated by the challenge binding, because the door is free to call, and the binding is peeked before the single-shot consume so an unbound caller cannot destroy the real browser's prompt.
- The WebAuthn library exposes no error codes, so its messages are mapped to reason codes. An unknown reason is treated as the generic one, so the client's retry loop always ends.
Federated identity
Linking
Linking is deliberately conservative. An incoming identity is matched to an existing account by nothing but these two rules:
- by issuer and subject, where the issuer is the configured provider's, never the token's
iss; - then by e-mail, when the address is authoritative: the provider sent
email_verifiedtrue, or the provider is marked trusted for e-mail linking and sent noemail_verifiedclaim. Two accounts with that address refuse the link. An account that has a password is linked this way only when the provider is marked trusted for e-mail linking.
The provider's username never selects an account, because a provider may let its users choose
preferred_username or nickname. An identity that matches neither rule is auto-provisioned as a new
account when the provider allows it, under the provider's username or, when that name is taken, the first
free <name>-<n>; otherwise it is refused. To attach such an identity to an existing account, an
administrator links it from the user's detail page.
Matching normalises e-mail case; email_verified accepts "1" and "yes"; the operator's trust flag fills a
missing claim but never overrides an explicit false. Auto-provisioning refuses to create a second account
on an e-mail already in use, and stores the address only when it is authoritative: an account provisioned
from an unverified claim has no e-mail, so the address cannot later pull its real owner into that account. The users table has no unique e-mail index, so the service guards duplicates,
persists why an identity was not attached, and never echoes the address to an anonymous caller. Attaching
an external identity to a password account hands the identity provider control of that account, so
without the e-mail trust flag that attachment is an administrator action on the user's detail page; turn the
flag on only for a provider whose verified addresses you would trust with every password account. An attached link takes its issuer from the stored provider, because a free-form issuer creates a
silently dead link.
Identity-provider issuers must be absolute HTTP(S) URIs, and a callback URI is accepted only when it is
already an absolute http or https URI: on Linux a leading-slash relative path parses as an absolute
file:// URI and would be sent to the provider as one. Anonymous endpoints expose only a provider's id
and display name; the full configuration stays behind the integrations permission.
A sign-in through a provider asks for the account's second factor like a password sign-in, unless that
provider has SkipTwoFactor set (off by default), which trusts the provider's own authentication instead.
Turning it on is audited on its own.
Role sync
Role sync is destructive and authoritative. When "use roles from the identity provider" is on, every
sync strips the account's roles and re-grants whatever the claim matched, falling back to the default
household role when nothing matched rather than refusing the sign-in, so a claim typo cannot lock the
operator out. A mistyped claim name therefore demotes every federated user, administrators included, on
their next sign-in. The one exception is the built-in administrator, which keeps Administrator (see
below). Claim values are upper-cased for matching. The sync writes its audit entry in the same save and only when the role set
changes; the entry distinguishes claim_empty (a configuration fault) from no_match, and records the
values the provider actually sent. One implementation serves the callback and the refresh, so the two
doors cannot disagree.
Roles must always be loaded with their permissions attached. A bare role resolves to an empty permission set, which is then written into the stored session.
Group membership cannot revoke the identity linked to the built-in administrator. Removing that person from the provider's admin group only changes what the next sync's claim says; the sync adds Administrator back regardless, and logs a warning each time it does. Revoking that access means disabling the identity at the provider, or, since a non-flagged administrator cannot manage the built-in account at all, signing in as the built-in administrator, unlinking the identity, and rotating the account's password.
Besides sign-in, a sync runs on a request whose session's identity-provider access token has expired,
when the session holds a refresh token and has not synced in the last five minutes. A federated sign-in that
passes through Reeve's own second factor keeps the provider, refresh token and access-token expiry in the
second-factor challenge, and the session the TOTP, backup-code or passkey door opens carries them, so it
syncs and ends at the provider's refusal like one opened straight from the callback. Those session-local
tests come before any database read. Each request reads the oidc state from its pinned generation to
rule out providers that do not sync roles. A sync that proceeds reads the settings from PostgreSQL. When a
provider is added, removed, or its issuer or metadata address changes, reconciliation drops that
provider's cached provider document.
A session's refresh runs once and ends the session only on a refusal
A browser sends several requests at once, and without affinity they land on different replicas with the
same expired token. Each takes a lease (30 seconds) before calling the provider: a held slot of limit one
in PostgreSQL, keyed by a hash of the session id (the id is a secret) and never renewed, so a holder that
dies frees the session after 30 seconds. A replica that is not serving, or whose grant is still not known
after one retry, answers 503 instead of refreshing. A fence ends the holder's slot at once, so a peer
can refresh while the holder's one provider call is still in flight; a provider with reuse detection may
then end that session. The holder re-reads the session first, and if a peer already refreshed it, uses
that result. A request that finds the lease taken re-reads the session every 100 ms for up to 15 seconds
and authenticates with the peer's result as soon as it lands. The provider call and the ID-token
validation share a 10-second bound, and the role sync has its own 10 seconds; the lease is held until the
final write, and the whole holder path fits inside the 30-second lease. None of the three runs on the
request's own aborted-request token: the provider has rotated by the time a browser disconnects, so the
token it issued is stored even when nobody is left waiting for it. A request authenticates only once the
session's sync mark has moved, and the comparison is on any change of it.
The lease is only mutual exclusion. The result is written by a compare-and-set on the refresh token the
holder spent, so a holder whose lease lapsed can never overwrite a newer token, and a sign-out in the
meantime is not undone. The token the provider issues is stored the moment it answers, conditioned on the
spent token, without moving the session's expiry or its role-sync time, and before the ID token is
validated and the roles are written; a failure in either later step leaves the session holding the token
the provider accepts next time. A Redis error on a write is ambiguous, so the step re-reads and retries
once. The session is deleted only when the provider answers invalid_grant to the token the session still
holds, again conditioned on it, never because a peer spent it first. Any other failure (the provider
unreachable or slow, an error status, an ID token that fails validation, a failed role write) refuses that
one request and leaves the session and its token for the next one; a request still waiting when its 15
seconds run out gets the same answer.
That refusal is answered 503 with Retry-After: 5, not 401: a 401 is the web client's dead-session
signal, and the session here is alive. The web client parses that 503 as "try again", keeps the session
and retries; it does not show the sign-in page, clear auth state or redirect. A genuine end of session
(the provider refusing the token the session holds, or no session at all) is answered 401 and torn down.
A replica that crashes between the provider answering and that token being stored still costs that user a
sign-in. auth_time on the refresh leg is no freshness signal, because step-up never refreshes.
Cached roles are never served through a provider outage, because that would extend a revoked role for as long as the provider is down.
A new signing key is fetched when a token names one. Each replica caches a provider's metadata and key set for 15 minutes. An ID token whose key is not in the cached set makes the replica refetch it once and validate again; further unknown keys inside the next 30 seconds reuse that fetch, so a burst costs at most one metadata and one key-set request per provider per replica per 30 seconds. Callers that arrive while the fetch runs wait for it. An unusable document (no keys, wrong issuer) is rejected before it replaces the cache. A key the provider does not publish fails validation. A lapsed signing certificate only logs a warning.
Authorization URLs
Login and step-up share one authorization-URL builder, so two copies cannot drift. The step-up ceremony
strips the operator-tuned prompt and max_age and sets its own by targeted edits of the query string;
parsing and re-serialising would alter scope or acr_values. What was begun comes from the signed state,
who completed it from the assertion. Login and step-up states share one HMAC key and are told apart by a
purpose field checked in both directions. Step-up fields in a signed state are nullable, all null for an
ordinary login, so a forgotten check fails closed.
Native sign-in from the phone
The native flow forces a fresh login (RFC 8252), so a silent single-sign-on completion cannot hand the app the victim's session. The app mints a challenge-binding verifier that never leaves its process; only the SHA-256 commitment travels, sealed in the signed state, because the raw verifier must never reach the backend through a URL the system browser can log. A native state without a commitment fails closed.
The backend returns to the app through a custom URI scheme with no path (the platform authenticator
rebuilds the result as {scheme}://{host}?{query} and drops a path). Only a top-level navigation can
follow a redirect to a custom scheme, so only a navigation gets the 302. Any installed app can register
that scheme, so the value it carries is an opaque one-time hand-off, never a challenge token, useless
without the verifier. The hand-off is a verifier-hash-bound Redis record, because the browser leg and the
app's redemption may reach different replicas, and the app redeems it on its own HTTP client, since the
system browser has a separate cookie jar. This is the only native call that sets a keepable cookie; the
phone has no equivalent of the web application's OIDC challenge entry point. The app does not use an Android App Link for this
hand-off, because Android fixes android:host in the manifest at build time and a self-hosted deployment's host
is unknown then. The residual risk is in known limitations.
Local sign-in and safe mode
DisableLocalLogin refuses every password sign-in, before any account is looked up. A replica in safe mode
lifts that refusal for accounts that hold the Administrator role: the built-in administrator seeded from
the BootstrapAdmin configuration section and any other account given that role. Safe mode turns every OIDC
endpoint off, so without this a broken provider would lock the operators out of the Cluster tab. An
administrator must still be Active and give the right password.
On a healthy replica DisableLocalLogin answers 403 before anything is counted. On a safe-mode replica every
other name, including a member, a custom role carrying the same permissions, and a name that does not exist,
is refused with the same 403 before its password is checked and before the
failed-login lock is consulted, so the refusal neither counts against the
address nor answers a password question the healthy replicas would not. An administrator's name then goes
through the lock like any sign-in: 429 from a blocked address, and a wrong password counts against the address
only. A refusal is audited as auth.login.safe_mode_refused. When an administrator's password passes, the
replica records auth.login.safe_mode_bypass. That entry says only that the password was accepted. The entry
saved with it says what followed: a password change, a second-factor challenge or a session.
The refusal discloses which names are administrators. This is accepted. In safe mode with
DisableLocalLogin set, members and unknown names answer 403, while an administrator answers 401 for a wrong
password and 401 when disabled, and only an administrator's attempt spends the time of a password hash.
Anyone who can reach a safe-mode replica can therefore list the administrator names. A healthy replica gives
no such signal.
What the rule costs. A safe-mode replica answers sign-in (its fence exempts it) and a Compose balancer
still sends it requests, so an administrator can sign in with a password against policy by retrying until the
request lands there; a Kubernetes Service lists no safe-mode pod. An administrator already holds
integrations.manage, which turns DisableLocalLogin off, so this gives the role nothing it lacks, but it
gives someone holding an administrator's password, and not their identity-provider session, a way past the
provider. Do not widen it to members or to any permission-based test: the rule names the Administrator
role, not its permissions, and a custom role carrying every one of them is still refused.
The built-in administrator is kept usable. It is the one administrator the rule is guaranteed to find
with a password, since every other administrator can be a federated account with none. The User entity
refuses to disable it or give it a role set without Administrator, and every writer of status or roles goes
through the entity (constraint).
The refusal is checked before the last-administrator check, and the API answers 409
built_in_administrator. OIDC role sync with "use roles from the identity provider" keeps Administrator on it
whatever the claim says, and the auth.oidc.roles_synced entry records builtInAdministratorKept. Every run
of the database initializer finds it by the flag, recreates it if missing, gives it a password from
BootstrapAdmin:InitialPassword if it has none, and restores the Administrator role. It leaves status alone:
the built-in administrator's status is the operator's decision, and a disabled one only produces a warning,
since other password-holding administrators are still admitted in safe mode. Since failures are counted per
address, nobody can lock the built-in administrator out with wrong passwords; they can only block the address
they are counted as, which is their own when the proxy chain is configured as above and a shared proxy's when
it is not. The way out when the password or second factor is lost, or the operator's own address is blocked,
is in troubleshooting.
The bootstrap administrator's credential is flagged must-change: its first sign-in issues a short-lived, single-purpose change token instead of a session. The change-password hand-over opens with an empty current password field.
Deployment-managed OIDC
A deployment can declare the whole OIDC feature as Managed:Oidc (see
managed configuration): the two switches and the
providers, each with a declared Id and its client secret as a value, a file or a reference. Every replica
reads its own copy of the section live, so sign-in and the callback use the declared providers and secrets, and the
API refuses a write to the OIDC settings with feature_managed after the permission check. Sessions and linked
identities refer to the provider Id, which is why the deployment declares it. A secret held as a file or reference
is bound to the provider that declared it, never to a list position. Disabling local login is applied only while an
administrator has an identity linked to a declared issuer; while that fails local login stays enabled and an alert is
raised.
Mobile client boundaries
The Android companion follows the same model with platform-specific edges. The user-facing behaviour is described in clients; the security-relevant rules are these.
- Cleartext HTTP is closed everywhere. The app ships a network security configuration that forbids cleartext for all traffic, with no exceptions and no per-host entries. The shared HTTP client goes through the platform's native handler and every WebView, the camera sheet included, is bound by it. To drive a local rig from a phone or emulator, put HTTPS in front of it; never add a host to the file, because it ships inside the app. The same file trusts user-installed certificate authorities beside the system ones, so a server behind a private CA works once the operator installs that CA on the phone; which CAs a phone trusts is the phone owner's decision.
- The sign-in screen is two steps driven by the server. Step one asks only for the server address;
step two renders what
GET /api/auth/login-optionssays that address accepts: a credential form when local login is on, a row per identity provider, and a notice only when neither applies. - Passkeys and biometrics fail towards the other factor, never towards a dead end. Every flavour of "no credential provider here or nothing to offer" maps to unavailable, so the challenge screen degrades to the authenticator code; a passkey that reports unavailable is withdrawn for the rest of the challenge. Meaning comes from the platform error's type, never its localised message. A biometric prompt that did not run costs an unlock, not the session; only a prompt that ran and came back against the user is a denial.
- A challenge has no session. Clearing the parked challenge is the whole teardown; the client never leaves the user on a sign-in form while a session is live, and a cancel that arrives while a verification could still establish a session defers to it.
- Backup codes are shown once and parked first. The client writes them to a process-lived holder before showing them and sweeps it whole on discard or completion; copied codes are marked sensitive to the clipboard preview, and the screen is protected from screenshots while it shows them.
- Sign-out scrubs every surface outside the app UI: launcher widgets, dynamic and pinned shortcuts, offline cache files, clipboard clips the app made, pending pre-selections and the WebView cookie jar. One surface's failure must not wedge another, and the coordinator is resolved eagerly so the scrub runs at all (constraint). What Android does not let the app clear at once is listed in known limitations.
- Commissioning secrets stay in memory. The Matter setup passcode and the Thread operational dataset, which contains the network key, are mapped and never logged.
Failure modes
| Symptom | Cause |
|---|---|
| Every federated user is suddenly an ordinary member | The roles claim name is wrong, or its values name no role here. Read the role-sync audit entry. |
| A user shows a new role but can do nothing until re-login | Roles were loaded without permissions, so an empty set went into the session. |
| Federated sign-in refused with "ask an administrator to attach this identity" | The matched account has a password, or the e-mail already belongs to an account. |
| Federated sign-in fails now and then with 503 "OIDC is disabled while the host is running in safe mode", or the login page shows only the password form with no provider button | One replica is in safe mode and the balancer sent that step of the flow, or the login page's options request, to it. Reloading usually lands elsewhere; bring the replica out of safe mode from the Cluster tab. |
| Two accounts for one person | The subject matched no link and no authoritative e-mail matched an account, so the identity was auto-provisioned; a provider username never selects an account. Resolve the duplicate and attach the link by hand. |
| An administrator's password sign-in works now and then although local login is disabled | The request landed on a replica in safe mode, which admits administrators. Each one is audited as auth.login.safe_mode_bypass. Members get 403 on every replica. |
| Sign-in answers 429 "Too many failed sign-in attempts from this address" | The source address used up Auth:Lockout:MaxAttempts (five) inside its window (fifteen minutes). Retry-After gives the seconds left. |
| Every user is refused with 429 at once after a few wrong passwords from anyone | Forwarded headers are not trusted for the proxy in front, so every client counts as the proxy's address. The log warns that X-Forwarded-For from the proxy was ignored; turn forwarded headers on (the Compose and Helm defaults) and, if the proxy is outside the private ranges, add it to the trusted networks (TRUST_SUBNETS, forwardedHeaders.trustedNetworks). |
Every user is refused with 429 at once, and no warning about an ignored X-Forwarded-For |
The header was applied, but the entry ForwardLimit hops from the right is a proxy's for every client: a hop in front of the ingress is not counted, or a TCP proxy without PROXY protocol hides the client. An uncounted HTTP proxy that is trusted shows as the warning that the counted address is in the trusted networks while X-Forwarded-For still names an earlier hop. The blocked address in the auth.login.blocked audit entry, and in the backend's "Password sign-ins from {address} are blocked" log line, is then one of your own proxies or nodes. Count every hop in ForwardLimit, trust each one, and pass the client through TCP proxies with PROXY protocol. |
A federated user's requests answer 503 with Retry-After for a while and then work again without signing in |
The identity provider was unreachable or slow when the session's access token lapsed. The session and its refresh token were kept, and the web client retried rather than sign the user out; the log says "OIDC refresh of session {fingerprint} failed; the session is kept". |
| Federated users are signed out when their provider token lapses | The provider answered invalid_grant: the refresh token was revoked, or spent by a replica that crashed mid-refresh. The log names the session by its fingerprint and says the provider refused it. |
A write or a realtime connection answers 403 with cross_site_request_refused |
A page from another site or port of the same host sent it with the user's session. If that page is yours (a dashboard on another port, a second frontend), add its origin to Cors:AllowedOrigins. |
| A second-factor screen stops accepting codes | Five wrong attempts destroyed the challenge; repeat primary sign-in. |
| Passkeys stop working after a domain change | The relying-party id is part of the credential. Re-enrol. |
| Passkeys refuse with "not configured" | No relying-party configuration; the server declines the method rather than faking it. |
| Passkey sign-in fails on every attempt with no configuration error | An origin is mistyped in a way that is not detectably malformed. Compare the refused origin named in the log with the configured list. |
| Sign-in forces a password change | The bootstrap administrator credential is flagged must-change and issues a short-lived, single-purpose change token instead of a session. |
| A mistyped password signs the user out mid-dialog | The request was not flagged as a credential re-check, so the client's 401 handler tore the session down. Flag endpoints that answer 401 about a credential inside an authenticated session. |