Authentication
UnauditedDieser Inhalt ist noch nicht in deiner Sprache verfügbar.
The server can prove a request comes from a session it issued, not who the user is. The master key, held client-side, is the identity root. Every login credential authenticates a session only, and the master key never derives from, and is never visible to, the credential verifier. Endpoint shapes and status codes are in Authentication and devices.
Account Types
Section titled “Account Types”- Registered accounts have a unique identity and their own master key, and sign in with password (+ optional TOTP) or OIDC (Choosing an Auth Path).
- Delegated/sponsored accounts have their own keys, wrapped under a random per-sponsoree KEK that the sponsor’s master key wraps, and no recovery path of their own. The sponsor authenticates and manages them and has full access (Key Management — Delegated/Sponsored accounts).
- Non-registered accounts have no identity or master key: share links (Share Links) encapsulate keys to the link secret, and web-upload links (Web Upload) let a guest seal to a link-scoped key with no read access.
Creating an Account
Section titled “Creating an Account”Registration takes an address, a password and the account’s identity anchor, and signs the caller in with a token pair.
- No display name, username or invitation code: the server stores as little about a person as it can. The anchor is a public key the device directory publishes anyway, not a fact about the person.
- Passwords have a 12-character floor and no composition rule, because they guard a session, not the master key.
- A taken address is
409 error.auth.user_already_exists, an account oracle by decision, bounded by the per-source registration budget (Authorization — Rate Limits). Every attempt whose body parses, refused ones included, is charged, so probing costs the prober whatever the answer. - Open registration needs a default quota. The server refuses to start with password registration enabled and no default quota limit, unless the operator sets the default to
unlimitedexplicitly (Quota — Thresholds and States), so accounts minted for free cannot fill the disk. - A new account has no device directory and therefore cannot write (invariant 7 of Validation Invariants — Server-Side Validation Invariants), so the client publishes its first directory immediately after registering (Device Enrollment — First-Device Enrollment).
- There is no token introspection, since the session ledger is read on every request and validation is the request. There is no password reset, since the server cannot re-wrap a master key it never saw; recovery is the escrow blob (Backup and Recovery).
The Identity Anchor
Section titled “The Identity Anchor”The anchor is the User IK public key (Key Management — User Identity Keys (User IKs)) that every directory publish and every global sign-out verifies under (Key Management — Device Directory). Whoever sets it owns the account’s write identity for the account’s life, so no credential the server verifies may set or change it after the fact.
- A password account is anchored at registration. The request carries the IK public key and an IK signature over a domain-separated message naming the address and this server’s origin (proof of possession). A bad proof is
400, and nothing is created. There is no window between creating the account and pinning its anchor in which a phished password can pin a different one. - An OIDC account is anchored by its first directory publish. Its first sign-in creates it before any client key exists. The window is accepted because squatting it requires the identity-provider credential, and on that path the provider is the account’s root by decision (Choosing an Auth Path).
- No sign-in credential and no operator command replaces an anchor. Neither a password, a second factor nor a provider assertion can, because the anchor exists so that a password holder cannot replace it. It changes only by a recovery-signed identity rotation (Key Management — Identity Rotation), which needs the one secret no device or server holds. The first directory publish, which must verify under the anchor, pins the recovery verification key beside it.
- An account that never publishes a directory is swept 7 days after registration. It cannot have written anything, so deleting it loses nothing and frees the address. The client persists the master key and IK before it registers, so a crash between registering and publishing resumes (“finishing setup”) rather than orphaning the anchor.
Passkeys Are Not in v1
Section titled “Passkeys Are Not in v1”No passkey surface ships. Building one is new work and reopens the rustls-only rule (Network Resilience — Transport Security), because webauthn-rs links openssl for attestation parsing.
The Second Factor
Section titled “The Second Factor”TOTP is the local path’s second factor.
- Login with a confirmed factor answers
202 Acceptedwith a challenge. No session, cohort or refresh token exists until it completes. Clients read the202from the status, and the SDK returns aLoginOutcome, never a challenge shaped like a failure. - Verifying the challenge opens the session, so the advisory
cohort_hash/device_idride that request. - A challenge is single-use. The session it opens burns it; a completed challenge is never re-armed for another code inside its 5-minute life.
- Every route that checks a code is charged twice, before the code is checked: once per challenge and once per account (Authorization — Rate Limits). The routes are verify-login, verify-enrollment and disable. The challenge is the login challenge, the pending enrollment, or the session presenting the disable. The per-challenge counter bounds one ceremony. The per-account counter bounds the loop of minting fresh challenges, which would otherwise give the holder of a password five guesses per sign-in without end. The per-account counter cannot be spent by a stranger, because every route that reaches it requires the password or a live session first.
- Enrollment requires a fresh credential (Authorization — Freshness-Gated Operations) and gates nothing until confirmed. It issues a secret and an
otpauth://URI, is refused over a confirmed factor and replaces a pending one. The confirming code is spent into the replay ledger. Without the freshness gate, a stolen access token could bind the thief’s authenticator and lock the owner out of every new sign-in. - Disabling requires a live code, not just a session, so a stolen access token cannot switch off the control.
- A code is accepted at most once (RFC 6238 §5.2) by compare-and-set on the highest step used. Parameters are fixed: SHA-1, 6 digits, 30 s step, ±1 step drift.
- The secret is sealed at rest under a dedicated server key, so a database or backup leak yields no second factor. The key is independent of the token key (Session and Access Tokens), so rotating the token key after a leak never strands a factor.
- A store outage fails sign-in closed.
- Reauthentication takes a password alone, because an existing session has already passed the factor.
The Profile Surface
Section titled “The Profile Surface”- The profile is the caller’s own id, address, optional display name and creation time: the whole of what the server stores about a person. The route has no
{user_id}segment, so reading another’s profile is unrepresentable; other accounts’ public facts are the device directory (Key Management — Device Directory). - Only the display name is editable. An absent key leaves it unchanged and an explicit
nullclears it. It is trimmed and ≤128 chars, and control characters are refused, not rewritten. - A password change authenticates with the current password and is charged as a re-authentication (Sign-In Limits). It closes every session of the account, then re-opens the caller’s. A wrong current password is
403, never401. - The login address is immutable. Changing it without proof of control of the new address is an account takeover, so the port has no method for it until such proof exists.
Sign-In Limits
Section titled “Sign-In Limits”Password guessing is bounded by counting, never by locking. An account is never locked: a lock that a stranger can trigger is a denial of service against the owner, and the owner is the one person the limit exists to protect. The budgets are in Authorization — Rate Limits.
- Per source. Login, re-authentication and registration are charged against the resolved client address (IPv4 address, IPv6
/64) on every attempt whose body parses, before Argon2 runs. This bounds both guessing and the CPU a source can spend. - Per address, a soft delay. Failed sign-ins against one presented address are free up to a small allowance. After that, each failure sets a not-before instant that doubles up to a cap, and the run decays after a quiet period; the numbers are in Authorization — Rate Limits. An attempt before the instant is answered
429 error.auth.rate_limitedwithRetry-After, without verifying the password and without being charged, so waiting is never punished. The run clears on a success or a password change. - Keyed on the address as presented, never on the account. The key is a keyed hash of the address string, so the counter store holds no addresses, and an unknown address is slowed exactly as a known one is. Keying on the account would make the delay itself the enumeration oracle that a single answer for “no such account” and “wrong password” exists to deny.
- A known device is exempt from the address delay. Every successful sign-in also returns a sign-in device token: server-signed, bound to the keyed hash of the address, and valid for 365 days. A later sign-in presenting it for the same address is charged against that token’s own small failure budget instead of the address delay. A stranger flooding an address therefore slows only devices that have never signed in to it. A thief who holds a device token for an address and is guessing its password is bounded by the token’s budget.
- Re-authentication and password change are charged per session, not against the address delay. They are performed by a session, so a stranger’s failures at the sign-in door cannot block an owner’s re-prove, and a stolen session’s guesses are bounded by that session’s budget.
- The answer is one shape. A slowed address, an unknown address and a wrong password differ only in status (
429vs401), and the429depends on the presented string alone. - Residual risk, accepted. An attacker who knows an address and keeps the delay at its cap from many sources can slow the first sign-in of a brand-new device to one attempt per delay cap. Refused sign-ins on an existing account reach its activity log, coalesced (Account Activity Log).
Choosing an Auth Path
Section titled “Choosing an Auth Path”Both paths mint the same sessions (Session and Access Tokens) and differ only in who verifies the credential. A deployment may enable either or both.
- Local auth (password + optional TOTP) is the default, with no external dependency, for personal and household servers.
- OIDC (authorization code + PKCE, Capsule as relying party only) suits deployments with an IdP or wanting SSO. Account lifecycle policy lives at the IdP.
Signing In Through an Identity Provider
Section titled “Signing In Through an Identity Provider”Authorization code + PKCE, plus the device grant (Signing In Without a Browser). No implicit or hybrid flow.
Ceremony. Authorize takes the client’s redirect_uri and binding_challenge and answers the provider URL, state and a 10-minute deadline; the client receives the redirect itself. The callback takes state, code and binding_verifier and answers exactly as password login does (token pair or 202 TOTP challenge), through the same session code.
- Redirect allow-list. Exactly
OIDC_REDIRECT_URL, or, only whenOIDC_ALLOW_LOOPBACK_REDIRECTis on (default off),httpon127.0.0.1/[::1]at any port (RFC 8252 §7.3;localhostrefused per §8.3). The redirect is stored with the ceremony and replayed byte-for-byte to the token endpoint. Refusal is400 error.auth.oidc_redirect_invalid. - Begin is rate-bounded as an unauthenticated write (Authorization — Rate Limits). It is charged per source first, so one caller cannot spend the deployment-wide buckets behind it. Then it is charged per admitted redirect host (
429 error.auth.rate_limited), and finally against the ceremony store’s capacity (503 error.auth.oidc_at_capacity). The host key is chosen after redirect validation and all refusals share one deployment-wide bucket, so a caller cannot mint counter keys. Limiter ceilings are partitioned per key kind so a flood on one surface cannot starve another. - The callback is charged per source before
stateis looked up, so the number of provider token exchanges a single source can drive is bounded even beforestatestops it. stateis single-use, burned on the first callback whatever the outcome. Unknown, spent and expired are one answer,401 error.auth.oidc_state_invalid.- Client binding defends against login CSRF.
binding_challengeis the S256 hash (43-char unpadded base64url) of a ≥256-bit client secret; a malformed one is400 error.request.malformedbefore any budget is charged. The callback comparesbinding_verifierin constant time after burningstateand before contacting the provider; a mismatch is the same401 error.auth.oidc_state_invalid. The SDK also refuses a foreignstatelocally (RFC 6749 §10.12). - ID-token checks: alg ∈ {RS256, ES256, EdDSA}, never
noneor HMAC; signature against the provider JWKS;issexactlyOIDC_ISSUER;audcontains the client id;azpif present;exp/nbf/iatwith 60 s skew;noncematches; boundedsub. Every failure is one wire code,401 error.auth.oidc_token_invalid, with detail in the log. A provider refusing the exchange is401 error.auth.oidc_exchange_failed; an unreachable one is500 error.auth.oidc_unavailable, distinct fromerror.auth.unavailable. - Discovery is lazy: first use, cached 1 day, so an IdP outage never blocks local auth. It is refused if its
issuerdiffers from the configured one (mix-up defence). Endpoints must behttpsunless the issuer is a loopback IP literal, in which case plain-HTTP endpoints must also be loopback. JWKS is refetched on an unknownkidat most once a minute, and unconditionally after an hour to drop revoked keys.OIDC_CA_BUNDLEadds trust anchors. - Accounts are keyed on
(issuer, subject), never linked by address. First sign-in creates a password-less account. A verified IdP email already held by any account is409 error.auth.oidc_address_taken; unverified emails reserve and collide with nothing. Explicit linking is a separate, out-of-scope ceremony. - A federated account is a row in the one account table with a null credential. Registering over its verified address is
409 error.auth.user_already_exists. A null credential never authenticates and is never charged to a sign-in budget. A profile with no verified address omitsemail. - OIDC ignores the password sign-in delay (Sign-In Limits), or password guessing could slow a person’s SSO too.
- A confirmed TOTP factor is honoured: the callback answers the same
202challenge. - A session’s credential instant is the provider’s. A session opened through the provider records the ID token’s
auth_timeasauthenticated_atwhen the token carries it, and the callback instant otherwise. An identity-provider session cookie therefore never counts as a fresh credential. - Re-authentication through the provider. Authorize takes an optional re-authentication flag on an authenticated request. The flag sends
max_age=0(OpenID Connect Core §3.1.2.1). Its callback MUST carry anauth_timeinside the freshness window (Authorization — Freshness-Gated Operations) and name the session’s own(issuer, subject). It then refreshes that session’sauthenticated_atinstead of opening a new session. Any other outcome is401 error.auth.oidc_token_invalid. - Scopes are fixed at
openid email.profileis not requested. server-infopublishesauth.oidc: { authorize, callback }ornull, endpoints only, never issuer or client id. Unconfigured, the OIDC routes answer404 error.auth.oidc_not_configured.
Configuration (capsule-server/src/config.rs): OIDC_ISSUER (absent = off), OIDC_CLIENT_ID, OIDC_CLIENT_SECRET (optional; absent = public PKCE-only client, RFC 8252 §8.5), OIDC_REDIRECT_URL, OIDC_ALLOW_LOOPBACK_REDIRECT, OIDC_CA_BUNDLE. An issuer without a client id, or the reverse, is a startup fault. Ceremonies live in PostgreSQL (in-memory in development), and capsule-server/compose.yaml ships a dex service (--profile oidc).
OIDC-Only Deployments
Section titled “OIDC-Only Deployments”PASSWORD_AUTH_DISABLED (default off) narrows the audited surface to the identity provider.
serverefuses it withoutOIDC_ISSUER, since a server with neither door admits nobody.- Register, login and reauthenticate answer
403 error.auth.password_disabledbefore anything else: no rate-limit charge, body validation, directory lookup or Argon2. A malformed body, an unknown address and a slowed address get the same answer. - Every local account is refused, including one created before the switch. There is no break-glass account: a named exception keeps a password door open on the account an attacker most wants, and the operator’s recovery is turning the switch off.
- Existing sessions are not revoked. A password session lives out its sliding and hard expiry but cannot re-authenticate with a password, so freshness-gated operations are closed to it. A session opened through the provider re-proves through the provider (Signing In Through an Identity Provider).
server-infopublishesauth.password_disabled: truebesideauth.oidc, so a client hides its password form. Absent meansfalse, as on a server predating the switch.
Signing In From the CLI
Section titled “Signing In From the CLI”capsule auth login --oidc is the RFC 8252 native-app flow and needs no extra server surface.
- It listens on
127.0.0.1at an ephemeral port with redirecthttp://127.0.0.1:{port}/callback. The server must enable loopback redirects, and the CLI prints that remedy on refusal. - The URL is always printed. It is also opened unless
--no-browser, only if it parses as absolutehttp(s), and on Linux/BSD only under a graphical session. - It waits ≤5 min, never past the ceremony deadline.
- Only a loopback callback carrying this ceremony’s
stateends the wait; anything else is ignored, so another local process cannot cut the sign-in short. A providererrorfor thisstateends it, anderror_descriptionis printed with control characters stripped. - The session is settled by the same function as a password sign-in, TOTP prompt included.
Signing In Without a Browser
Section titled “Signing In Without a Browser”Headless clients use the device authorization grant (RFC 8628): capsule auth login --oidc --device.
-
The server proxies the provider and the
device_codenever leaves it. Begin takes abinding_challengeand answers a server-minted 128-bithandle,user_code,verification_uri(+_completeif given),intervalandexpires_by(the minimum of the provider’sexpires_inand 15 min). -
Polling takes
handle,binding_verifierand the advisorycohort_hash/device_id. Success answers as the callback does (tokens or202). Otherwise:Provider answer Capsule answer Ceremony authorization_pending400 error.auth.oidc_device_pendingkept slow_down, or poll sooner than one interval429 error.auth.oidc_device_slow_down, interval += 5 skept access_denied401 error.auth.oidc_device_deniedburned expired_token; unknown/spent handle; binding mismatch401 error.auth.oidc_device_expiredburned other refusal 401 error.auth.oidc_exchange_failedburned unreachable 500 error.auth.oidc_unavailablekept -
The interval is server-enforced at the provider’s value, ≥5 s, and an early poll is refused without asking the provider. A client that waits one interval before every poll and adds 5 s per
slow_downstays in step. -
The ID token passes every callback check except the nonce, which MUST be absent: a token carrying a nonce was minted for another authorization request. The back-channel request with a server-held device code replaces the nonce’s binding.
-
binding_verifieris checked in constant time on every poll before the provider is asked; a mismatch burns the ceremony. -
A session, TOTP challenge, refused ID token or taken address also burns the ceremony. It is burned before the session opens, so racing polls open one.
-
No grant support (no
device_authorization_endpoint, orunauthorized_client/unsupported_grant_type) is404 error.auth.oidc_device_unsupported; other device-endpoint refusals are500 error.auth.oidc_unavailable.verification_uriis held to the endpoint scheme rule, anduser_codeto ≤64 chars with no control characters. -
Begin checks binding shape first, then the per-source begin budget, then one deployment-wide budget, then store capacity (Authorization — Rate Limits). Polls are bounded by the begin budget × one provider call per interval.
-
The CLI prints the address and code, never opens a browser, and gives up at
expires_by.
Identity and Discovery
Section titled “Identity and Discovery”Handles are [email protected] (Matrix-style). .well-known/ never enumerates users.
.well-known/capsule/server-infois public and server-scoped only: API base, auth and federation endpoints, server signing key,protocol_versionrange andmin_protocol_versioncutoffs.- User lookup is authenticated: local clients by session token, federated peers by a federation capability token (Federation — Federation Capabilities) rate-limited per peer.
- Anonymous WebFinger returns only what the user opted into (default nothing), limited to handle and display name, never keys, devices or album hints, per the deny-by-default rule (Schema Rules and Open Questions — Schema Evolution and Field Grammar).
The .well-known/capsule/* Registry
Section titled “The .well-known/capsule/* Registry”All are public and take no credential. A new path MUST add a row.
| Path | Contents | Owner |
|---|---|---|
server-info |
Server-scoped facts above. Never a user list. | Identity and Discovery |
moved/{user} |
IK-signed moved certificate (post-v1). | Account Portability |
revoked-jti |
Federation capability revocations (≤24 h). | Federation — Token Lifecycle and Chain of Trust |
deprecation |
Min-supported-client announcements. | Schema Rules and Open Questions — Min-Supported-Client Deprecation Policy |
attestation-keys |
Storage-attestation public keys + append-only history. | Durability |
Account Portability
Section titled “Account Portability”Post-v1. The User IK (Key Management — User Identity Keys (User IKs)) is already a server-independent root; only the handle is host-bound. No DID system.
- The new server registers the account under the same IK, leaving the key hierarchy unchanged.
- The old server publishes
.well-known/capsule/moved/{user},{ old_handle, new_handle, moved_at, ik_sig }, cacheable 24 h. It is the only well-known record naming a user, admissible because the user signs and initiates it. - Resolvers verify
ik_sigagainst the IK from the signed device directory (Key Management — Device Directory) and re-resolve. An unverifiable certificate is ignored (the old handle keeps resolving) and surfaced.
No server can forge a migration, because the IK signs the move.
Session and Access Tokens
Section titled “Session and Access Tokens”Both tokens are EdDSA JWTs signed with the server’s Ed25519 token key (JWT_ED25519_DER). They are classical only, per the operational-signature carve-out (Cryptographic Primitives — Signature Scheme). Each names its kind (access, refresh, or the half-finished second_factor), and every verifier takes the kind it expects, so one kind is never accepted as another.
Session ID
Section titled “Session ID”A server-generated UUIDv7 identifying the session record. It is not a secret: the record carries its creation time in the clear beside it.
Session Token
Section titled “Session Token”The refresh token: a JWT naming the account, the session id and the session’s lineage (Token Lineage and Reuse). It is stored on the client and presented only to obtain a new pair. Its expiry is the session’s remaining life (Session Expiry and Revocation).
What the server stores is not a credential. The session ledger holds session ids, lineages and timestamps, never a bearer secret. A leaked database, replica or backup therefore yields no live session on its own. The token key is the one secret that turns such a leak into every live session, so it is held as the deployment’s most sensitive secret (Self Hosting). Rotating it signs every device out.
Access Token
Section titled “Access Token”A 15-minute JWT issued against the session token, presented as the bearer credential on every authenticated request. The lifetime is fixed, not configurable: it bounds what a lost access token buys, not what a revoked one does (Explicit Revocation).
Token Lineage and Reuse
Section titled “Token Lineage and Reuse”A lineage is the chain of sessions one sign-in produces through refreshes. A refresh closes the presented session and opens its successor in the same lineage, so a refresh token is good once. The lineage id is minted at sign-in, carried in every refresh token and never moved, as the hard cap’s sign-in instant is (Hard Expiry).
- Reuse revokes the lineage (refresh-token rotation with reuse detection, RFC 9700 §4.14.2). A refresh token whose session is closed while its lineage still has a live session is a stolen or replayed token. The server closes every session of that lineage and records the event in the account’s activity log. The legitimate device and the thief both re-authenticate. Only the one who holds the password and factor gets back in.
- A lost response is retried, not punished. A client that retries a refresh within 60 s of the rotation receives a fresh pair for the same successor session, provided that successor has not itself been refreshed. Outside that window the retry is reuse.
- Refreshes are budgeted per lineage (Authorization — Rate Limits), so a stolen token cannot rotate a lineage faster than an honest client ever does.
Session Expiry and Revocation
Section titled “Session Expiry and Revocation”A session token stops being honoured on sliding expiry, hard expiry or explicit revocation, and nothing else. Expiries are enforced at access-token issuance.
Sliding Inactivity Expiry
Section titled “Sliding Inactivity Expiry”180 days (SESSION_TTL_DAYS) without an access-token issuance. Each issuance resets the clock; activity alone does not, since a request records last-used time and never extends the session.
Hard Expiry
Section titled “Hard Expiry”365 days (SESSION_HARD_CAP_DAYS) from sign-in, never reset. It caps the window for a silently exfiltrated token on an active device (the malicious keyholder of Threat Model — Client Class Taxonomy).
Both are whole days, set per deployment and never per session. Zero, a negative count, or a cap shorter than the sliding window refuses the boot as a configuration fault. A stored session keeps the deadline it was opened under, so a changed value applies from its next refresh. A lowered value then refuses a session idle longer than the new window, or a lineage older than the new cap, as expired, and rotates one inside both with only what the new values leave it. A raised value lengthens nothing until that refresh.
Invariants:
- The cap survives rotation. The session record carries its lineage’s sign-in instant; a refresh carries it forward unchanged and a re-authentication does not move it.
- A session lives until the earlier of the two expiries, and its refresh token is issued for exactly that remaining life, never a whole window past the cap.
- A deploy never shortens a live session. A record that predates the sign-in instant measures its cap from its own creation.
Explicit Revocation
Section titled “Explicit Revocation”The session ledger supports:
- List active sessions with last-used time.
- Revoke one session, authenticated by any active session token.
- Revoke all, authenticated by proof of master-key possession, not a session token, so a stolen token cannot lock the user out of every device.
Revoke-all is two requests. An authenticated POST /v1/auth/logout/all/challenge issues a single-use challenge; it is authenticated so it is not an account-existence oracle. An unauthenticated POST /v1/auth/logout/all redeems an IK signature over a domain-separated message containing it, verified against the account’s identity anchor (Key Management — Device Directory), never a request-supplied key. The challenge is burned on every attempt.
Invariants:
- Revocation is immediate. The bearer scheme reads the ledger on every authenticated request, so an in-flight access token is refused on next use. The access-token lifetime bounds a lost token, not a revoked one.
- An unreadable ledger refuses (fail closed) with
503 error.auth.unavailableandRetry-After, never401. A client that read an outage as an expiry would discard a live session and send its user to a sign-in that cannot succeed until the store is back (Authorization — When the Counter Store Fails). - Last-used is coarse: at most one write per minute per session.
- Nothing revokes a session automatically except reuse. The server never revokes on a heuristic, because that bypasses the user-initiated audit trail. The one automatic revocation is a lineage whose refresh token was replayed (Token Lineage and Reuse), recorded in the account’s activity log.
- An operator can revoke, and it is recorded. On a confirmed server-side compromise the operator has two levers. One is a maintenance command that revokes every session of one account or of all accounts, recording an operator-revocation event in each affected account’s activity log. The other is rotating the token key, which invalidates every token at once. Neither touches keys, directories or data, so the user’s own revoke-all remains the only path that proves master-key possession.
Device Cohorts
Section titled “Device Cohorts”Reinstalling re-enrolls with a new device_id, because device keys are hardware-bound (Metadata — Add-id Binding), so one phone accumulates ledger entries. The cohort hash groups sessions from one physical device and is a grouping aid only.
Per-Platform Primary Identifier
Section titled “Per-Platform Primary Identifier”| Platform | Primary identifier | App reinstall | OS reinstall | Factory reset |
|---|---|---|---|---|
| iOS | Keychain random 128-bit seed, ThisDeviceOnly, non-synchronized |
yes (not guaranteed) | no | no |
| Android | SSAID (signing-key-scoped ANDROID_ID) |
yes | no | no |
| macOS | IOPlatformUUID |
yes | yes | yes |
| Windows | MachineGuid |
yes | no | no |
| Linux | /etc/machine-id (only ever hashed) |
yes | no | no |
The promise is reinstall-stable everywhere, reset-stable only on macOS. A factory-reset phone is a new cohort.
Encoding
Section titled “Encoding”cohort_hash = SHA-256( canonical-CBOR([ "capsule-device-cohort/v1", user_id, platform_tag, primary_id ]) )The input is canonical CBOR (Metadata — Canonical CBOR Encoding) with a closed platform_tag enum. user_id is folded in so one device under two accounts yields unlinkable hashes. It is implemented once in capsule-core (cohort).
Privacy and Scope
Section titled “Privacy and Scope”- Sent only in the session-opening request body, and registered in the header census (Validation Invariants — Universal Headers) as a body field. Never in signed artifacts, to federated peers or in
.well-known. - Advisory only. It is client-asserted and unverifiable, so no authorization or capability decision may read it, and it never substitutes for
device_idor the DSK. Absent or garbage values behave identically to valid ones.
Server Storage and Surfacing
Section titled “Server Storage and Surfacing”- The session record carries
cohort_hash, and a durabledevice_cohorts(user_id, cohort_hash, first_seen, last_seen)map outlives session expiry. - Recording a cohort never fails a sign-in: it is written after the session, and a failure is logged and dropped.
- It appears only in the session listing. There is no filter by cohort and no “revoke cohort” verb; revocation names a
session_id. - The UX asserts (“a device you’ve used before, last seen date”) with no “not my device” toggle. Disputes go through a support report bundling
{cohort_hash, [(device_id, session_id, first_seen, last_seen)]}.
Known Gaps
Section titled “Known Gaps”- The server still locks an account after repeated failed sign-ins:
AccountLockedanswers423(capsule-server/src/routes/auth.rs:436), charged against the per-accountLOGIN_ATTEMPTSbudget of 5 failures in 15 minutes (capsule-server/src/counter/budgets.rs:21). The per-address delay and the sign-in device token that replace it are not implemented. - Refresh rotation detects no reuse: no lineage claim or reuse check exists in
capsule-server/src, so a replayed refresh token is not caught and no lineage is revoked (Token Lineage and Reuse). - An unreadable session ledger is not answered
503withRetry-After; the server answers500or401today (Authorization — When the Counter Store Fails). - TOTP enrolment and the escrow
PUTcarry no freshness gate (Authorization — Freshness-Gated Operations), and TOTP secrets are stored as plaintext base32 (capsule-server/src/auth/totp/postgres.rs:136) rather than sealed at rest. - The operator session-revoke maintenance command does not exist.
- Registration carries no identity key or proof of possession, and no sweep removes accounts that never publish (The Identity Anchor; invariant 37 in Validation Invariants).
Validation
Section titled “Validation”- Token round-trip (unit): session token → access JWT → verify; after key rotation, old JWTs verify within their grace window.
- Expiry (unit, mock clock): sliding refreshes on each issuance, hard does not and survives rotation; rejection happens at access-token issuance.
- Revoke-all (unit): rejected without master-key proof; with it, every other session is invalidated.
- Revocation immediacy (unit): a revoked session’s live access token is refused on next use.
- TOTP:
202on a confirmed factor; code replay refused; per-challenge and per-account caps on verify-login, verify-enrollment and disable; a completed challenge cannot open a second session; enrollment refused on a stale session; the stored secret is not its base32 plaintext; store outage fails closed. - Identity anchor (integration): registration without a valid proof creates nothing; a publish under a different IK after registration is
403; an account with no directory is swept after its window and one with a directory never is. - Sign-in limits (unit, mock clock): the per-source budget trips before Argon2 runs; the address delay doubles to its cap, refuses without verifying or charging, decays and clears on success; a known and an unknown address are slowed identically and answer byte for byte alike; a valid device token for the address bypasses the delay and one for another address does not; re-authentication failures never slow the address; a parallel burst is admitted at most the allowance.
- Lineage (unit): a replayed refresh token closes every session of its lineage; a retry inside the grace window returns the same successor; a retry after the successor rotated is reuse.
- OIDC freshness (integration): a callback whose
auth_timeis outside the window does not make a session fresh; re-authentication for another(issuer, subject)is refused. - OIDC (integration): an in-process loopback mock provider (offline, container-free) covers key rotation, the refetch floor, a wrong PKCE verifier, every claim refusal, binding mismatch and each device-grant answer; gated round trips run against dex (
CAPSULE_TEST_DEX=1). - Account portability (smoke, post-v1): moved certificate from A; B registers the same IK; peers follow the move.
- Cohort: cross-language known-answer vectors; the same
primary_idunder twouser_ids gives distinct hashes; absent, malformed and colliding values behave identically; a tripwire asserts no signed schema has a cohort field; the durable map outlives sessions.
The auth → library-query E2E case is in the E2E case index.
Related
Section titled “Related”- Authorization: the closed lifecycle-action set every write proves against.
- Device Enrollment: how a device joins the account and the device directory (Key Management — Device Directory).
- Backup and Recovery: recovering the master key after device loss.