Admin API authentication
Admin API access is controlled at the network level. The admin interface is bound to your provisioned endpoint and protected by your Myra Security account credentials. Inference endpoints use a bearer-token model described below.
Admin API
Security posture
All endpoints under /admin/v1/ are accessible to authenticated operators via your Myra Security account. The admin API is intended to be called by the admin UI or from automation scripts on your management network.
💡 Note: For on-premise deployments, bind the admin listener to an internal network interface and restrict access to trusted hosts. Do not expose the admin API directly on a public interface without network-level controls in place.
Authentication comes before the request body is read. An unauthenticated request to /admin/v1/ is answered 401 without its body being read, regardless of size. For an authenticated request the body is read once, right after authentication, so a client that disconnects mid-request is noticed even when the body is larger than about 1 KiB; long-running endpoints then stop work that no one is waiting for. The few endpoints that authenticate themselves (the anonymous browser error report, the key-pool alert bot, the growth bearer endpoint) are not pre-read and keep their own checks.
Session errors. The admin session is the aig_admin cookie. When it is missing or rejected, /admin/v1/*, GET /admin/auth/me, PATCH /admin/auth/me, POST /admin/auth/renew and POST /admin/auth/impersonation/start answer 401 with a JSON body {"error": "<reason>"}. The reason is always one of a fixed list, never text taken from the request: unauthenticated (no cookie, on any of these routes), or, for a cookie that fails verification, one of missing token, malformed token, invalid signature, base64 decode failed, json decode failed, payload not an object, missing exp claim, token expired, token not yet valid, not a session token, ci token rejected or malformed amr claim. A rejection that carries no reason is answered invalid token; a reason outside the list is answered with the generic invalid_token. On /admin/v1/* a valid session whose account is gone, deleted or disabled is answered account not found, deleted, or disabled, and a revoked session session revoked. A backing-store fault is 503 with temporarily unavailable (see below). No new verify reason exists for the password sign-in: a pending sign-in token presented as the cookie is malformed token, and a session refused for lacking a second factor answers 403 mfa_session_required (see Password and second factor sign-in), not one of the 401 reasons.
Transient faults never invalidate a session. Every authenticated admin endpoint (and the sign-in endpoints below) distinguishes a definitively missing, deleted or disabled account (401/403/404, and for the session routes a cleared cookie) from a transient backing-store fault, which returns 503 with a retryable error body (on the browser sign-in routes otp/request, otp/verify, otp/verify-link the 503 is sent only when the storage layer says the fault is retryable: 503 { "error": "temporarily unavailable; retry later" } with Retry-After; any other fault, including one that cannot be classified, answers the JSON 500 { "error": "internal error" } with the CORS headers, no session cookie and nothing counted; a plain, non-break-glass otp/request still sets its login-binding cookie, the same for every address). A 503 sets or clears no session cookie, increments no failed-attempt counter and records no denial in the audit log — clients should retry with backoff (a fault answer (503 or 500) on POST /admin/auth/otp/request has already spent one of the ten request-cap slots, because the cap is checked before the lookup). One deliberate exception: on POST /admin/auth/otp/verify-link a fault while the account is re-loaded after the link was consumed answers the same 503 or 500, but the link is spent: a retry answers 400 invalid_or_expired, so request a new code instead of replaying the link. Another: on POST /admin/auth/otp/verify a fault that hits after the code was accepted (while the account is being loaded) has already consumed that code — the client should request a fresh one rather than replay it. One more deliberate exception: on PUT /admin/v1/me/password a fault after the current password was counted leaves that guess counted, and a session that cannot be minted after the password commit answers 503 (403 tenant_suspended for a suspended workspace) with no cookie although the password changed. A backing-store fault can never authenticate a request either; the gate fails closed.
Cross-origin requests (CORS)
The admin API has one cross-origin policy, the same on every route. Credentialed cross-origin reads are granted to exactly one origin: the one the operator configured for the admin UI (AIG_ADMIN_CORS_ORIGIN). An answer carries Access-Control-Allow-Origin: <that origin> together with Access-Control-Allow-Credentials: true, whatever Origin the request sent. The request's Origin is never echoed and * is never used. A foreign site therefore cannot read an admin response with the user's session cookie, even when it hits a route that answers 200.
When no origin is configured (the usual same-origin deployment, where the UI and the API share a host), neither header is sent, on any route and for the OPTIONS preflight alike. A preflight answers 204 with Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS, and the pair only when an origin is configured. Same-origin browsers and non-browser clients (scripts, curl) are unaffected: CORS only restricts cross-origin browser reads.
Browser sign-in endpoints
Every error answer of these endpoints (and of every other /admin/… route) carries X-Request-Id and
exposes it to the browser app, which shows it in the copyable support reference under the error — see
Error codes › Request id on admin errors.
The browser sign-in flow uses a passwordless one-time-code (OTP) exchange. These endpoints are reachable without a prior session (they establish or read it):
| Method | Path | Auth | Description |
|---|---|---|---|
POST |
/admin/auth/otp/request |
Public | Request a one-time sign-in code for an e-mail address. Always returns a generic success message regardless of whether the address is registered. The e-mail carries the code and a one-click sign-in link; if that link cannot be built as a clean http(s) link, the e-mail carries the code only (the failure is logged, never shown). A domain allow-listed by enabled configurations of two organisations is never resolved to one: it counts as no single sign-on (logged on the server) and the code is sent. Single sign-on discovery fails closed: after the address check and the request cap, the server checks the address's domain against the enabled single sign-on configurations (the same discovery as POST /admin/auth/sso/lookup). If that configuration cannot be read (database fault), no code is sent and the answer is 503 { "error": "single sign-on settings unavailable, try again", "code": "sso_lookup_unavailable" } with Retry-After: 5 — an unreadable configuration is never treated as "no single sign-on". The answer depends only on the domain, never on whether the account exists, and the request-cap slot is spent (the cap is checked first). A domain that does have single sign-on still receives the code: the login page offers single sign-on, it does not enforce it (every account can use the e-mail code; see Sign in) — so until single sign-on is enforced this check adds no security; it is an explicit fail-closed policy: e-mail sign-in is unavailable while the single sign-on configuration cannot be read. Optional remember_me (boolean): the "stay signed in 30 days" choice is persisted on the code row so a sign-in completed via the magic link (which carries no form state) honours the same preference as typing the code; only a literal true is stored (absent or any non-true value fails closed to a short session). Address shape: the email is canonicalised (surrounding whitespace trimmed, ASCII letters lower-cased) and must be printable ASCII with no inner whitespace and exactly one @; a value that is absent or empty is 400 { "error": "email required" }, one that is malformed (a non-ASCII or control byte, inner whitespace, no single @, or a raw length above 254 bytes) is 400 { "error": "…", "code": "invalid_email" } — nothing is stored or sent in either case. Prior codes stay valid (keep-live): a request does not invalidate earlier unused sign-in codes for the address — a resend no longer strands a user who then enters the first email's code. Only DEAD codes (already used, expired, or guess-budget-spent) are purged on a new request, so a few codes can be live at once — at most 3 live sign-in codes per address, newest wins: the request that would leave a fourth deletes the oldest live code(s) in the same step (so after four requests the first mail's code no longer signs in, its magic link too). The creation time has one-second resolution: codes requested within the same second are kept in an unspecified but stable order, so "newest wins" holds for requests at least a second apart. Used, expired and guess-budget-spent codes do not count toward the 3. If that clean-up fails, the new code is withdrawn and the request answers the transient 503 (no mail). Codes are scoped by purpose (the cancellation page's confirmation codes are a separate set that a sign-in code never verifies and a sign-in request never purges or counts toward the cap — they stay uncapped, see Billing). All live sign-in codes for the address share one guess budget — every wrong guess counts against every live code — and a successful sign-in, via either the typed code or the magic link, retires every live code and link for the address so no stale sibling can mint a second session. The request and hourly caps bound the episode. (This replaces the former newest-only behaviour, where a resend deleted the prior code; the residual — up to 3 previously-issued sign-in codes stay live until expiry (≤ the code window), a successful sign-in, or the 4th request retiring the oldest, rather than being killable by a single resend — is bounded by the cap; the cancellation codes stay uncapped.) Cap: at most 10 requests per address per code window — a 429 { "code": "otp_request_cap" }, identical for a registered and an unregistered address. There is deliberately no per-client-IP cap on this route: the client address is taken from X-Forwarded-For, which a caller can set, so a per-IP cap on the primary sign-in would be a lever against a chosen office's egress address while bounding nothing. The code window is a deployment setting (default 900 s; 60–86400, out-of-range values fall back to the default). A database fault in the account lookup returns a fault answer, 503 when retryable and 500 otherwise (no code was stored — request again; the request-cap slot is still spent, the cap is checked before the lookup so a registered and an unregistered address answer alike). Blocked accounts are told by e-mail, never in the response. When the address belongs to an account that cannot sign in, no code is minted and the response is the same generic 200 (status, body and headers byte-identical to an unregistered address), but the stored address receives an account-deactivated notice: "your account has been deactivated" (soft-deleted account — an administrator delete, a SCIM deprovision, or a tenant deleted together with its users — or a live account of a soft-deleted tenant) or "your account has been disabled" (an administrator disable), asking the person to contact their organisation administrator. A sign-up link is offered only where a new account would be accepted: for a deleted member of a self-serve workspace whose address holds no one-free-trial lock — a teammate who never started a trial, or a registrant whose lock a platform-admin delete released — and while self-serve sign-up is on, the mail also links to /signup. There is no sign-up link for a member of a managed (non-self-serve) workspace, a disabled account or a member of a deleted workspace (the address is still in use), or when the trial lock is still held (a tenant-admin delete of the registrant), cannot be read, or sign-up is off. Never mailed: an unregistered address, an account the person deleted themselves, an erased account (Art. 17 erasure or tenant purge — no row remains), a reclaimed address (its old row was renamed on re-registration), and an accent / homograph variant of a blocked address. The mail goes to the stored address, in the mail language, under the tenant's product name (the platform default name once the organisation itself was deleted). Limits: the request cap above applies first (the eleventh request in a window is the same 429 for every address), and the notice itself is sent at most once per address per 24 hours (otp_deact:<address>; like every auth counter it is held per gateway node, so a multi-site deployment sends at most one per node). The once-per-day limit is silent: a request over it gets the same 200 and simply sends nothing. The day's notice is counted when it is scheduled, so a notice that could not be delivered (the mail relay failed, the server was busy or restarting — logged on the server) is not retried for that address until the day is over. Fail-safe: a fault while looking up the blocked account sends nothing and still answers the generic 200. Timing: the blocked-account lookup runs for every address the sign-in lookup did not resolve to a code-receiving account (unregistered, blocked and static-code accounts alike), and the mail is rendered and sent after the response, so the request does the same database work for an unregistered and a blocked address; the only extra step for a blocked address is scheduling the background send (microseconds). (A registered, code-receiving address does more work — the code is stored before the answer — as it always has.) Browser binding: every request that passes the address check, the request cap and the single sign-on check (known, unknown and blocked addresses alike — no existence oracle) gets a Set-Cookie: __Host-aig_login_nonce=… and the magic link in the mail is bound to it — see Magic-link browser binding. Password sign-in (password_mfa): while one of the sign-in flags is on, a person whose organisation signs in with "Email + password + second factor" and who has a password gets no code and no mail: 200 { "message": <the generic text>, "next": "password" }. A person without a password still gets the code (first setup). A fixed-code account in such an organisation never gets next and no code (the generic 200). On a single sign-on domain a break_glass: true request never carries next (details). A sign-in flag that cannot be read answers 503 { "error": "temporarily unavailable" } before anything is looked up, for a known and an unknown address alike; a fault while reading the person's sign-in option or password row answers the same 503 with no code. |
POST |
/admin/auth/otp/verify-link |
Public | sign in via the single-use magic link instead of typing the code. Body { token } — a 43-char base64url token that rides the login email's URL fragment (/login#token=…) and is POSTed by the SPA (never a GET, so the token never reaches nginx access logs or the Referer header). On success sets the same aig_admin session cookie and returns the same { "user": … } payload as /otp/verify, through the identical success tail (full-row re-resolve → login_blocked gate → real-iat session). Session length honours the "stay signed in" choice the user made at /otp/request (stored on the code row): a fresh-browser link click carries no checkbox, so the stored preference is the only signal — a stored remember_me yields the 30-day session, an absent (legacy/NULL) or malformed stored value fails closed to the standard 8-hour session (a crafted row can never mint the longer one). ABSENT, malformed, unknown, expired and already-used tokens all return the one generic 400 { "error": "invalid_or_expired" } — no enumeration oracle (invariant 11); a transient DB fault is 503, never a definitive 400 on a valid token. Single-use: a successful verify sets used_at and NULLs the token, so a replay is inert and the 6-digit code on the same row is also consumed (exactly one of {link, code} wins). because sign-in codes are now keep-live (a resend can leave several live), a successful link verify retires every live sign-in code and link for the address, not only the token's own row — so a sibling code/link cannot survive the real sign-in. A coarse global ceiling (otp_link_global) bounds random-token load; no per-IP cap (the X-Forwarded-For rationale), and the 256-bit token makes guessing infeasible. Static-OTP accounts mint no link. Bound to the requesting browser: the link signs in at once only in the browser that asked for it (its __Host-aig_login_nonce cookie); opened anywhere else the answer is 428 link_confirm_required with the account email and nothing is consumed — the app shows a confirm page and only a second POST with "confirm": true signs in (then with the short default session: the stored 30-day choice belongs to the browser that ticked it); a malformed or another browser's cookie is 403 link_other_browser and never signs in. Details, accepted shapes and every answer: Magic-link browser binding. Password sign-in (password_mfa): a person with a password, and every fixed-code account, in an organisation on "Email + password + second factor" gets 403 { "error": "password sign-in required", "code": "password_signin_required" } and no cookie; a person without a password gets the setup answer 200 { "pending_token", "purpose": "setup", "next": "create_password", "expires_at" } (Cache-Control: no-store) and no cookie. Either way the link is used up. A sign-in flag that cannot be read answers 503 { "error": "temporarily unavailable" } before the link is redeemed (it stays valid). A 503 after the link was redeemed (the person's sign-in option or password row cannot be read, the setup token cannot be stored, or the account re-resolve faults — 503, or 500 { "error": "internal error" } when the fault is not retryable) means the link is spent: request a new one. |
POST |
/admin/auth/otp/verify |
Public | Verify the e-mailed code. On success sets the aig_admin session cookie and returns that full account payload nested under a top-level user key — { "user": { … } } — whose object matches GET /admin/auth/me field-for-field (including the tenant flags such as tenant_pii_masking_enforced and tenant_workflows_enabled). Note the shape difference: /me returns the account object bare, this route wraps it, so seed your cached user from response.user, not the response root. Optional remember_me extends the session. The 200 carries Cache-Control: no-store, so no browser or proxy cache replays the account payload as a fresh sign-in. The email follows the same canonical shape as /otp/request (400 invalid_email when malformed); the code must be a string or a number — an absent, null, boolean, object or array code is 400 { "error": "email and code required" } and is never counted as an attempt. Code shape (checked first): the code is read before any counter, database read or hash — a value whose raw length is above 64 bytes is 400 { "error": "email and code required" }; otherwise it is trimmed of surrounding ASCII whitespace (space, tab, line feed, vertical tab, form feed, carriage return) and must be 4–32 bytes long, else 400 { "error": "invalid or expired code", "code": "invalid_otp" }. Neither answer is counted as a guess, and the work is linear in the body size. Per-code budget: five wrong guesses exhaust the code — the sixth and later attempts return 429 { "code": "otp_attempt_cap" } until a new code is requested (the same code is returned for an address with no live code, registered or not). Hourly ceiling: twenty rejected verification attempts per address within an hour — every wrong guess and every attempt answered 429 otp_attempt_cap, across codes — return 429 { "code": "otp_failure_cap" } until the hour has passed; a fresh code does not lift it, a successful sign-in clears it, and a 503 or 500 counts nothing. A valid code for a removed account returns 403; a transient database fault returns 503 (before the code was checked: nothing consumed or counted; while loading the account after the check: the code is consumed — retry with a fresh one) — no cookie is set in either case (in the account lookup a non-retryable fault is 500 { "error": "internal error" }; see Sign-in database faults). Password sign-in (password_mfa): a person with a password, and every fixed-code account, in an organisation on "Email + password + second factor" gets 403 { "error": "password sign-in required", "code": "password_signin_required" } (the code is consumed, no cookie); a person without a password gets the setup answer 200 { "pending_token", "purpose": "setup", "next": "create_password", "expires_at" } (Cache-Control: no-store, no cookie). The sign-in flags, the person's sign-in option and the password row are read before the code is checked: a fault there is 503 { "error": "temporarily unavailable" } with nothing consumed or counted. If the setup token cannot be stored after the code was accepted, the answer is the same 503 and the code is spent: request a new one. |
GET |
/admin/auth/me |
Session cookie | Return the signed-in user's profile. 401 if the session is missing or invalid (cookie untouched) or the account was deleted or disabled (cookie cleared). A transient database fault returns 503 and leaves the cookie untouched — retry. The payload carries session_expires_at (unix seconds — the current session's expiry), which the app uses to drive sliding session renewal; it is absent while impersonating (the impersonation payload carries no session of its own). The same payload carries session_auth_time (unix seconds — when the current session was minted: the original-login time, which renewals preserve; the token's issue time for an older token). The app uses it, never its own clock, to tell a genuinely new sign-in from a stale confirmation when it measures lost sessions (see [session-lost-early]); it is absent while impersonating and when the token carries neither claim. GET /admin/auth/me and PATCH /admin/auth/me answer 200 with Cache-Control: no-store, so no browser or proxy cache replays an account payload as a fresh sign-in. It also carries handover_pending — a JSON array (never an object) of the agents handed over to the caller that still await confirmation, [{ "gateway_id", "agent_id", "name", "handed_over_at" }], newest first and capped at 50. It is derived live from the agents themselves (no stored flag), so it empties as soon as each agent is confirmed (the agent detail route names the successor in its successor object, see there); it lists only the caller's own tenant and own agents, is an empty array while impersonating, and degrades to [] (with a server warning) if the lookup fails. It also carries protection_paused — a JSON array (never an object) of the caller's own agents that are currently paused by automatic protection, [{ "agent_id", "gateway_id", "name", "paused_at", "signal" }] (paused_at in unix seconds, signal is deny_burst, volume_spike or approval_rejections, or null if the stored evidence cannot be read), newest first and capped at 50. It is derived live from the agents (no stored flag), so it empties once the agent is resumed; it lists only the caller's own tenant and own agents, is an empty array while impersonating, and degrades to [] (with a server warning) if the lookup fails. It also carries plan_change_enabled — a JSON boolean, true only when the plan change is switched on and the caller's workspace is on its allowlist (absent or malformed settings read false); present only for a caller who may buy (the workspace owner or a holder of BILLING_PURCHASE) and omitted for any other member and for an account with no workspace, so a plain member cannot learn whether the change is enabled; still present while impersonating a caller who may buy; if the caller's custom-role permissions cannot be read, a delegated holder sees the field omitted (the owner is unaffected). |
GET |
/admin/v1/me/notifications |
Session cookie | Re-poll of the notification fields of GET /admin/auth/me, so the bell and banners refresh without re-reading the whole account payload. For a plain member this costs a handful of database statements (about six); an administrator additionally pays for the budget-alert computation, so the route is cheaper than /me but not free for admins. Returns { "budget_alerts", "budget_alerts_sig", "budget_alerts_muted", "failing_runs", "expiring_tokens", "handover_pending", "protection_paused", "protection_warnings", "config_approval_outcomes" } (config_approval_outcomes: the caller's own four-eyes requests decided in the last 7 days), each list a JSON array (never an object), plus config_approval_outcomes_seen_up_to (unix seconds, omitted when never set and while impersonating: outcomes whose outcome_at is at or before it were acknowledged and no longer count toward the badge). Both routes are built by one shared builder, so the values are identical to those on /me under the same rules, including the dismissal state budget_alerts_muted (computed against the signature the caller dismissed). While impersonating the personal lists (failing_runs, expiring_tokens, handover_pending, protection_paused, protection_warnings, config_approval_outcomes) are [] without being read, and budget alerts are masked as on /me (see impersonation). A failing lookup degrades that list to [] with a server warning. The route takes no input: query parameters are ignored and there is no request body. Without a valid session it answers 401 { "error": "unauthenticated" } (no cookie), 401 { "error": "session revoked" }, 401 { "error": "account not found, deleted, or disabled" }, a 401 with a token error from the session errors listed above (the cookie does not verify), or 503 { "error": "temporarily unavailable" } (a transient fault, including a failed impersonation-session lookup while an impersonation cookie is present; nothing is granted, retry), or 503 { "error": { "code": "service_starting", "message": "Service is starting: schema migration in progress. Retry shortly." }, "code": "service_starting" } with Retry-After: 2 (the readiness gate during a schema migration; retry shortly); 200 carries Cache-Control: no-store. The field allowance_used_pct is not part of either payload. |
POST |
/admin/v1/me/notifications/config-outcomes-seen |
Session cookie | Acknowledge the caller's config-approval outcomes in the bell up to { "seen_up_to": <unix seconds> }. Acknowledged outcomes stay listed but leave the badge. The marker only moves forward. A future, malformed or absent value is a 400, and the call is refused while impersonating. Accepted shape and every answer: Config approvals. |
POST |
/admin/auth/renew |
Session cookie | Sliding session renewal — silently re-anchor the current aig_admin session's expiry to now + the original window so a long, active session never crosses exp and hard-redirects to /login mid-stream. On success sets a fresh aig_admin cookie and returns { "ok": true, "renewed": true, "expires_at": <unix seconds> }. See Sliding session renewal for the accepted input, the fail-closed rejects, the throttle, and the auth_time claim. |
PATCH |
/admin/auth/me |
Session cookie | Update the caller's own profile (locale, preferred name, work category, model instructions, one-shot UX flags). The response is the same full account payload as GET /admin/auth/me (including the tenant flags such as tenant_pii_masking_enforced), so a client can replace its cached user with the response without dropping any field. Refused while impersonating: during an active impersonation the call answers 409 { "error": "not available while viewing as user" } and writes nothing (it would otherwise change the administrator's own profile); if the impersonation state cannot be read, the answer is 503 and nothing is written. If the write commits but the fresh payload cannot be read back (transient database fault), the response is 503 with "saved": true — the change is stored; do not blind-resubmit. The account is re-read from the live row before anything is written: a deleted or disabled account gets 401, a cleared cookie and nothing is written; an account whose live role is demouser, or that has no system role at all, gets 403 (the session's own role claim is never consulted). Two 503 shapes exist: without saved a transient fault happened before anything was written — nothing was stored, retry; with "saved": true the write committed — reload, do not resubmit. See Updating your profile. |
POST |
/admin/auth/logout |
Public | Clear the session cookie. No session is verified — the call always clears the cookie and returns { "ok": true }. |
GET |
/admin/auth/methods |
Public | Capability probe for the register/sign-in quick sign-in row. Returns { "signin": [ … ], "signup": [ … ] }, each a JSON array of provider ids (never an object, even when empty). The SPA renders a provider button only when it appears here for that verb, so the buttons stay conditional and fail-closed — nothing configured returns two empty arrays and the row is absent, no error. A provider is named only when the platform flag oauth_login_enabled is on (default off ⇒ both arrays empty) and its OAuth credentials are fully provisioned — google requires its client id, secret and redirect URI to be provisioned, and microsoft likewise; a partial set is treated as absent. signin lists every such ready provider. signup lists a ready provider only when sign-up is additionally reachable — self-serve registration on (a deployment setting) — so the register screen never shows a button that would dead-end; signup is always a subset of signin. The AVV state does not hide the register button: the Sign up with … button captures the affirmative Terms + AVV consent itself (see Google & Microsoft quick sign-in). Read-only, no side effects, reveals only which providers are configured (never a secret). app_scheme (JSON boolean): whether the native app may use the custom-scheme return (myraai://, iPhones below iOS 17.4) — true only when the flag is on and the platform setting oauth_app_scheme_return is true; absent or malformed setting ⇒ false. The app hides its provider buttons on those devices when it is false. |
Mail cap. At most 5 code mails per hour per address are sent for sign-in codes, counted across the whole cluster (a fixed hourly window, so a burst straddling the window boundary can briefly reach up to twice the cap). Above it the route gives its normal success answer, with the same status, body and headers: no mail is sent and no code or link is stored. A per-node emergency brake of 120 mails per minute across all code-mail routes does the same and writes an error-log line for operators. A database fault while counting is the route's usual transient 503. Limits (accepted side effects). A stranger who keeps sending 5 requests per hour for a victim's address can keep the victim from getting a new code or link for that hour (an earlier, still-live code keeps working); and the per-node emergency brake (120 mails per minute) can be used up by requests for about two dozen known addresses, after which no code mails go out from that node for the rest of the minute.
Web app polling contract. The web app polls GET /admin/v1/me/notifications once per browser tab, and only while someone is signed in and a notification surface is on screen: on open, when the window gains focus or the tab becomes visible (at most once a minute), every 5 minutes while the tab is visible, and explicitly after a dismissal, an acknowledgement or a finished chat turn. The cached answer belongs to one identity: it is cleared at once on sign-out and on a change of account, organisation or impersonation, and an answer that arrives late for the previous identity is discarded. On an error (network, a non-2xx status, a 401) the app keeps the last good lists and shows nothing; after a 401 it stops polling until the next sign-in or until an explicit refresh succeeds. "Not loaded" is never shown as "no notifications". A 200 that does not match the documented shape is rejected as a whole and treated like an error, so a malformed entry can never hide a blocking budget alert. Rejected: a body that is not a JSON object, a missing list or a list that is not an array, a list entry that is not an object, a wrong-typed key field (scope, entity_id, label, tier as strings and used_pct as a finite number on a budget alert; kind, schedule_id, name, reason as strings and delivery as a boolean on a failing run; token_id, label as strings and service as a boolean on an expiring token; agent_id, gateway_id, name as strings on a handover or a protection pause), a budget_alerts_muted that is not a boolean, and a budget_alerts_sig that is present but not a string (including null; the server omits the key). Unknown extra keys and unknown scope / kind values are accepted.
Repeated keys. A JSON body in which an object repeats a key ({"email":"a@x.com","email":"b@x.com"}) is refused with 400 { "error": …, "code": "duplicate_key" } on every body-taking auth route; nothing is stored and no mail is sent. See Request body shape.
Suspended-tenant sign-in
With the tenancy switch on (AIG_TENANCY_ENABLED), a person whose workspace is suspended cannot start a session. Platform administrators are exempt; with the switch off nothing is read. On the routes of the table, except the password sign-in routes in the last two rows (which refuse at the mint only), the check runs first, before the SSO re-check, the password-and-MFA policy and the MFA set-up branch, and the session mint repeats it as a backstop for a suspension that lands in between. A refusal sets no cookie, stamps no last login and writes no pending-MFA record. Audit rows differ per route (see the table): only the OTP verify routes (suspended workspace only) and the CI session grant write one.
| Endpoint | Suspended | State cannot be read |
|---|---|---|
POST /admin/auth/otp/verify and /otp/verify-link (code, magic link, static code) |
403 {"error":"tenant_suspended","code":"tenant_suspended"}, Cache-Control: no-store, audit auth.login_denied (status 403); the code or link is consumed |
503 {"error":"temporarily unavailable"}, no-store, no audit row |
POST /admin/auth/session/renew |
the same 403, no audit row |
the same 503, no audit row |
POST /admin/auth/ci-session (CI session grant) |
the same 403, audit auth.ci_session_denied (status 403); the request limiter is not charged |
the same 503, audit auth.ci_session_denied (status 503) |
POST /admin/auth/demo-login |
404 {"error":"demo_unavailable"}, the same status, body and headers as an unknown demo account (which, unlike this refusal, writes an auth.demo_denied row), no audit row, no no-store |
the same 404, no audit row |
POST /admin/auth/signup/trial |
403 tenant_suspended with trial: true and the voucher (when there is one); the sign-up intent is not spent for the session (a repeated POST /signup/trial answers 409 trial_already_used), no audit row |
200 with session_issued: false; no audit row; the intent is unspent and the status poll below picks it up |
GET /admin/auth/signup/status |
200 with session_issued: false; the intent is unspent, no cookie |
500 {"error":"internal error"}, the intent is unspent; a later poll issues the session once the state is readable |
POST /admin/auth/signin/finish and /setup/finish (password sign-in) |
refused at the session mint only (no earlier check): 403 tenant_suspended, no-store; the refusal itself writes no audit row; the pending row is kept and nothing is stamped (setup/finish: nothing hashed) |
503 {"error":"temporarily unavailable"}, no-store; the refusal itself writes no audit row |
PUT /admin/v1/me/password |
refused at the side-effect-free mint before the commit: 403 tenant_suspended, no-store, the password is not changed and no session is ended. A suspension that lands after the commit gets the same 403 with no cookie: the password is changed and every session ended |
the same 503, before or after the commit alike |
If the suspension lands between the check and the mint on a sign-up route, the intent is already spent and no cookie is set: POST /signup/trial answers 200 with session_issued: false, GET /signup/status answers 500 {"error":"internal error"} and every later poll 200 with session_issued: false. The person signs in normally once the workspace is resumed. (tests: tests/unit/test_signup.lua "MAP-4353 trial race", "MAP-4353 status race")
Content-Type requirement. Every public body-taking auth POST requires Content-Type: application/json (parameters such as ; charset=utf-8 are allowed, case-insensitive). A form, text/plain or multipart/form-data type, an absent header, and a repeated header (nginx joins repeats with ,, so application/json, text/plain no longer matches) all answer 400 { "error": "content type must be application/json", "code": "unsupported_content_type" } before the body is read — nothing is stored, no mail is sent, no cookie is set. This shuts the door a cross-site CORS "simple request" (a <form enctype="text/plain"> or a no-cors fetch, both of which skip the preflight) would otherwise use to invoke the handler in a victim's browser. It is one shared gate (admin.helpers.require_json_content_type), applied to: /admin/auth/otp/request, /admin/auth/otp/verify, /admin/auth/otp/verify-link, /admin/auth/signup/request, /admin/auth/signup/voucher, /admin/auth/signup/verify, /admin/auth/signup/verify-link, /admin/auth/signup/checkout, both /admin/auth/{google,microsoft}/start, /admin/auth/oauth/app-redeem, and /admin/auth/reactivation/opt-out (which keeps its own uniform invalid_token answer rather than the generic message, to avoid an oracle). Absent and malformed share this one restrictive 400 by design — the request never proceeds either way (invariant 11). Exempt: the RFC 8628 device-code routes /admin/auth/device/authorize and /admin/auth/device/token are not gated — their client is an out-of-repo headless adapter whose Content-Type is not under SPA control, and RFC 8628 clients commonly send application/x-www-form-urlencoded; gating them is deferred pending confirmation of the adapter's header (see Device-code auth).
Sign-in return target (/login?next=). The browser sign-in page accepts an optional next query parameter naming the page to return to after the sign-in; it is written by the application itself (a protected page opened without a session, a shared conversation's Continue) and is validated in the browser only — no backend endpoint reads it. Accepted shape: a same-origin absolute path — a value that starts with exactly one /, at most 2048 characters, with an optional query and fragment — whose first path segment is not a pre-sign-in page (login, signup, demo, debug). Rejected: anything else — a scheme (https://…, javascript:…), a protocol-relative //host, a backslash anywhere in the path (browsers read \ as /, so /\host is protocol-relative and /x\..\page walks up), a percent-encoded slash or backslash (%2F, %5C, any case) in the path part (the query may carry them — a query value may encode its own slashes), a control character in any encoding (raw or percent-encoded), an embedded //, a . or .. path segment in any percent-encoded spelling, a malformed percent sequence, a non-string, an empty value. A rejected, empty, or absent next all land on the start view: the shared outcome is the most restrictive landing the application has, so a forged value can only lose the return and never gain a page. The value is passed to the in-application router only, never to a browser-level navigation. Single-sign-on and Google/Microsoft round trips carry no return target on the wire — the start endpoints read no next/RelayState return target and every sign-in callback lands on / (a Google/Microsoft registration lands on /easy); instead the browser keeps the validated value in the tab's session storage for at most ten minutes and the application applies it once, re-validated by the same rule, when that tab returns to /. A hostile value is never stored; an identity-provider error returns to /login?error=… and the stored value stays the return target for the retry; a round trip that returns in a different tab lands on the start view. A pre-filled composer text (text in the target's query or fragment) is removed from every return target, so a single-sign-on round trip never carries it. The target is validated twice — as received (surrounding whitespace removed; the 2048-character limit applies here) and in its canonical form — and it is returned in the canonical form: surrounding whitespace removed and every text entry removed, repeated until nothing changes (so trailing whitespace of whatever remains after the text entries are removed is dropped: /easy ?text=x returns /easy, /easy?a=1 &text=x returns /easy?a=1). A raw control character, line or paragraph separator, backslash or lone surrogate anywhere in the value — including inside a text entry — still rejects the whole value (percent-encoded escapes inside a text value are removed with it); a target whose canonical form names a pre-sign-in page (/login ?text=x) is rejected. Re-validating a returned target yields it unchanged.
Sign-in code e-mail language. The code mail is sent in the first of: the account's own locale, the tenant's default_locale (tenant settings), English — the same chain every lifecycle mail uses (Lifecycle e-mails → Language).
Sliding session renewal
The aig_admin session JWT has a hard exp. Without renewal a long conversation that crosses exp gets a 401 on its next /admin call and hard-redirects to /login mid-stream, losing the in-progress draft. POST /admin/auth/renew removes that: while the session is still valid it silently re-mints a fresh session cookie with its expiry re-anchored to now + the original window, through the same issuing path a login uses (no second session mechanism). The application calls it in the background at roughly half the remaining lifetime (read from session_expires_at on /me), so an active session slides indefinitely and never lapses; renewal is a pure background request that never touches the composer, so the draft and any in-flight answer are preserved. There is deliberately no absolute-lifetime cap — an auth_time (original-login epoch) claim is carried unchanged across every renewal so one can be introduced later without a token or schema migration. The session's amr claim (RFC 8176 authentication-method references, e.g. ["email"], ["static_otp"], ["oidc"], ["saml"], ["google"], ["microsoft"], ["demo"]; a CI-grant session carries ["pwd","otp"]) is likewise carried unchanged across every renewal, and a token that never had one stays without one. The password sign-in adds the values ["pwd","otp"] (password + authenticator app), ["pwd","hwk"] (password + security key), ["pwd","swk"] (password + passkey) and ["pwd","rc"] (password + recovery code). Only pwd plus one of otp, hwk, swk or rc satisfies the sign-in option "Email + password + second factor" (password_mfa).
Accepted input / what is rejected (trust boundary). The only input is the aig_admin session cookie; the request has no body and the client is never the authorization boundary. It is validated fail-closed through the identical verify + live-account chain the whole admin API uses, and nothing is minted on any rejection — expiry cannot be defeated by presenting a garbage or expired cookie:
- absent cookie →
401(no session to renew); - malformed (non-JWT) or wrong-signature cookie →
401— absent and malformed are distinct answers, both refused; - expired token →
401(a pastexpis rejected before renewal is even considered); - wrong-purpose token (a
signup/impersonationcredential presented as a session) →401; - token with a malformed
amrclaim (not a list, empty, an unknown or duplicate value, or more than 4 entries) →401(malformed amr claim); a legacy token with noamrat all is still accepted; - revoked / disabled / deleted account (the session's
iatis at or before the account's revocation floor, or the row is gone/blocked) →401and the cookie is cleared; - a pending sign-in token presented as the cookie →
401malformed token(it is not a JWT); - a session of
email/static_otporigin or withoutamr(nootp,hwk,swkorrc) for a person who is now onpassword_mfa→403 mfa_session_required, the cookie is left untouched and nothing is minted; the old session lives until its own expiry. Sessions with an externalamr(oidc,saml,google,microsoft) anddemosessions are renewed unchanged, except that of asys:adminholder whileadmin_mfa_enforcedis on, which also gets403 mfa_session_required; - a transient database fault →
503(nothing minted, retry); - an unreadable or malformed sign-in switch (
admin_mfa_enforced,password_mfa_enabled,password_mfa_tenant_allowlist) or stored sign-in option, or a failed role read, while deciding themfa_session_requiredrule →503temporarily unavailable, nothing minted, cookie untouched. Only what the decision reads can refuse: a session withpwdplus a second factor reads nothing, an external ordemosession reads onlyadmin_mfa_enforced(and the role while it is on). A corruptadmin_mfa_enforcedtherefore stops renewal for every session that lackspwdplus a second factor until the value is fixed (see settings).
The mfa_session_required refusal is decided before the throttle below: a throttled 200 never replaces a 403, and a refused renewal takes no throttle slot and writes no audit row. On success the response is { "ok": true, "renewed": true, "expires_at": <unix seconds> }. Every renew answer carries Cache-Control: no-store: the renewing 200, the throttled and the session-policy "renewed": false 200, and the 403 / 503 of the mfa_session_required rule. A ≈10-second per-session throttle bounds cookie/audit churn from multi-tab or visibility double-fires: a renewal that arrives within the window returns { "ok": true, "renewed": false, "expires_at": <current exp> } without re-minting (the throttle is best-effort — under shared-dictionary pressure it fails open and re-mints, never dropping a needed renewal). Every real renewal writes an auth.session_renewed audit row (never the token or email). Renewal is paused during impersonation (the impersonation payload carries no session_expires_at), which is bounded by the impersonation credential's own short lifetime.
Per-tenant session policy. A tenant can set an absolute lifetime (session_max_age_s) and an idle timeout (session_idle_timeout_s) — see Updating a tenant. Both are enforced server-side on every request and on renewal:
- Maximum age counts from the sign-in (
auth_time, which renewal never moves). Renewal cannot extend a session past it: the re-minted cookie's expiry is capped at the limit. A renewal that arrives within ≈10 seconds of the limit answers401(the session is ended); a renewal that would not move the expiry answers200with"renewed": false. - Idle timeout is measured from the cookie's last mint or renewal (
iat). The app renews while a signed-in tab is open, so "idle" means no renewal for that long, i.e. no open signed-in browser tab. It is not keyboard or mouse inactivity. - A violating session is treated like a revoked one:
401on/admin/auth/meand every other admin call, cookie cleared. A stored policy value that is malformed is a refusal, never "no policy". An absent value (null) means no limit. - Policy changes apply to existing sessions at their next request. Impersonation sessions are checked against the acting administrator's own tenant policy (never the impersonated user's). While an administrator impersonates,
GET /admin/auth/mereports the administrator's own session expiry assession_expires_at, so the app keeps renewing the administrator's session through the impersonation and an idle timeout shorter than the impersonation does not sign them out. - After an administrator signs a user out everywhere (Users & tokens API), a sign-in in the same second as the sign-out is refused (the session must be issued after the revocation floor); signing in again a moment later works.
💡 Note: Sessions are carried in the
aig_admincookie (a signed JWT). The Google/Microsoft quick sign-in (below) is separate from the standard email-OTP sign-in flow. The public no-login demo-login entry point is disabled:POST /admin/auth/demo-loginreturns404for every request and mints no session, so a/demo?for=<name>link can no longer start a session (it lands on the Demo unavailable card). The former per-address rate-limit on that entry no longer applies.
Google & Microsoft quick sign-in / registration
Personal-identity OAuth lets a customer sign in or register with a Google or a personal Microsoft (consumer MSA) account, beside email-OTP. This is distinct from the tenant-configured OIDC / SAML SSO below (that authenticates existing users against a tenant's own IdP; this creates and signs in self-serve customers). One code path serves both verbs — the button label is the only difference — so an unknown identity registers (a new free-trial tenant, exactly like the email trial funnel) and a known one signs in.
Ships dark, fail-closed on two independent gates. Every surface (the /admin/auth/methods probe, the initiate redirect, the start, the callback, and the native-app redeem POST /admin/auth/oauth/app-redeem) is inert unless both the platform flag oauth_login_enabled is on (a DB-backed Feature Flag, platform-admin only, default off) and the provider's OAuth credentials are provisioned. Either gate failing ⇒ the button is not advertised and the endpoints return 404 (indistinguishable from an unmounted route — the client is never the authz boundary). Enabling a provider is therefore a deliberate act: flip the flag and provision creds.
| Method | Path | Auth | Description |
|---|---|---|---|
GET |
/admin/auth/google · /admin/auth/microsoft |
Public (gated) | Initiate sign-in. Generates an opaque state + a nonce, stores them in the database (keyed by state, single-use, 10-min TTL) with the remember-me intent and the sign-up email locale, sets the aig_oauth_state cookie (HttpOnly; Secure; SameSite=Lax), and 302-redirects to the provider's authorize endpoint. The correlation is DB-backed (not an in-process per-node cache), so an active-active deployment where the initiate and callback land on different sites still completes — mirroring the OIDC SSO flow. The browser initiates this GET on the admin-auth host (the same host the callback is served from), so the host-only aig_oauth_state cookie set here is present at the callback — on a split-host deployment (SPA host ≠ admin-API host) a sign-in initiated on the SPA host would set the cookie on the wrong host and every callback would fail the CSRF check. 404 unless flag-on and creds present; rate-limited per client IP (60 requests per 60 s, one bucket shared with POST …/start; 429 { "error": "rate limited" } past the cap), because the durable state row makes the unauthenticated initiate a write. Accepted query: remember (1/true for a 30-day session; anything else = the 8-hour default). Rejected: any consent parameter — consent_terms_version, avv_accepted or avv_version, with a value, valueless or repeated — answers 400 and stores nothing: consent is accepted only through the POST …/start below (a clickable link must never be able to carry a consent record), so a consent that arrives on this channel is treated as malformed, not as absent. |
POST |
/admin/auth/google/start · /admin/auth/microsoft/start |
Public (gated) | Initiate registration with consent — the register page's Sign up with … button, enabled only once the page's single Terms + AVV consent checkbox is ticked. A credentialed JSON POST from the application origin (CORS allowlist + Content-Type gate) with body { "consent_terms_version": "<version>", "avv_accepted": true }, validated by the same rule as POST /admin/auth/signup/request: consent_terms_version must be a string of 1–32 characters from [A-Za-z0-9 . - _ :] (the acceptance signal — the recorded version is the server-pinned terms_current_version, not this client value), and while an AVV version is in force avv_accepted must be the JSON boolean true. Rejected with 400, nothing stored, no cookie: a missing body, a body that is not a JSON object (null, a number, an array, a string), a body that fails to parse (malformed_body), a missing / empty / over-long / badly-charactered / non-string (null, number, array) consent_terms_version, and — while the AVV is active — an absent or non-true avv_accepted (false, "true", 1, null, an array). Same gates as the GET plus the registration gate: 404 unless flag-on and creds present and self-serve registration is on (a sign-up-only surface is as unmounted as the /signup/* routes when registration is closed), the same per-IP rate limit (429, applied before validation), 503 when the state row cannot be written. On success it mints the same state + nonce + cookie as the GET and stores the consent with the correlation — the terms version, the server's AVV version in force at that moment, and consent_at (the click time) — plus the optional signup_source (same parser and rules as /signup/request; malformed → 400 { "error": "invalid signup_source" } with no state row and no cookie — checked after the per-IP rate limit, before the referral lookup), the optional voucher_code (the campaign voucher code the visitor typed before the click — same shape and same drop rule as /signup/request's voucher_code: trimmed, upper-cased, 4–64 characters of [A-Z0-9_!?.-] (an input longer than 256 bytes before trimming is rejected outright, never trimmed); malformed or a non-string (null, number, object, array) is dropped with a WARN (the value is never logged); absent (or "") → nothing happens; either way the flow continues with the same response shape as without a code, never a 400, so /start is no oracle for which code shapes exist; read after the consent and signup_source checks, before the referral lookup, and ignored by the sign-in and app sign-in variants), and any referral attribution: the aig_ref cookie (or an explicit body.ref) is resolved here through the same normalise + active-partner resolver as the e-mail funnel (after the rate gate, so an unauthenticated flood is shed first) and the resolved partner id is carried in the correlation payload to the callback (malformed / unknown / suspended / DB-fault → no attribution, the registration still proceeds). It then answers 200 { "authorize_url": "<provider authorize URL>" }; the browser navigates there itself (the application follows the URL only if it is an https:// URL of at most 2048 characters). Content-Type gate: the request must carry Content-Type: application/json (parameters such as ; charset=utf-8 allowed, case-insensitive); a form or text/plain post, an absent header or a repeated header answers 400 before the body is read, with nothing stored and no cookie — so a cross-site page cannot run this endpoint with a CORS simple request (no preflight) either. Independently of that, a cross-site page can never read the response: the state and nonce stay secret, so nothing can be provisioned from a forged start. No remember-me field on registration: the stored remember is always "0" (a client cannot pick the lifetime) — the server's sign-up policy issues the 30-day session, see Resolution below. Native app: the body is dispatched first. If any consent key is present (a JSON null counts as present) it is the registration start above. If no consent key is present but the app pair app_challenge + app_return is, it is the app sign-in start: no registration gate, ref / signup_source are ignored (not parsed, not stored), optional remember must be a JSON boolean. The app pair is accepted on a registration start too. app_challenge must be exactly 43 characters of [A-Za-z0-9_-] (the PKCE S256 challenge) and app_return exactly link, scheme or intent; a JSON null, a number, an object, a wrong length or charset, or only one of the two → 400, nothing stored. An app start sets no aig_oauth_state cookie. Order: flag/creds 404 → rate limit 429 → Content-Type 400 → body → dispatch → (registration only) the self-serve 404 — so with registration closed a non-JSON or malformed POST now answers 400/429 rather than 404. The GET initiate rejects app_challenge / app_return with 400 (the challenge must never travel in a URL). |
GET |
/admin/auth/google/callback · /admin/auth/microsoft/callback |
Public (gated) | Trust boundary. When the provider redirects back with an ?error= instead of a code — a user cancel at the consent screen (access_denied) or a provider fault — the callback 302-redirects the browser to /login?oauth_error=<reason> (never a raw JSON body, which would render as text): access_denied → cancelled, any other provider error → try_again. No state is consumed and the cookie is not read on this branch (it issues nothing; unlike the OIDC ?error= branch, which attributes and audits the refusal); the provider's error/error_description is never reflected. Otherwise (a normal code+state return): verifies the aig_oauth_state CSRF cookie, then atomically consumes the single-use state (a replay / expired / unknown state → 400; a transient DB fault on the consume → 503), exchanges code at the provider token endpoint over verified TLS, then validates the id_token and signs the user in (existing) or registers a new trial tenant (unknown — only when the correlation carries the consent recorded by POST …/start). App states — a state of the shape a + channel (l/s/i) + 32 lowercase hex — take a separate branch that needs no cookie (the PKCE check at the redeem replaces the double-submit cookie) and never answers with JSON for user-facing outcomes: the state is consumed first (a DB fault → 503); a provider ?error=, a missing/expired/replayed state, a missing or malformed code, a failed token exchange or any failed claim (incl. the nonce, which is the only binding of the provider code to an app state) → an app error redirect cancelled / try_again; success → no side effect (no link, no lookup, no provisioning, no audit, no session) but a single-use 64-hex handoff code (120 s) sent to the app — see Native app sign-in. Every other state runs the web path exactly as described here. |
Callback validation (every check fails closed; ABSENT and MALFORMED both reject — no session, no account). In order: code/state must be non-empty strings (400); the aig_oauth_state cookie must equal the returned state (400, CSRF — this double-submit check runs first) and then the state must be consumed server-side (400, expired/unknown); the stored entry must carry a non-empty nonce (400); if the stored entry carries any consent field, all of them must be well-formed — consent_version a non-empty string, avv_version a string, consent_at an integer no later than now + 60 s and no older than the 10-minute state lifetime plus 60 s (the 60 s absorbs clock skew between active-active sites in either direction) — else 400 (the entry is the server's own write, but a mangled one must neither pass as a consent nor fall through to the consent-less path); a stored voucher_code that does not normalise (incl. a JSON null) → 400 bad state; the token exchange must succeed (a 5xx, typically 502, on a non-2xx / network / non-JSON / missing-id_token response); the id_token claims must decode to an object (502); then iss must be an expected issuer (502), aud must equal the client id (502), exp must be a number ≥ now − 120 s (401, an absent exp is treated as expired), nonce must equal the stored value (401), the provider's verified-email claim must be the boolean true (Google email_verified, Microsoft xms_edov; a string "true", 1, or absent all 403), sub must be a non-empty string (502), and email must be a non-empty, RFC-shaped address — the email claim only, never preferred_username (which no claim attests) (502). Only then is the identity resolved.
Resolution. An existing active account → the OAuth identity is linked (oauth_link) and a session is issued (landing on /, honouring a remember-me from the GET initiate). A disabled account → denied (never routed to registration). An unknown identity → a new free-trial tenant is provisioned exactly like the email no-card trial (the same one-per-email dedup, per-domain/per-IP throttle, consent snapshot, and trial entitlement), only if self-serve registration is on and the correlation carries the consent recorded by POST …/start — the stored terms version, consent_at (the click time), the AVV version, any referral partner id captured at /start and the campaign source captured at /start (re-validated with the same parser at the callback, before the token exchange; a correlation whose stored source no longer parses answers 400 bad state — it never degrades to "no source") and the voucher code captured at /start (re-normalised at the callback with the same rule; a stored voucher_code that does not normalise — including a JSON null or any non-string — answers 400 bad state, it never degrades to "no code") are written to the signup intent and the provisioned tenant exactly as /signup/request writes them, and the stored AVV version must still equal the server's current AVV version at the callback (a change between click and callback means the customer accepted a different document → nothing is provisioned and the register page asks again; this is stricter than the email funnel, which trusts its request-time snapshot). Voucher outcome. The carried code is recorded on the signup intent and then follows the e-mail trial funnel's path unchanged: the claim is written with source = signup_oauth (voucher_claim), the code is carried on the new tenant together with the provider-verified address (the per-account dedup key), and a trial-redeemable code (redeem_at_trial; a unique code or a shared generic campaign code — once per e-mail address up to its max_redemptions) is redeemed at the trial start while any other valid code is deferred to the paid conversion. An OAuth sign-up shows no outcome card and the redirect URL carries no outcome (it would be forgeable): the outcome reaches the customer through the trial-started e-mail (which states the voucher outcome) and the wallet / promo balance (promo_usd on GET /admin/auth/me). An existing account that uses "Sign up with …" is signed in and the code is ignored (codes are redeemed only at signup); the loser of a concurrent double-registration also ignores it. A flow that started on the sign-in GET has no consent, so an unknown identity there is bounced to the register page rather than provisioned. The new trial lands on /easy?registered=1 (the one-shot registration marker; the native app's redeem answers the same next) with the 30-day session — the same lifetime as a sign-in with "stay signed in". Session length: every session a flow started on the sign-UP surface issues (a consented POST …/start, web or app) is the 30-day session — the new account, the double-registration loser, and an existing active account signed in through "Sign up with …". A flow started on the sign-in GET or the app sign-in start keeps the login's remember choice (30 days with remember, otherwise the 8-hour default). A concurrent double-registration of the same email yields exactly one tenant (the loser is signed into the winner's account, not errored).
Identity subject is matched byte-exact. See Identity resolution and the tenant boundary.
Bounce targets (?oauth_error=<reason>). User-facing outcomes are browser redirects. Registration outcomes return to the register page's trial step — /signup?trial=1&oauth_error=<reason> with consent_required (no consent in the correlation, or the AVV version changed), registration_unavailable (self-serve off), already_registered, trial_already_used (the email already used its free trial and its prior account is gone — erased, or re-registered under a different address variant; a platform-admin delete clears the one-trial-per-email lock so a deliberately-reset account never hits this and instead gets a fresh trial), rate_limited, rate_limited_domain / rate_limited_network (the per-domain or per-network trial limit was reached; see Trial sign-up exceptions for the int/beta override), or try_again (a transient fault during a registration flow; the same bounce whether the server logged it as retryable or as a genuine fault, the audit row carries 503 or 500 accordingly); the page shows the matching message and, for consent_required, moves focus to the consent checkbox. Sign-in outcomes return to /login?oauth_error=<reason> with account_suspended (the account exists but is disabled), account_deactivated (a soft-deleted account still owns this address — e.g. a tenant admin deleted the user; the terminal "your account has been deactivated, contact your organisation administrator" message, shown on /login and never the sign-up/consent flow — a soft-deleted account was previously dead-ended at the consent checkbox or shown the misleading "trial already used"), admin_mfa_required (a Myra platform admin while admin_mfa_enforced is on, also from a sign-up start; see the Google and Microsoft row), cancelled (the user cancelled at the provider's consent screen — also where a cancelled registration lands, since the ?error= branch consumes no state and so cannot tell sign-in from sign-up; the Register tab is one click away), or try_again (a transient fault during a sign-in flow, or a registration that succeeded but whose session could not be issued — sign in to continue). The account_deactivated decision is derived only from an authoritative server signal (a user row with deleted_at IS NOT NULL for the exact, ascii_fold-normalized address — never a client hint); it fails closed, so a backing-store fault while it is being decided denies the request with the try_again bounce (never the deactivated message, never a sign-in, and never a fall-through to sign-up or a trial), while a non-matching (accent / homograph) address degrades to the ordinary flow (the sign-in mint lookups already exclude deleted_at), disclosing no more than the existing account_suspended already does. The application maps the reason through one closed allowlist on both pages; an unknown or tampered value shows a generic message and is never reflected. Every outcome that reaches identity resolution (an account lookup, link, provision, or denial after the token exchange) is written to the audit log with the OAuth identity provider:sub in idp_entity_id (the wide column shared with SSO) and the tenant id in entity_id (empty pre-provision) — never the e-mail, so the audit log carries no PII here. The pre-exchange provider-error bounce (cancelled/try_again from an ?error= with no code) resolves no identity and writes no audit row — it is logged at ngx.WARN only. The identity lives in idp_entity_id rather than entity_id because a long subject (e.g. a Microsoft oid GUID) overflows the UUID-sized entity_id and would otherwise drop the row. Microsoft's xms_edov requires the Azure app registration to emit the email + xms_edov optional claims; until validated against real consumer tokens the Microsoft provider is provisioned but left dark.
Native app sign-in (iOS / Android)
Google forbids sign-in inside an embedded web view, and the app's web-view cookies are not the system browser's, so the native apps use the RFC 8252 pattern: the app's web view POSTs the start with a PKCE challenge, the provider login runs in the system auth browser (ASWebAuthenticationSession on iOS, Custom Tabs on Android), and the callback returns a single-use handoff code that only the web view holding the PKCE verifier can redeem.
Return channel — decided by the server from the callback request's User-Agent (the browser that completed the login), never by the client: link → https://<app host>/auth/app-complete#code=<code> only for an Apple Safari user agent (an https URL on our domain can only open our app or stay in Safari); scheme → myraai://oauth?code=<code> only for an iPhone below iOS 17.4 and while oauth_app_scheme_return is on (accepted residual risk: a malicious app that registers myraai:// on such an iPhone could intercept a code in an attacker-started flow); intent → only for an Android user agent (on Apple platforms intent: is an ordinary custom scheme that any app could catch, so a non-Android browser gets unsupported; an Android tablet whose browser sends a desktop user agent therefore signs in with the e-mail code), an Android intent: URI with the explicit package eu.myra.myraai (only an app with that package name can receive it — Android does not check the signing certificate here, so a sideloaded malicious app using our package name on a device without the real app could receive a code in an attacker-started flow; accepted residual risk, the Android counterpart of the iOS one) carrying the code in the extra aig_code, plus a browser_fallback_url without the code. A requested channel that is not eligible gets error=unsupported&page=login on that channel and no code is minted. App errors use the same channel as error=<reason>&page=login|signup (Android: extras aig_error, aig_page).
| Method | Path | Auth | Description |
|---|---|---|---|
POST |
/admin/auth/oauth/app-redeem |
Public (gated) | Body { "code": "<64 lowercase hex>", "verifier": "<43–128 chars of [A-Za-z0-9._~-]>" }. Order: flag 404 → per-IP rate limit (own bucket, 30/min) 429 → Content-Type 400 → body shape (absent, null, wrong type, length or charset, upper-case code → 400 invalid code / invalid verifier, nothing consumed) → atomic single-use consume of the handoff (unknown / expired / replayed → 400 invalid or expired code; DB fault → 503) → stored handoff type-check (unknown or no-longer-provisioned provider, missing email/sub → 400 bad handoff) → PKCE check base64url(SHA-256(verifier)) == challenge in constant time (mismatch → 400 invalid verifier; the code is burned either way); an e-mail that no longer passes the address check, a consent snapshot outside the start-to-redeem window (10 min + 2 min + 60 s clock slack) an unparseable campaign source, or a stored voucher_code that does not normalise (incl. a JSON null) → 400 bad handoff. Then the same account resolution as the web callback runs here — link, sign-in, disabled deny, registration gates and provisioning, audits, session — answering 200 { "next": "/" \| "/easy" } with the aig_admin session cookie, or a deny 4xx { "reason": "<reason>", "page": "login" \| "signup" } (reasons as in the bounce targets above; statuses 403, 409, 410, 429, 500, 503). Audit rows of an app sign-in therefore carry POST /admin/auth/oauth/app-redeem. |
The app's completion page /auth/app-complete accepts exactly one of #code=<64 hex> or #error=<reason>&page=<login|signup> (any repeated or unknown key is malformed → try_again), removes the fragment from the address bar immediately, and redeems only with the verifier its own web view stored at the start. The native apps load that page only while a sign-in they opened is pending and block every other navigation to it.
A page that reloads itself keeps its fragment. When a page file cannot be fetched (typically right after a deployment replaced it), the web app reloads the page once. The reload keeps the address as it was, fragment included: a sign-in code, a sign-in error or an opt-out token (#t=…) in the address reaches the reloaded page unchanged. A magic-link token (#token=…) is the exception by design: it is taken out of the address when the page starts and held only in page memory, so a full page load, this reload included, does not carry it (the sign-in and sign-up pages are not loaded lazily, so this reload does not happen on them). For the one reload the app appends a short marker (aigcr) to the end of the fragment, and the reloaded page removes it again before anything else reads the address, so no page ever sees it. Only an exact marker at the end of the fragment counts (#text=aigcr does not). If the address cannot be rewritten the app does not reload, and a page that fails to load a second time shows the "Reload" card instead of reloading in a loop. The app itself never logs the fragment or sends it to a server. A sign-in return target (next) keeps the fragment of the page the visitor wanted, except a text entry (a composer pre-fill), which is always removed; that target travels in the query of the sign-in address, and the marker is never part of it.
Connectors. The same return channels, handoff-row mechanics and PKCE redeem also carry the per-user connector OAuth connect of the apps, with separate state kinds (a sign-in code and a connector code are not interchangeable), the page word connectors in place of login|signup, and an authenticated redeem at POST /admin/v1/mcp/oauth/app-redeem. See Connector OAuth from the mobile apps.
Data retention. A handoff row holds the verified identity (provider, e-mail, subject, display name), the start's consent snapshot, campaign source (incl. a click ID) and the campaign voucher code typed at the start. It is deleted when redeemed; an unredeemed row is valid for 120 s and then removed by the hourly oauth_state clean-up — so it can exist for up to about 62 minutes (see Data retention).
Display name. The name the provider sends is sanitised before it becomes the new account's name: control, bidirectional and zero-width characters are removed, whitespace runs collapse to one space, and a name longer than 255 characters or not valid UTF-8 is ignored (the account is created without a name; it is never truncated). Earlier versions cut the name at 80 bytes.
Public login branding (white-label)
So the login page can render a tenant's white-label branding before anyone signs in, two public endpoints resolve a tenant by slug (from a ?tenant=<slug> link). Both take a hostile slug and are hardened fail-closed:
| Method | Path | Auth | Description |
|---|---|---|---|
GET |
/admin/auth/brand/lookup?tenant=<slug> |
Public | Returns { "branded": true, "product_name", "greeting", "logo_version", "logo_light_version" } when the slug resolves to a tenant that has branding, else { "branded": false }. Only these non-sensitive fields are ever returned. |
GET |
/admin/auth/brand/logo?tenant=<slug>&variant=dark\|light&v=<version> |
Public | Returns the login logo as JSON { "mime", "version", "data" } where data is the base64-encoded image (image/png/image/jpeg). The login page fetches this over connect-src and renders it as a data: URL, so a split-host deployment (SPA host ≠ admin/auth host) is not blocked by the SPA img-src CSP that forbids a cross-host <img src>. Same shape as the in-app /admin/v1/tenants/{id}/logo asset route. v is the content-hash version and is required by the login page; the response is immutable-cacheable only when v equals the tenant's current non-empty logo version (a re-upload = new version = new URL); a stale, absent or junk v is served no-cache. |
- Slug validation. The slug must be 1–64 characters of
[A-Za-z0-9._-](it is lower-cased). Anything else is treated as a miss. - Identical fail-closed misses (no oracle). An invalid-charset slug, an unknown slug, a soft-deleted tenant's slug, and a known but unbranded tenant all return the byte-identical
{ "branded": false }— the endpoint is not an account/tenant-existence oracle, and a database error also degrades to{ "branded": false }(never a 5xx that would confirm a match). The logo route returns a generic 404 for an invalid slug/variant, an unknown tenant, or a tenant with no such logo. (Unlike the signed-in/admin/v1/tenants/{id}/logoroute, which answers an unset logo with200and null fields, this public route keeps one indistinguishable 404 for every miss, so it is not an existence oracle; the login page only fetches it when the lookup announced alogo_version.) - Which logo the login card shows. The login card's logo chip is dark blue in both UI themes, so the login page treats it as a dark surface: it fetches the dark-theme logo (
variant=dark) whenlogo_versionis present, otherwise the light-theme logo (variant=light), which it shows on a light chip. Only the chosen variant is fetched; while it loads, or if the fetch fails or the bytes do not decode, the default Myra mark is shown. - No data leak. The lookup reads a narrow column allowlist (product name, greeting, and the logo pair's version + MIME) — never plan, budget, SIEM/SSO posture, cloud regions, the chat disclaimer, or the sidebar links. The logo route re-clamps the stored MIME to the PNG/JPEG allowlist and never serves (or base64-encodes) any other type.
- Rate-limited per IP (its own bucket, separate from SSO discovery) to blunt slug enumeration.
Failed-authentication throttle on /v1
Requests to /v1 that are rejected for authentication reasons (unknown workspace, missing or invalid token, expired or revoked token) are counted per client address. Beyond the limit (default 300 rejections per 60 s) the address is answered 429 auth_rate_limited with a Retry-After header until the window ends, even for a request that carries a valid token. Only rejections are counted; successful requests are not. The address is the first X-Forwarded-For entry, and IPv6 clients share one counter per /64 network. Requests the gateway makes to itself inside its own host are not counted. Operators tune the limit and window with the preauth_reject_limit and preauth_reject_window_s settings. See Error codes. Many clients behind one shared NAT or egress address share one counter, so one of them repeatedly failing (for example a script looping on a revoked or expired token) can briefly block the others' valid requests for up to one window; raise preauth_reject_limit if that network is legitimately noisy.
How the public rate limits behave
There are two deliberately different shapes, and which one applies depends on what is being counted.
Per-IP request limiters — a fixed window. SSO discovery, login branding and its logo, the four
SAML routes, the OIDC start route (1000 per 60 s per client IP and tenant by default, its own counter; see SSO refusal lockout), and the self-serve signup routes count requests per client IP. The window opens on
the first request from that client and closes a fixed number of seconds later, whatever happens in
between: a request that is refused does not extend it. So a 429 from these always clears on
its own once the window elapses — there is no state an operator has to reset, and no way for a
client to lock itself out permanently. Requests with no usable client IP share one bucket
(anything that does not parse to a canonical address: a blank or non-address X-Forwarded-For
value, a hostname, RFC 7239's unknown, an IPv4 with leading-zero octets; a forged but well-formed address keys as described below), and each endpoint keeps its own counter, so exhausting one never affects another.
An IPv6 address carrying a zone id (fe80::1%eth0) keys like the same address without it: the zone
names the receiving interface, not the client, and is stripped before keying, so such a client is
never thrown into the shared bucket where unrelated junk could exhaust its allowance.
What "per client IP" means. An IPv4 address is counted exactly. An IPv6 address is counted per
/64 network (the size an ISP hands a single subscriber, RFC 6177 / RFC 7421), so a client cannot
sidestep a limit by rotating through the addresses of its own /64: every address in one /64 shares one
allowance, and a different /64 has its own. IPv4-mapped spellings (::ffff:203.0.113.9 or ::ffff:cb00:7109, with or without a zone id) count as
the plain IPv4 address. NAT64 (64:ff9b::a.b.c.d) and IPv4-compatible (::a.b.c.d) addresses are treated
as ordinary IPv6 and key on their /64, not unmapped. The same rule applies to the limiters on the public form, form-upload, partner
link-redirect, cancellation (kuendigung) and inbound-webhook failure routes. The free-trial per-IP cap (5 new trials per rolling 24 h, see No-card free trial) uses the same key: it is stored with each trial sign-up as an ip_bucket, so respelling an IPv6 address or moving to another address of the same /64 does not earn a new allowance. Trial sign-ups recorded before this key existed carry no bucket and keep counting under their exact stored address until they age out of the 24 h window. The same key is stored with each pending device-login authorization as device_authorization.source_bucket (the IPv4 address or the IPv6 /64) to enforce the per-address cap of 5 pending authorizations per gateway (see Device-code auth); it is deleted together with the row (at most 600 s plus the reaper interval) and is NULL for rows created before the column existed, which count toward the gateway cap only.
Failure counters. The one-time-code guess budget is per code: five wrong guesses exhaust
the code itself (otp_attempt_cap), and the way past that per-code block is to request a new code
— which invalidates the exhausted one and starts a fresh budget of five. (The 24-hour budget described below is a separate lock: while it is spent, a code from a new e-mail is refused too; that e-mail's sign-in link still works.) This is what keeps a
"request a new code" remedy honest across every gateway node. Around it sit two tumbling
windows keyed per address: at most ten code requests per code window (otp_request_cap) and
at most twenty rejected verification attempts per hour across codes (otp_failure_cap, cleared
only by a successful sign-in — and every rejected attempt counts, a wrong guess and an attempt
on an already-spent code answered 429 otp_attempt_cap alike, so hammering a dead code spends
the hour as surely as guessing does). Together they bound an unauthenticated caller to 5 × 10
guesses per window and 20 rejected attempts per hour on any one address — and, because anyone can send requests for any
address, to locking that address out of new codes for the rest of a window or out of
verification for the rest of an hour (a bounded nuisance, never an authentication). Both
limits are reserved before a guess is compared, so concurrent requests cannot overshoot them: a
guess takes its place in the code's five-guess budget (inside one database transaction that locks
the address's codes) and its slot in the hourly cap before the code is checked, so a burst of
simultaneous guesses for one code is answered at most five times with 401, and the remainder
with 429. The same holds for an address with no live code (an unknown address, a registered
address whose code expired, a static-code account): its five-guess budget is reserved with one
atomic step before the guess is compared, so on one node a burst of simultaneous guesses is
answered exactly five times with 401 and the rest with 429 for every kind of address, and a
caller cannot tell a registered address from an unknown one by the burst's outcome. A guess that
turns out correct, an already-consumed double submit, or one that fails on a server fault
(503) gives its hourly slot back; a wrong guess never does.
After five wrong guesses on the no-live-code path, even an already-consumed double submit is answered
429 otp_attempt_cap. If the lock on an address's codes
cannot be taken within 5 seconds, the request is answered 503, with nothing counted. The
CI-session endpoint keeps its sliding failure window keyed per client-IP bucket (every
failure refreshes it, so the block anchors to the last failed attempt). A successful attempt is
never counted.
Where each counter lives — and the stated residual. The per-code budget is a column on the
code row, so it is the same on every gateway node. The tumbling windows and the five-guess
budget for an address that has no live code (an unknown address, a registered address whose
code expired, a static-code account) live in each node's memory, so those counts are per node
in a multi-node deployment. On one node an unknown address and a registered one are
indistinguishable in every response and over time. A caller whose requests reach two different
nodes can tell a registered address with a live code from an unknown one (five wrong guesses
on one node, a sixth on the other: the live code is already spent everywhere, the memory counter
on the second node is not) — only that state, only across nodes, and only within the code
window. For the same reason auth.otp_blocked is recorded once per episode per node.
Counters of a registered address cannot be pushed out. The in-memory counters of an address that belongs to a
registered account (the hourly ceiling and the five-guess budget described above) are kept in a protected memory
area that a flood of requests for made-up addresses cannot evict, so a caller cannot reset a registered person's
budget by sending many requests for other addresses. If that protected area is ever full or unavailable, the answer
for a registered address is the same 429 the cap would give (otp_failure_cap, or otp_attempt_cap for the
five-guess budget), and the code is not compared where the protected memory alone decides: the hourly ceiling, and
the five-guess budget when no live code exists or the code is a fixed one. A live code is still judged by its own
five-guess limit. The condition is logged on the server. Counters of unregistered addresses stay in the ordinary
rate-limit memory and behave as before. While the protected memory is healthy the answers, their status codes and
their bodies are unchanged. When it is full or unavailable, or after a flood of requests that pushes an unregistered
address's counters out, a registered address can answer 429 where an unregistered one answers 401; that
difference costs a caller a flood of requests to produce. The e-mailed sign-in link (POST
/admin/auth/otp/verify-link) does not use these counters and keeps working meanwhile.
Cluster-wide 24-hour failure budget. On top of the three counters above, every e-mail sign-in
address (POST /admin/auth/otp/verify, the setup e-mail-code step) has one budget of 20 kept wrong
guesses per fixed 24-hour window, stored in the database and therefore the same on every gateway node.
It is keyed by a SHA-256 of the normalised address, not by account, so an unknown address spends and
locks it exactly like a registered one (no account-existence oracle) and no plaintext address is stored.
It is reserved before the code is compared: a wrong guess keeps its slot; a correct code, a double
submit on an already-consumed code, a guess answered by another counter, or a 503 gives the slot
back. Once the 20th wrong guess is kept, the next attempts are answered 429 otp_attempt_cap (its sign-in page text points to the sign-in link in the e-mail as well as a new code; the partner flows answer 429 otp_failure_cap instead, see Partner API) without
comparing the code — even the correct one — until the window ends (24 hours after the window's first
counted failure since the budget was last empty), or until it is reset early by a successful sign-in through the link in a code e-mail (POST /admin/auth/otp/verify-link, e-mail-code accounts) or by Support; while the budget is spent a typed code is refused. A code request does not reset it (a
resend must not undo a brute-force budget), and a request that is capped never increments it. If
the budget cannot be read or written the answer is 503 (retryable) and nothing is compared: a fault is
never read as "within budget". The 20th wrong guess itself is still a plain 401. When that lock is
reached on an account's static (fixed) code, the event auth.static_otp_locked is recorded
(Audit log). A legacy static code (set before the 12-character minimum) signs in only until 30 days after the migration first ran; after that the correct code answers 403 static_code_expired (audited auth.static_otp_expired, no session, budget not cleared) while a wrong guess stays 401; see Users: legacy static codes. Support can lift a lock early after verifying the account holder. The way back in while locked depends on the account: for an e-mail-code account, the one-click sign-in link in a fresh code e-mail (POST /admin/auth/otp/verify-link) still signs in and resets the budget (typing that e-mail's code is refused while locked, so use its link); for a static-code account, wait until the window ends or ask Support.
Request body shape. POST /admin/auth/otp/request, POST /admin/auth/otp/verify, and PATCH /admin/auth/me expect the request body to be a JSON object. A body that is valid JSON but not an object — an array, null or a bare scalar (42, true, "x") — is rejected at the trust boundary with 400 { "error": "request body must be a JSON object", "code": "malformed_body" }, as is invalid JSON; neither is ever read as an empty object. Only an absent or blank body is read as an empty object. An unreadable spooled body returns 503. The OTP routes have required fields, so an absent body fails their validation with 400 (for example, POST /admin/auth/otp/request with no body returns 400 { "error": "email required" }). PATCH /admin/auth/me has no required field, so an absent body is a valid no-op that returns 200 with the unchanged profile. Only the whole-body shape is normalised here; per-field validation (required, non-empty, type) is enforced by each route.
Reactivation opt-out (public)
POST /admin/auth/reactivation/opt-out — the login-free opt-out behind every
member-reactivation e-mail. The mail links
to the SPA page /reactivation/opt-out#t=<token>; the token rides the URL fragment (never sent
to a server, so it is absent from every access log), and the page posts it only when the member
clicks confirm — a GET of the link records nothing, so a mail scanner pre-fetching links cannot
opt anyone out. There is no GET route.
If the opt-out page file cannot be fetched and the page reloads itself, the reload keeps #t=<token> (see A page that reloads itself keeps its fragment under the native app sign-in).
Accepted: a JSON object body { "token": "<string>" } where the token is a signed HS256
credential the platform minted for that member (purpose = reactivation_optout, 60-day expiry),
at most 2048 bytes, naming a live (non-deleted) member. Extra fields are ignored.
Rejected → 400 { "ok": false, "error": "invalid_token" }, nothing written — deliberately one
answer for every failure (no oracle between them): an absent, empty, unparseable or non-object body;
an absent, non-string, empty or oversize token; a malformed, tampered, expired or wrong-purpose
token (a session token or a signup token is refused here exactly as a session verifier refuses a
reactivation token — the purpose claim gates both directions); a token naming an unknown or
soft-deleted member.
Success → 200 { "ok": true }. Idempotent: the first confirm stamps
user.reactivation_opted_out_at and writes one audit event (user.reactivation_opted_out,
actor type user, with the client IP) in the same transaction — if the event cannot be written the stamp is rolled back and the endpoint answers 503 (retry); a repeat is 200 with no second event. An administrative
opt-in does not invalidate the member's token — a renewed objection wins (Art. 21(3)).
Signup-abandonment reminder (public)
A platform-global maintenance sweep (signup_reminder_enabled) — enabled
platform-wide by migration 0354 after the DPO/legal sign-off (integration already; production
when the release lands), though the flag ships dark in code
(AGB/AVV acceptance is not express e-mail consent, §7 UWG), and a platform admin can turn it off
again at any time — sends each unverified, consent-bearing self-serve signup one reminder that re-mints a fresh
30-minute 6-digit code and a 24-hour magic link, so the person can finish. The reminder's link was
requested by no browser, so it is bound to none: wherever it is opened it shows the confirm page first
(Magic-link browser binding). Eligibility is
one-per-email (the newest unverified intent): it excludes intents that recorded no consent (the
pay-first funnel), that are already verified/consumed/in-checkout, that already own an account, that
were already reminded, that are suppressed, and test/fixture addresses; the newest intent must be
1 h–72 h old (past the instant-or-never verify window, well inside the 14-day intent reaper). Bounded
by a per-tick cap (20) and a platform daily cap (signup_reminder_daily_cap, default 100).
POST /admin/auth/signup-reminder/opt-out — the login-free unsubscribe behind every reminder. The
mail links to the SPA page /signup-reminder/opt-out#t=<token>; the token rides the URL fragment
(never sent to a server) and is posted only on confirm — no GET route, so a link-prefetching mail
scanner cannot opt anyone out. If the page file cannot be fetched and the page reloads itself, the reload keeps #t=<token> (see A page that reloads itself keeps its fragment under the native app sign-in). Accepted: a JSON object { "token": "<string>" } where the token
is a signed HS256 credential (purpose = signup_reminder_optout, 30-day expiry) naming the
signup e-mail, at most 2048 bytes. Rejected → 400 { "ok": false, "error": "invalid_token" },
nothing written — one answer for every failure (absent/empty/unparseable/non-object body;
absent/non-string/empty/oversize token; malformed/tampered/expired/wrong-purpose token — a
reactivation_optout token is refused here and vice-versa, the purpose claim gating both; a
non-e-mail subject). No enumeration oracle: the reply never reveals whether that address ever signed
up. Success → 200 { "ok": true }. Idempotent: the first confirm inserts a
signup_reminder_suppression row (a retained Art. 21 objection record — it outlives the signup
intent and is never reaped) and writes one signup_reminder.opted_out audit event; a repeat is 200
with no second row. The suppression and its audit event commit together and the 200 is sent
only after the commit: if the opt-out and its audit event cannot be committed, the answer is
503 { "ok": false, "error": "temporarily_unavailable" } when nothing was written (safe to retry),
otherwise 500 { "ok": false, "error": "internal_error" }. The transactional /signup/request code path never consults the suppression
list, so unsubscribing from reminders never blocks a requested signup code.
Other answers. 429 { "error": "rate_limited" } — a per-client-IP fixed window of 30 requests
per minute on its own bucket (see how the public rate limits behave);
the page shows "try again in a minute", never "broken link". 503 { "error": "temporarily_unavailable" }
— a database fault; this is never disguised as invalid_token, because it does not depend on the
token.
Demo contact capture
💡 Note: The public no-login demo entry is disabled (
POST /admin/auth/demo-login→404), so no newdemousersessions can start. Thedemouserrole and the endpoint below remain for any session already issued before the cut-off (valid until its natural expiry); the documented behaviour applies to such a live session only.
The no-login demo (role demouser) collects a prospect's contact details once per visit, before it may send any prompts. GET /admin/auth/me returns demo.contact_needed: true until the form is submitted this visit; the SPA shows a mandatory modal while it is true.
Mobile environment switch flag
GET/PATCH /admin/auth/me (and the /otp/verify login payload) carry can_switch_mobile_env — a 0|1 integer, server-derived from the per-user mobile_env_switch column (default 0). It is 1 only for a test user an operator has explicitly entitled; it drives the mobile app's Production/Integration environment switcher, which the SPA renders only when the flag is 1 and the native app bridge is present.
Accepted shape / what is rejected (trust boundary). The field is server-authoritative and read-only on this payload — the client cannot set it (PATCH /admin/auth/me ignores any mobile_env_switch/can_switch_mobile_env in the body; it is not a writable profile field). The serializer normalises the stored value with the house nonzero → 1 rule and fails closed to 0 for an absent, NULL, or non-numeric value, so a corrupt row hides the control rather than exposing it.
It is a UX visibility gate, not a security control. The Integration backend enforces its own login; a user who is not a test user there cannot authenticate even if they reach it. The flag only decides whether the switcher is shown — the client is never the authorization boundary. To entitle a tester, set `user`.mobile_env_switch = 1 in the production database.
GET/PATCH /admin/auth/me (and the /otp/verify login payload) also carry tenant_live_transcription_enabled — a 0|1 integer: whether the caller's workspace has live_transcription_enabled on. It is server-authoritative and read-only (a PATCH body value is ignored) and is computed with the same flag predicate as the live-transcription relay's entitlement check (GET /admin/v1/chat/transcribe/stream, 4403 not_entitled), so it is never 1 where the stream would be refused. A user without a workspace, an absent or non-numeric stored value gets 0 (fail closed). Clients use it to decide whether to offer live transcription; the stream itself still refuses a non-entitled workspace with not_entitled / 4403, whatever a client does.
GET/PATCH /admin/auth/me (and the /otp/verify login payload) also carry tenant_voice_mode_enabled — a 0|1 integer: whether the caller's workspace has the voice mode (spoken conversation, /admin/v1/chat/voice) enabled. It is server-authoritative and read-only (a PATCH body value is ignored) and is computed with the same flag predicate as the voice stream's entitlement check (4403 not_entitled), so it is never 1 where the stream would be refused. A user without a workspace, an absent or non-numeric stored value gets 0 (fail closed). Clients show the voice button only for exactly 1; the stream itself still refuses a non-entitled workspace, whatever a client does.
GET/PATCH /admin/auth/me (and the /otp/verify login payload) also carry tenant_answer_corrections_enabled — a 0|1 integer: whether the caller's workspace allows correcting AI answers. It is server-authoritative and read-only (a PATCH body value is ignored). A user without a workspace gets 1 (no workspace policy applies); a failed read or a malformed stored value gets 0 (fail closed). Clients show the Edit this answer action only for exactly 1; the server enforces the policy on the write whatever a client does.
tenant_approval_ttl_default_s — GET/PATCH /admin/auth/me (and the /otp/verify login payload) also carry the caller's organisation default approval waiting time for new agents, in seconds (a whole number from 300 to 604800; see Default approval waiting time for new agents). It is omitted when the organisation has not set one, when the caller has no organisation, or when the tenant cannot be read. A stored value outside 300–604800 (only possible by changing the database directly) is served as 300, the value a new agent is then created with. It is server-authoritative and read-only (not a writable profile field). Clients use it only to preselect and name the default in the agent editor and the external-agent wizard; the server applies the default to a create that carries no ttl_seconds (the web app always sends the value it shows).
| Method | Path | Auth | Description |
|---|---|---|---|
POST |
/admin/v1/demo/contact |
Session cookie (role demouser) |
Store one contact lead, then mark this visit's form as submitted (demo.contact_needed flips to false). |
This is the single write the demo identity is permitted besides ghost conversation creation and inference-token minting; every other write is rejected with 403.
Accepted body — a JSON object with exactly these string fields, each required and non-empty after trimming:
| Field | Max length (bytes) | Notes |
|---|---|---|
full_name |
200 | |
email |
320 | Must match local@domain.tld (a liberal shape check, not a deliverability check). |
company |
200 | |
phone |
60 | Digits, spaces and + ( ) . / - only, with at least one digit; otherwise 400 phone invalid. |
Rejected (400): any field with control/format characters or invalid UTF-8; a missing, non-string, empty/whitespace-only, or over-length field; a malformed email. Rejected (403): any caller whose role is not demouser. On success the endpoint returns 201 { "ok": true }; leads are append-only (each submission is a new row) and carry no conversation content.
In the app the form is its own page, /easy/demo/contact: while /me reports demo.contact_needed (and the demo is not locked), the chat sends the demo user there, and after a successful submit the page re-reads /me and returns to /easy. The page has no dismiss action. Opened by a demo user who no longer needs to give contact details, it returns to /easy; any other role sees the No access page there. Once the demo prompts are used up, the chat shows a lock dialog that cannot be closed (no close button, Escape and a click outside do nothing); it offers Contact Myra and Already a customer? Sign in.
CI session grant (non-production only)
POST /admin/auth/ci-session mints the same aig_admin session an interactive login mints, for an allowlisted synthetic test identity — so automated test rigs authenticate reliably without driving the login UI. It exists only to make test auth deterministic; it is not a production feature and is designed so a leaked credential cannot become a standing backdoor.
It does not exist on production. The route is dual-gated, fail-closed, and returns a 404 — byte-identical to an unmounted route — unless both hold:
- The runtime environment is
devorint(utils.env.name(); an allowlist, so a future staging tier also fails safe). This gate is structural and cannot be flipped by a configuration slip. - The
auth.ci_sessionconfig block is present — configured only by Myra on int/dev deployments and never in the production environment.
The minted session carries amr = ["pwd","otp"] (so it will satisfy mandatory Myra-admin MFA once that is enforced, without an exemption) and the ci claim; the ci claim, not amr, is what marks it as a CI session. As a third backstop, verify_session_jwt rejects that ci claim on any tier other than dev/int — so even under a shared-JWT-secret mistake a CI session cannot authenticate production. A static lint (scripts/lint_no_ci_session_in_prod.sh) fails the build if a prod config or .env.production* ever wires the block, or if the int and prod JWT secrets are equal.
Auth (trust boundary). Authorization: Bearer <secret> — exactly that shape: the scheme Bearer (case-insensitive, RFC 7235), one space, then the secret (no whitespace or control characters, at most 4096 bytes). Only the sha256 of the secret is stored server-side (in config); the plaintext lives solely in CI vaults; the comparison is constant-time (both sides hashed, no length oracle). Rejected 401 (never throws): an absent header; the secret without the Bearer prefix; another scheme (Basic …); two spaces, a tab, or any whitespace inside or around the token; an empty token; a non-string value; and a repeated Authorization header — it is refused outright, never collapsed to its first value (the gateway's HTTP front end already answers a duplicated Authorization header with 400 before the endpoint runs). A wrong secret in the correct shape is also 401. Wrong/absent-secret attempts are not audited (unattributable) but are rate-limited per source IP (10 failures / 300 s → 429); a successful grant is never counted.
Accepted body — a JSON object:
| Field | Type | Notes |
|---|---|---|
email |
string, required | Canonicalised like the sign-in routes (trimmed, ASCII lower-cased). Must be an exact member of the configured allowlist AND end in @local.test (the synthetic-test domain). The identity must already exist; the endpoint never creates users. |
ttl_minutes |
integer, optional | Session lifetime, clamped server-side to [1, 60] (default 15); any out-of-range or non-numeric value falls back to the default (a NaN / Infinity / 1e999 literal is refused by the body parser, 400 malformed_body). |
Rejected: an absent, non-string or empty (after trimming) email → 400 (no identity asserted — nothing counted or audited); a malformed email (non-ASCII or control byte, inner whitespace, no single @, raw length above 254 bytes) is an asserted identity that can never be allowlisted and takes the same path as an unlisted one — 403, counted against the per-IP failure window and audited; an email not in the allowlist, not @local.test, or resolving to no/disabled account → 403; a transient DB fault → 503 (nothing minted). On success: 200 with a Set-Cookie: aig_admin=… (scoped to this admin-API host) plus a JSON body { token, max_age, expires_at, email } for non-browser consumers (e.g. a native WebView) — never the secret. Every successful grant and every post-authentication denial is written to audit_log (auth.ci_session_issued / auth.ci_session_denied) with the actor and IP but never the secret, token, or email.
Consumers are non-browser only (test-runner HTTP clients / curl): the admin-API CORS preflight allows only Content-Type, so a browser fetch sending Authorization fails preflight by design.
Self-serve sign-up (pay-first)
The public self-serve funnel lets a new customer verify an email, pick a plan, pay through Stripe Checkout, and land in the product — no operator provisioning. It is a distinct credential chain from the OTP login above: a short-lived signup JWT (in the aig_signup cookie, purpose=signup, scoped to /admin/auth/signup/) that the session verifier explicitly refuses, and that is swapped for the real aig_admin session only once payment has provisioned the tenant.
All of the self-serve endpoints below are gated by a deployment-level self-serve switch. When it is off every one returns 404 (indistinguishable from an unmounted route); the kill-switch stops new sign-ups only — the Stripe webhook keeps provisioning already-paid checkouts.
A second, narrower control governs only the paid entrance: the global platform setting paid_signup_enabled (a DB-backed Feature flag, platform-admin only, default off). When it is off — the default — the plan picker is not offered and a new customer starts on the free trial; and POST /admin/auth/signup/checkout is refused server-side (404, fail-closed), so hiding the UI is not the only guard. A platform admin turns it on from the Feature Flags section at the top of Account › User Management › Organisations; the setting is read per request (and the write invalidates the cross-worker cache), so it flips immediately with no restart or rebuild. GET /admin/auth/signup/legal reports it to the sign-up page as paid_signup_enabled. (It replaces a former deployment flag, which is retired.)
Turning paid sign-up off removes the direct paid entrance only. It does not affect the trial-to-paid conversion (POST /admin/v1/billing/checkout), which is how a trial workspace subscribes and remains available throughout.
| Method | Path | Auth | Description |
|---|---|---|---|
POST |
/admin/auth/signup/request |
Public | Step 1 (guarded by the EU Captcha when it is switched on; OAuth registration is exempt): send a 6-digit verification code (30-min, single-use) to an email that can be registered. The trial sends the email + the affirmative AGB/AVV consent here — recorded on the intent at step 1 (before the OTP verify). The paid funnel sends email-only here (its consent is recorded later at signup/checkout). The name/voucher fields are gone (email-only). A present-but-malformed consent → 400; consent is validated before the existing-account lookup, so it is never an enumeration oracle. Always returns the same generic message. A consented request supersedes the address's older open sign-ups that carry no consent (see Superseded codes). The sign-up is written in one retried transaction; if the transaction could not run (concurrent writes for the address on every retry, or the database was unreachable before anything was written), any request answers 503 { "error": "signup_busy" } with Retry-After: 2 — nothing stored, no mail sent, re-request. Browser binding: every request that passes validation and the rate limits (new and existing addresses alike) gets a Set-Cookie: __Host-aig_signup_nonce=… and the link in the mail is bound to it — Magic-link browser binding. |
POST |
/admin/auth/signup/verify |
Public | Verify the code. Code shape (checked first, before the rate limit and any database read): an absent, non-string/non-number code or one whose raw length is above 64 bytes is 400 { "error": "email and code are required" }; after trimming ASCII whitespace the code must be exactly 6 ASCII digits, else 400 { "error": "invalid or expired code", "code": "invalid_otp" }; neither is counted as a guess. On success sets the aig_signup cookie (HttpOnly; Secure; SameSite=Strict; Path=/admin/auth/signup/, 24 h). the code is matched against every open (unconsumed, unexpired) intent for the email, not only the newest — a superseded one included, which is answered as such — so a resent code no longer strands the user (previously only the most recent code worked). The match is a constant-time compare per live row, with a dummy-hash compare when there is none, so a wrong code and a missing intent stay indistinguishable by timing. The code of a superseded sign-up answers 410 code_superseded (or 409 when the address already has an account) and is not verified. |
POST |
/admin/auth/signup/verify-link |
Public | verify via the single-use magic link instead of typing the code. Body { token } — a 43-char base64url token that rides the signup email's URL fragment (/signup#token=…) and is POSTed by the SPA (only once the visitor's session is known and absent — a browser that is already signed in never consumes a sign-up link, so the link can never replace that person's session; never a GET, so the token never reaches nginx access logs or the Referer header). On success sets the same aig_signup cookie as /signup/verify. ABSENT, malformed, unknown, expired and already-used tokens all return the one generic 400 { "error": "invalid_or_expired" } — no enumeration oracle (invariant 11). The one exception is the still-unused link of a superseded sign-up: 410 code_superseded (409 when the address already has an account) — only a holder of that exact 256-bit token can reach it, so it reveals nothing they do not know; the link is not consumed. Single-use: a successful verify NULLs the stored token hash, so a second click (or a replay) matches nothing and is inert. A coarse global ceiling bounds random-token load; there is no per-IP cap (the IP bucket is the client-controlled X-Forwarded-For), and the 256-bit token makes guessing infeasible. the link has its OWN expiry (signup_intent.link_expires_at, read as COALESCE(link_expires_at, code_expires_at) so a row minted before the column existed still verifies within its 30-min code window) — 30 minutes at signup, extended to 24 hours only when the signup-abandonment reminder re-mints it; the re-minted 6-digit code stays 30 minutes (a 24-hour 6-digit code would be guessable). Bound to the requesting browser: answered before any binding decision only for a superseded link; otherwise the link verifies at once only in the browser that asked for it (__Host-aig_signup_nonce), opened elsewhere it is 428 link_confirm_required with the address (nothing consumed; "confirm": true verifies), and a malformed or another browser's cookie is 403 link_other_browser — Magic-link browser binding. |
POST |
/admin/auth/signup/checkout |
aig_signup cookie |
The paid account-creation step: validate + record the AGB/AVV consent (moved here from request), then create (or resume) a Stripe Checkout Session for the chosen catalog plan, interval and seats; returns its URL. Refused with 404 when the paid_signup_enabled platform setting is off (the direct paid entrance is closed — the trial-to-paid conversion is unaffected). The session of a superseded sign-up answers 410 code_superseded (409 when the address already has an account) before any consent is recorded or any Stripe session created; a consent write that loses a race to a supersede is re-read and answered the same way; retries exhausted on that write → 503 signup_busy. |
POST |
/admin/auth/signup/trial |
aig_signup cookie |
The trial account-creation step: takes no body — the affirmative AGB/AVV consent was recorded at step 1 (signup/request). Provisions a real tenant directly (no Stripe) from the intent and swaps the signup cookie for the real aig_admin session. A consent-less (email-only) intent is answered 422 consent_required before anything is provisioned (410 code_superseded when the address has since made a consented request — Superseded codes), and the provisioning choke point independently refuses any intent whose consent snapshot is absent or malformed, so it can never become a trial. |
GET |
/admin/auth/signup/status |
aig_signup cookie (optional) |
Poll provisioning. Once provisioned, swaps the signup cookie for the real aig_admin session. |
GET |
/admin/auth/signup/legal |
Public | Legal-acceptance readiness — { avv_required, avv_version, terms_version, paid_signup_enabled, captcha_required }. captcha_required (boolean) is true exactly when signup/request enforces the EU Captcha. The sign-up page shows the widget unless it is false. terms_version is the server-pinned current Terms/AGB version the page displays and echoes; both avv_version and terms_version are read per request from the DB-backed settings store (a platform admin flips either live, no rebuild). |
GET |
/admin/auth/signup/catalog |
Public | The product catalog the sign-up page renders (plans, prices, seat limits, add-ons, top-ups) — see below. |
signup/request
email + consent step 1. Registration is a two-step funnel: step 1 asks for the business email and the single merged AGB/AVV consent checkbox; step 2 is the OTP; verifying auto-provisions the trial. The trial sends its affirmative consent HERE, so it is recorded on the intent at step 1 — before the OTP verify, and never after an account exists. The paid funnel sends email-only here and records its consent later at signup/checkout (consent at the pay button); its intent is created with a NULL consent snapshot that the provisioning choke point refuses until checkout records it. The name field was removed entirely (email-only). The voucher field was removed from the DEFAULT funnel, with one documented exception: a campaign link carrying ?voucher= reveals an optional voucher-code field on the trial's email step, and its code is submitted here as voucher_code. See AVV acceptance and the provisioning guard below.
Accepted body — a JSON object:
| Field | Rules |
|---|---|
email |
Required. Canonicalised exactly like the sign-in routes (surrounding whitespace trimmed, ASCII letters lower-cased; printable ASCII only — a non-ASCII or control byte, inner whitespace, or a raw length above 254 bytes is rejected) and must additionally match a pragmatic local@domain.tld shape (single @, dotted domain, no leading/trailing/double dots). One address policy at both boundaries: an address that could not sign in by one-time code cannot be signed up either. |
consent_terms_version |
Sent by the trial (the paid funnel omits it → email-only). Its presence is the "I accept the current terms" signal; when present it is validated fail-closed: 1–32 chars of [A-Za-z0-9 . - _ :]; a malformed value (non-string, empty, too long, bad charset, or JSON null) → 400. The value is NOT trusted: the version RECORDED on the intent is the server-pinned terms_current_version (DB-backed setting, served by /signup/legal), never the client's string — the client is not the authz boundary, and a stale/forged client can no longer pin an arbitrary version onto the legal record. When absent (Lua nil), the intent is created email-only (NULL consent — the paid path). Absent ≠ malformed (invariant 11): a malformed value is rejected, never degraded to the permissive email-only path, and an email-only intent can never provision (the choke point refuses NULL). Validated before the existing-account lookup, so the 400/200 split does not depend on whether the email is registered — no enumeration oracle. |
avv_accepted |
Required to be boolean true when consent is present and AVV is active (the default); absent/non-true → 400. Ignored when no consent is sent (paid path) or when AVV is dormant. |
locale |
Optional; en or de (default de). Stored on the intent — every later lifecycle email keys off it. |
voucher_code |
Optional campaign voucher code, sent by the trial funnel's ?voucher=-gated field and — typed before the click — by the Google / Microsoft /start. Shape-normalised before any DB touch: trimmed, upper-cased, and accepted only as 4–64 characters of [A-Z0-9_!?.-] (an input longer than 256 bytes before trimming is rejected outright, never trimmed). Absent and malformed deliberately share one outcome — the column is stored NULL and the signup proceeds — because that shared outcome is the RESTRICTIVE one: no code on the intent means no code on the tenant and nothing to redeem, so the collapse cannot authorize a grant (invariant 11). The response is byte-identical either way: answering differently for a malformed code would make this route an oracle for which code SHAPES exist. Storing it is not granting it — redemption re-validates authoritatively under a row lock later. |
ref |
Optional affiliate referral code (see below). Resolved at request time and locked as the lifetime attribution — it attaches to the first touch, independent of consent. |
signup_source |
Optional campaign source object — see Signup campaign source. Absent → nothing stored; malformed → 400 { "error": "invalid signup_source", "detail": "<reason>" }, validated right after the email shape check (before every rate limit, the captcha and the account lookup — the same answer for registered and unregistered addresses). |
eu_captcha_response |
The single-use token the sign-up page's EU Captcha widget produces. Required only while the captcha is on (AIG_EUCAPTCHA_SECRET set — reported to the page as captcha_required by signup/legal); ignored while it is off. A string of 1–4096 bytes with no whitespace or control characters. Absent, null, "", a non-string (number, boolean, array, object) and any badly-shaped string are all rejected with 400 captcha_failed — none of them is ever sent to the vendor, so they cannot pass. |
Content-Type gate: the request must carry Content-Type: application/json (parameters such as ; charset=utf-8 allowed, case-insensitive). A form or text/plain or multipart/form-data post, an absent header, and a repeated header (nginx joins repeats with ,, so application/json, text/plain no longer matches) all answer 400 { "error": "content type must be application/json", "code": "unsupported_content_type" } before the body is read — nothing is stored, no mail is sent. This shuts the door a cross-site CORS "simple request" (a <form enctype="text/plain"> or a no-cors fetch, which skip the preflight) would otherwise use to mint a signup intent and fire an OTP mail in a victim's IP bucket. It is the same gate …/start carries, shared via admin.helpers.require_json_content_type (one implementation). Absent and malformed share this one restrictive 400 by design — the request never proceeds either way (invariant 11).
Busy (503 { "error": "signup_busy" }, Retry-After: 2): the sign-up (and, for a consented request, the supersede of the address's older consent-less sign-ups) is one database transaction the server retries itself; only when the transaction could not run (every attempt collided with concurrent writes for the address, or the database was unreachable before anything was written) does it answer 503 — nothing was stored and no mail sent, so send the request again (the attempt still counts toward the per-address and per-IP hourly limits).
Retryable database fault (503 { "error": "temporarily unavailable; retry later" } with Retry-After): any sign-up route answers this, instead of 500, when its database read or write failed with a fault the server classifies as retryable and, for a write, provably applied nothing. Send the same request again; for signup/status keep polling. Every other fault is the genuine 500 { "error": "internal error" }. See Error codes.
Rejected (400): missing/non-string/malformed email; while the captcha is on, a missing/malformed/rejected eu_captcha_response ({"error":"captcha_failed"}; 503 captcha_unavailable when no verdict can be obtained); an email whose domain is on the static in-code disposable-domain blocklist (e.g. mailinator.com, guerrillamail.com, 10minutemail.com, yopmail.com, temp-mail.org, and ~25 more); a present-but-malformed consent_terms_version; or (consent present + AVV active) an avv_accepted that is not boolean true. Rejected (429): more than 5 requests/hour per email or 20 requests/hour per IP. The account-creation step signup/trial that hits the trial limits is also answered 429 with an unchanged error text plus a machine-readable code: trial_limit_domain (per-email-domain daily cap) or trial_limit_network (per-IP daily limit, counted per IPv4 address or IPv6 /64, replaceable by a matching sign-up exception on int/beta).
Which URL parameters survive in-app navigation
Funnel entry state (h). ?voucher=, ?ref= and ?lang= are funnel entry state: each is read once and cannot be recovered once dropped. voucher and ref are read when the signup page mounts (voucher by presence only, ref by value); lang is read by the language detector at app init, i.e. on a document load — which is why dropping it matters on a reload, a back/forward or a middle-click rather than on the in-app hop. The Create account / Sign in switch therefore rebuilds both of its targets from the current query, and those three parameters — and only those three — travel across a /signup ⇄ /login round trip. It is a named allow-list, not a merge: oauth_error, error, canceled, session_id, next and tenant are deliberately dropped, because each belongs to one specific navigation and carrying it would pin a stale banner, a stale resume, or a stale return target to the funnel.
?trial=1 is always emitted by the Create account target rather than carried, so that tab means "the no-card trial funnel" whatever the current URL says.
A carried, SUPPORTED ?lang= outranks a signed-in user's saved language for that session. The language detector reads the querystring before anything else, and the account's stored locale is applied only when the URL carries no ?lang= — or carries one the application does not support. So signing in from a campaign link with ?lang=de gives that session a German interface even if the account is set to English, while ?lang=zz is ignored and the account's own language applies (a value that arrives wrong is treated like one that never arrived, never as a valid one). This is intended: the parameter is the visitor's most recent explicit choice (the card they scanned, or the language pill on the screen in front of them), and it is the same precedence the language pill on the sign-in screen has always had. It is not sticky — any in-app navigation drops the parameter, and the next reload applies the account's own language.
The carry moves the parameter, never its meaning: ?voucher='s presence reveals the voucher field and its value is still never read as a code (the field is always empty and always typed by hand), so a shared campaign link cannot spend someone else's voucher no matter how it is navigated. Two paths still lose the parameters and are documented as such in the signup guide: the page-footer legal links, and an OAuth sign-up denial (whose return URL is built server-side).
AVV (Art. 28 data-processing agreement) acceptance
The /avv page serves the DPO-approved binding AVV verbatim (Version 1.1.1 / 21.08.2026, German — the German version is the sole legally binding one per its §13, so it is shown in every UI language; an English translation is pending and, until it lands, an on-page notice states the German version is authoritative).
Where consent is captured. The single merged AGB + AVV checkbox is affirmatively accepted (unchecked by default) and recorded on the signup_intent (consent_terms_version, consent_at, avv_version) before any tenant is provisioned — but at a funnel-appropriate step:
- Trial → at step 1 (
POST /signup/request): consent rides the email step and is recorded immediately, so the account (created only after the step-2 OTP verify) is never created without it. - Paid → at the pre-payment obligation step (
POST /signup/checkout): consent sits with the pay button, recorded before the Stripe session is created (the webhook that provisions later trusts this snapshot).
Both places validate fail-closed via ONE shared validator: a well-formed consent_terms_version (1–32 chars, [A-Za-z0-9 . - _ :]) and, while AVV is active, avv_accepted: true; a malformed consent rejects with 400. The client's consent_terms_version value is only an acceptance signal — the version recorded is the server-pinned terms_current_version (see below), not the client's string. The two funnels write the same intent columns (one source of truth), differing only in when the earliest affirmative step occurs. A defence-in-depth guard at the single provisioning choke point (_provision_tenant_stack, shared by the trial path, the OAuth sign-up path and the paid Stripe webhook — which runs no consent check of its own) refuses to create a tenant whose consent snapshot is NULL, so no account can ever exist without a recorded consent (the columns are nullable per migration 0343; this guard is the structural replacement for the retired NOT NULL).
The server-pinned current AVV version is the DB-backed platform setting avv_current_version (read per request via the shm-cached settings store, so a platform admin flips it live via PUT /admin/v1/settings with immediate effect — it is no longer a deployment setting). It defaults to 2026-08-21 ⇒ active by default: an absent/empty row falls back to that code default, so the account-creation step requires avv_accepted: true and snapshots the server version onto signup_intent.avv_version; at provisioning that snapshot is projected into the consent_record table (document='avv', server version, accepted_at, accepted_ip, linked tenant_id/user_id) inside the provisioning transaction. consent_record is the authoritative, per-document AVV acceptance evidence. The accepted version is server-pinned (never client-supplied). A malformed stored value (over 32 chars, out of the [A-Za-z0-9 . - _ :] charset, or empty after trim) fails safe to the code default 2026-08-21 (never dormant) and is logged as an error; the settings PUT validator rejects such values at the boundary, so a bad version cannot be stored through the API. Dormant-by-default is retired — an admin cannot disable acceptance by blanking the key (clearing restores the active code default).
The Terms/AGB version is pinned the SAME way: the DB-backed platform setting terms_current_version (shm-cached, read per request, flipped live via PUT /admin/v1/settings), served to the sign-up page by /signup/legal as terms_version and snapshotted onto signup_intent.consent_terms_version for both sign-up funnels and the OAuth sign-up. It defaults to 2026-08-10 (an absent/empty row falls back to that code default); the client's submitted consent_terms_version is only the acceptance signal and is never stored, so a stale or forged client can no longer pin an arbitrary version onto the legal record. A malformed stored value (over 32 chars, out of the [A-Za-z0-9 . - _ :] charset, or empty after trim) fails safe to the code default 2026-08-10 and is logged as an error; the settings PUT validator (shared with avv_current_version) rejects such values at the boundary.
Retention: on tenant hard-delete the row is retained (accountability, §195 BGB limitation period) — hard_delete_tenant stamps tenant_deleted_at and the purge reaper deletes it once older than the configured consent-retention window (default 3 years); subject_email + accepted_ip are kept unscrubbed because they are the evidentiary payload.
GET /admin/auth/signup/legal returns { "avv_required": boolean, "avv_version": string, "terms_version": string, "paid_signup_enabled": boolean, "captcha_required": boolean } (the AVV pair derived from the avv_current_version setting per request) so the sign-up page can render the acceptance line only when active. With the active-by-default setting, avv_required is true and avv_version is the pinned version (default 2026-08-21). It 404s when self-serve is off, like every signup route.
The VAT wording of the pricing page and the obligation screen comes from each price's tax_behavior in signup/catalog (the former price_tax field is gone).
The optional voucher_code (a redeemable trial-credit code ^[A-Z0-9_!?.-]{4,64}$, case-insensitive) is accepted only on the paid funnel's signup/checkout step. The manual voucher field was removed from the trial, then restored for campaign traffic only: the no-card trial shows a voucher field only when the entry URL carries ?voucher=, and that code is submitted at signup/request (above) rather than here. The default trial funnel is still email-only with no promo-code entry. The affiliate ?ref= attribution (below) is a separate, unaffected mechanism. A malformed value is dropped and the checkout proceeds unaffected (it never blocks the funnel); a well-formed code is stored on the intent and redeemed authoritatively once the tenant is provisioned. See Vouchers.
The body also accepts an optional ref: an affiliate referral code (^[A-Z0-9-]{4,64}$, case-insensitive on input) carried from a partner's referral URL. It is resolved at request time to an active partner and the resolved partner id — never the code string — is stored on the signup intent, then copied onto the provisioned tenant as referred_by_partner_id (with referred_at), establishing the lifetime attribution used by the partner dashboard. Fail-closed to no attribution: an absent, malformed, unknown, or suspended-partner ref all resolve to a NULL attribution and the signup proceeds — the shared outcome is the restrictive one (no partner is credited), so a wrong/garbage code can never credit a partner it does not name. A transient DB fault during the optional lookup is best-effort (the signup still proceeds, unattributed). Non-string values (e.g. a JSON object) are rejected by the shape check. The referral code is a marketing/lookup handle only; the durable attribution is the partner id, so a partner renaming its code never affects past attributions.
Attribution covers both funnels. A prospect who clicks a ?ref=//r/<code> link and then registers via OAuth (Google/Microsoft) is attributed exactly like the e-mail funnel: the aig_ref cookie set by the click is read at POST /admin/auth/<provider>/start (the credentialed same-site POST — where the cookie is reliably present, unlike the cross-site provider redirect to the callback), resolved through the same normalise + active-partner resolver, carried through the server-side oauth_state payload to the callback, and stamped onto the provisioned tenant as referred_by_partner_id. The same fail-closed rule applies (malformed / unknown / suspended / DB-fault → no attribution, the signup proceeds). The partner-facing surface is documented in Partner dashboard.
Signup campaign source
For the per-channel signup KPI the application captures, on the first page load of the tab, the campaign parameters of the landing URL and the host of the referring site, keeps them in memory only (no cookie, no localStorage / sessionStorage — storing them on the device for analytics would need consent under § 25 TDDDG) and sends them as the optional object signup_source on POST /admin/auth/signup/request (every call: first submit, resend, consent-step recovery) and on POST /admin/auth/{google,microsoft}/start. What the application reads: utm_source, utm_medium, utm_campaign, utm_term, utm_content (each falling back to its Matomo twin mtm_source / mtm_medium / mtm_campaign / mtm_keyword / mtm_content); the type of an advertising click ID — gclid, gbraid, wbraid (Google Ads; the last two are its iOS click IDs), msclkid (Microsoft Advertising), oppref (ChatGPT / OpenAI ads), li_fat_id (LinkedIn ads), rdt_cid (Reddit ads); one per sign-up, the first non-empty one in that order — and its value (click_id, trimmed; sent only when it passes the rule below, otherwise only the type is sent); and the host of document.referrer, omitted when it is funnel-internal — the application's own host or API host, a Google / Microsoft sign-in host (accounts.google.com, login.microsoftonline.com, login.live.com), Stripe (checkout.stripe.com, billing.stripe.com) or a common webmail front-end the verification mail is opened in (mail.google.com, outlook.live.com, outlook.office.com, outlook.office365.com, mail.yahoo.com, navigator.web.de, navigator.gmx.net, mail.proton.me): a page load returning from one of those is a step of the sign-up, not the channel — or not a public host name. utm_id and every other parameter are ignored.
Accepted shape (all keys optional; unknown keys are ignored and never stored):
| Key | Rules |
|---|---|
utm_source, utm_medium, utm_campaign, utm_term, utm_content |
A string of valid UTF-8. Normalised before validation: C0 control characters, DEL, C1 controls (U+0080–U+009F) and the invisible format / separator characters that could disguise or split a displayed value (zero-width U+200B–U+200F, line/paragraph separators U+2028–U+2029, bidi embeddings/overrides U+202A–U+202E and isolates U+2066–U+2069, U+FEFF) are removed and surrounding ASCII whitespace is trimmed. At most 128 code points after normalisation. A value that normalises to "" is stored as NULL (it carried no campaign value). |
click_id_type |
Exactly one of gclid, gbraid, wbraid, msclkid, oppref, li_fat_id, rdt_cid, none (case-sensitive). none means "a source was captured, without a click ID"; on its own it carries nothing and is treated like an empty object. |
click_id |
The click-ID value. A string of 10–255 characters of A-Z a-z 0-9 _ - whose first character is a letter or digit (so a stored value can never start with a spreadsheet formula character = + - @), sent together with a click_id_type other than none — every click type keeps its value (the observed formats fit: oppref 120 characters, rdt_cid 19 digits, li_fat_id a UUID, gbraid / wbraid base64url). Stored verbatim, always as a string. |
referrer_host |
A bare public host name, lower-cased by the server: at least two dot-separated labels, each 1–63 characters of a-z 0-9 - not starting or ending with -; at most 255 characters; the last label is not all digits (no IPv4 literal) and the host does not end in an internal suffix (.local, .localhost, .internal, .intranet, .lan, .home.arpa, .corp, .localdomain). No scheme, path, port, user info, IPv6 literal, whitespace, empty label or trailing dot. The suffix rule is a privacy filter against disclosing intranet host names; it cannot recognise an intranet on a public domain (e.g. wiki.example.com). |
Absent ≠ malformed (invariant 11). An absent signup_source (key omitted), an empty object, and an object whose only key is click_id_type: "none" store nothing — every column stays NULL and the sign-up behaves exactly as before. A malformed one is rejected with 400 { "error": "invalid signup_source", "detail": "<reason>" } and nothing is stored, no mail sent, no OAuth correlation or cookie created: signup_source that is not a JSON object (null, an array incl. [], a string, a number, a boolean); a utm_* value that is not a string (incl. null), not valid UTF-8, or longer than 128 code points after normalisation; a click_id_type outside the list; a click_id that is not a string, breaks the length / character rule, or comes without a real click type (click_id_type absent or none); a referrer_host that is not a string or breaks the host rule. One malformed key rejects the whole object (no partial store). detail is a fixed message naming the key — never an echo of the submitted value. The application applies the same normalisation and limits itself and omits whatever would not pass, so a real visitor never meets this 400; if it ever does (a client/server rule drift), the application repeats the request once without signup_source and reports the drift — attribution never costs a sign-up. On /signup/request the check runs before the rate limits and the captcha, so that repeat costs neither a rate-limit slot nor the single-use captcha token.
Signup country. Alongside the campaign source the gateway records the country the
registration came from — only from the X-Myra-Client-Country request header that the Myra CDN sets
on the admin-API host from its GeoIP lookup of the connecting address, and only while the platform
setting signup_country_header_trusted is on (default
off: the header is forgeable on any request that does not pass through the CDN rule). Accepted
shape: exactly two capital letters A-Z (an ISO 3166-1 alpha-2 code), surrounding whitespace
trimmed; anything else — absent, empty, lowercase, three letters, digits, a header sent twice — is
stored as unknown (NULL), never rejected (it never blocks a sign-up). It rides the intent
(signup_intent.country) and is copied to tenant.signup_country at provisioning on every path
(e-mail trial, OAuth, native-app redeem, paid checkout); each attempt keeps its own capture (a
weaker later attempt does not inherit an earlier attempt's country). It is shown in the
Art. 15 export of the registration and used only for
the region breakdown of the growth statistics.
Where it is stored. The parsed values ride the signup intent (signup_intent.utm_source … referrer_host, click_id; click_id_type is an enum) and are copied onto the provisioned tenant (tenant.signup_utm_source … signup_referrer_host, signup_click_id) inside the provisioning transaction — on every path (e-mail trial, OAuth trial, paid checkout via the Stripe webhook) — so they survive the intent clean-up. Which capture counts when an address makes several attempts: the strongest signal wins, ties go to the newer request — a campaign signal (any utm_* value or a real click-ID type) beats a referrer-only capture, which beats nothing. It is settled when an intent is written (/signup/request, before the address's expired attempts are cleaned up, and the OAuth callback): a request whose own capture is weaker — e.g. a resend from a later page load with nothing left in memory — takes over, whole and never mixed, the source of the address's strongest unconsumed attempt of the last 24 hours, even if that attempt's 30-minute code has expired. A newer request with its own campaign keeps it. So the intent row always holds the effective source, and the tenant copy equals the provisioned intent's row (which the Art. 15 export shows). The values are never shown in an HTML page; the offline KPI report escapes them. Known limits: an OAuth registration that is bounced back to the register page (consent_required) and restarted from that reloaded page carries no source unless an earlier attempt of the address did; and a person who makes a weaker attempt and then a newer one with its own campaign, but verifies the OLDER attempt's code, provisions the older attempt's (weaker) source — the source is settled per attempt when it is written. Because a weaker attempt takes over a stronger one whole, a click ID of another attempt of the same address (within 24 hours) can become the registration's click ID; someone who passes the captcha could plant one for another person's address, which can only misattribute a conversion.
Ad-conversion events
Registrations and purchases are reported to the advertising platforms in real time from the browser: the web application pushes one event per conversion into the Matomo Tag Manager data layer, and the platforms' tags in that container (Google Ads, Microsoft Advertising, ChatGPT ads, Reddit, LinkedIn — configured by marketing) send it. Nothing is uploaded and no server calls a platform. Consent for these tags is obtained upstream on www.myrasecurity.com and was reviewed by Myra's compliance department; the application shows no consent banner of its own. The tags read their own click ID from the ad's landing URL (or their cookie), so the stored click ID of the campaign source is not needed for this.
Data-layer contract (the interface marketing's container is built on):
| Event | Keys |
|---|---|
aiws_public_page — at every route change to a public page |
No keys. Pushed only when the current route is a public acquisition page (/login, /signup, /signup/success, /privacy, /tos, /avv, /impressum, /trust, /demo), its address carries nothing private (no next, user_code, nonce or tenant query key, no key=value fragment) and the browser is not the native iOS / Android app. This event is the only trigger for the platforms' page-view tags — so a tag can never fire on a workspace page, on a sign-in page reached by an in-app redirect that carries a return path, or inside the app. |
aiws_conversion — once per conversion |
aiws_conversion: registration or purchase; aiws_purchase_kind: signup (paid sign-up), plan (trial → paid plan) or topup (wallet top-up), empty for a registration; aiws_value: the amount in major units with two decimals (39.00), empty for a registration; aiws_currency: EUR or USD, empty for a registration; aiws_transaction_id: 16 hexadecimal characters — an opaque, stable digest of the Stripe Checkout Session (the session id itself is never pushed); the registration and the purchase of a paid sign-up each get their own; empty for other registrations. |
Rules for the container (the guarantees above hold only with them): each vendor's own automatic page-view and single-page-app / history tracking is switched off (e.g. the Google tag with send_page_view: false, Microsoft UET without automatic SPA tracking, the LinkedIn Insight Tag's history tracking off); a vendor's base library is loaded only by a tag that fires on aiws_public_page or on aiws_conversion; no advertising-platform tag uses the container's built-in Page View or History Change triggers (Matomo's own analytics page views keep theirs); enhanced conversions / advanced matching that read the page (e-mail scraping) stay off. A conversion hit carries the address of the page it fires on (e.g. /easy, /billing/upgrade/paid) — accepted. Custom-HTML tags may use the aiws_* values only as quoted JavaScript strings. The amount is the list amount of the checkout's seat line (price × seats — net when the Stripe price is tax-exclusive; an EU-governed add-on line is not included) for a plan or a paid sign-up, and the loaded amount for a top-up. Inside the native app no aiws_conversion is pushed.
When it fires — each conversion once per page load that owns it; a reload or a bookmark of the cleaned address has nothing to report, and a purchase that a platform sees twice (e.g. a second return from a completed Checkout) carries the same aiws_transaction_id, its de-duplication key:
- Registration — the next page load after a self-serve trial was created carries the one-shot marker
registered=1: the e-mail trial's own navigation (/easy?registered=1, or/login?registered=1when no session was handed over), the Google / Microsoft sign-up landing (/easy?registered=1, also as the native app's redeemnext). The voucher confirmation card reports the registration when it is shown instead. - Paid sign-up — the Stripe return
/signup/successreports the registration and the purchase once the account is provisioned. - Plan purchase — the return
/billing?upgraded=1once the plan shows as active. - Wallet top-up — the return
/billing?wallet=1.
Accepted shape of the URL-borne keys (untrusted — anyone can craft a link): the Checkout success URLs carry session_id (Stripe substitutes {CHECKOUT_SESSION_ID}), conv_value and conv_currency, set by the server when it creates the session (POST /admin/v1/billing/checkout, the wallet top-up, POST /admin/auth/signup/checkout). The application accepts a purchase only when each of the three keys appears exactly once, conv_value matches ^(0|[1-9][0-9]{0,8})\.[0-9]{2}$ and is not 0.00, conv_currency is EUR or USD, session_id matches ^cs_(test|live)_[A-Za-z0-9]{10,250}$, and the page owns that purchase (/billing with exactly one of upgraded=1 / wallet=1, or /signup/success). The marker is accepted only as exactly one registered=1. Absent keys (a reload; a checkout created before this change) report nothing; malformed keys (any other shape, a repeated or partial key, a key on another page) also report nothing and are logged as a client anomaly with a fixed reason — a wrong value can never become a conversion. In both cases registered, conv_value and conv_currency are removed from the address bar on the first page load, before the tag container loads — and session_id too on /billing and /signup/success; on /signup/success the session id (any non-empty value — the server validates it) is moved into the page's history state, where the status poll reads it. The server builds the suffix only for a positive whole amount in EUR or USD; anything else gets no value keys (logged).
Pages without the tag container (so their address never reaches a tag): a page load whose fragment carries a key=value pair (sign-in and sign-up links #token=… — taken out of the address before any other script runs and held in page memory, opt-out links, a composer pre-fill, the native sign-in hand-off), a page load whose query carries next (a return target can name a shared-conversation or device-code path), user_code (device code), nonce (connector handshake) or tenant (the organisation of a branded sign-in), a shared-conversation link, and any page load where removing these keys or a composer pre-fill from the address failed.
Known limits: a sign-in / sign-up link token that arrives without a page load (the app already shows /login or /signup when the tapped mail link reaches it — the tag container of that page load may be running) is taken out of the address by listeners registered before any tag's, so the address a tag reads afterwards is clean; the navigation event object itself (HashChangeEvent.newURL, a browser's Navigation API event) still carries it, and a removal that fails at that point leaves it in the address — a stated residual; a link crafted with these keys can produce a false conversion in the visitor's own browser (it only skews ad reporting); a magic-link landing (#token=) loads no tag container, so the Matomo trial events of that page load (trial started / rejected) are not recorded — the registration conversion itself is still reported on the next page load; a checkout session opened before this change reports no purchase; no conversion is reported when the paid return times out before the plan shows as active, when a trial's success response was lost (the retry panel's "may already exist" path) or when a Google / Microsoft sign-up's account lookup after provisioning failed (the person is sent to sign in).
Anti-enumeration: the response is an identical generic 200 { "message": … } whether or not the email already has an account. An email that already has a live, login-capable account gets that response with no intent created and no code sent (its return path is login/reactivation, not sign-up). Instead, that address is mailed a short "you already have an account, sign in" notice (a link to the sign-in page; no code, no sign-in link, localized like the account's other mail), sent off-request to the stored address, at most one per address per day per gateway node (the limit lives in node memory and resets when the node restarts), so a repeated request cannot be used to mail-bomb the owner. Only the mailbox owner can read it, which is why the screen answer stays neutral. Disabled, deleted and static-code accounts get no notice. As with the OTP-login precedent, this leaves a timing asymmetry (the existing-account path skips the cleanup + insert + email work) — this is documented rather than pretended away; the per-IP limit blunts timing-based enumeration.
Magic-link browser binding
A magic link (sign-in /login#token=…, sign-up /signup#token=…) used to sign in whoever held
it: anyone could request a link for their own address and mail it to someone else, who would then work
inside the sender's account (login-CSRF / session swap). Each link is now bound to the browser that
requested it.
The cookie. POST /admin/auth/otp/request sets __Host-aig_login_nonce, POST /admin/auth/signup/request
sets __Host-aig_signup_nonce — one per flow, each HttpOnly; Secure; SameSite=Lax; Path=/ with
Max-Age = that flow's link lifetime (the login code window; 30 minutes for sign-up). The value is 256
random bits (43 base64url characters); only its SHA-256 is stored, on the code / sign-up row
(link_nonce_hash). A browser that already holds a well-formed nonce of that flow keeps it (a resend, a
second tab and an older live link stay bound to it); a malformed one is replaced. The cookie is set for
every request that passes the address check and the rate limits — before the account lookup, so its
presence never tells whether an address has an account. A 400 / 429 / 503 that comes before that
point sets none. The __Host- prefix makes browsers refuse the cookie from any other host, so a sibling
*.myra.eu page cannot plant one.
Redeeming (POST /admin/auth/otp/verify-link, POST /admin/auth/signup/verify-link, body
{ "token": "…", "confirm": true } — confirm optional):
| Situation | Answer | Consumed? |
|---|---|---|
| The browser's cookie matches the link's binding | 200 — signed in (login) / aig_signup set (sign-up), exactly as before |
yes |
| No cookie of that flow (another browser or device, an app with its own cookie store, a mail app's built-in browser), or the link is bound to no browser (a sign-up reminder, a link minted before this change) | 428 { "error": "link_confirm_required", "email": "<account address>" } (login also "code": "link_confirm_required") |
no |
Same as above, with "confirm": true |
200 — the confirm page's explicit click. A confirmed login gets the short default session, never the stored 30-day choice (that belongs to the browser that ticked it). |
yes |
| A cookie that is malformed (wrong length or characters, empty) or repeated, or a well-formed cookie of another request | 403 { "error": "link_other_browser" } (login also "code") — even with "confirm": true |
no — the right browser can still use it |
| An absent / malformed / unknown / expired / used token | the unchanged generic 400 invalid_or_expired (checked before the cookie, so the cookie never reveals whether a token is valid) |
— |
| A superseded sign-up link | the unchanged 410 code_superseded / 409, before any binding decision |
no |
Accepted confirm: absent, true or false (false = not confirmed). Anything else — null, a string,
a number, an object — is 400 { "error": "invalid_confirm" } before any database work; a malformed value
is never read as "no". The 428 carries the address only to the holder of a live token (who got it from
that mailbox). The confirm page shows it as text and warns that continuing signs in to that account;
before the confirm POST the sign-in page re-checks GET /admin/auth/me and does not post when a session
exists meanwhile (or when the check itself fails other than with 401, including a 200 whose body is not a JSON
object). A sign-up session swap is guarded
on the server.
In the app: the iOS and Android apps open ai.myra.eu links themselves (universal / app links). A link
requested in the app opens in the app with one click; a link requested in the phone's browser (or on
another device) opens in the app's own cookie store and shows the confirm page. When the app already shows
/login or /signup, the tapped link reaches the open page without a reload and is redeemed there.
Stated residuals: a nameless cookie set by a sibling host for the whole myra.eu domain can reach
the header in a form the server cannot tell from the real one on browsers that do not yet reject such
cookies (older Safari) — effective only when the person holds no nonce of their own (a sibling host able
to set such cookies could also evict the person's host-only nonce by filling the registrable-domain
cookie jar, so the residual rests on controlling a sibling myra.eu host and an old-Safari-class browser,
not on the person happening to hold none). A cookie lost while the app was killed in the background
degrades to the confirm page, never to a silent sign-in. Each
decision is logged as one line magic_link flow=<login|signup> outcome=<bound|confirmed|confirm_required|mismatch>
(no address, no token), so the share of links opened outside the requesting browser is measurable.
Superseded codes
When an address makes a consented POST /admin/auth/signup/request (the trial's step 1, including the
consent-step recovery after a 422 consent_required), the server supersedes that address's older,
still-open sign-ups that carry no consent (the paid funnel's email-only step-1 shape), in the same
transaction as the new sign-up. From then on a code, an unused magic link or a signup session of such an
older sign-up no longer works:
signup/verify,signup/verify-link,signup/trial,signup/checkoutanswer410 { "error": "code_superseded", "message": "This code is no longer valid. Use the code from the newest email." }— nothing is verified, consumed, provisioned or paid; the code (or link) from the newest e-mail is the way forward.- When the address already has an account by then,
verify,verify-linkandcheckoutanswer the honest409instead (sign in).trialkeeps its existing409s (active subscription, trial already used) ahead of the410. - Only sign-ups without recorded consent are superseded: a consented sign-up, one already holding a payment session, one already used, and other addresses are never touched; an email-only request never supersedes anything; two consented requests never supersede each other. A superseded sign-up can never gain consent or a payment session afterwards (during a rolling deploy an older server node may still record consent on one; such a sign-up then counts as consented and is live everywhere).
- The marker does not shorten anything: a superseded sign-up is cleaned up when its own code window ends,
after which its code gets the ordinary
401.
signup/verify
Accepted body: { email, code } (both required; email normalized as above). The code is compared in constant time against every open intent for that email (a live match wins over a superseded one); a missing intent is compared against a fixed dummy hash so existence is not revealed by timing. Rejected (400): missing email/code or malformed email. Rejected (401): wrong or expired code. Rejected (410 code_superseded, or 409 when the address already has an account): the code of a superseded sign-up. Rejected (429): 5/hour/email or 20/hour/IP. On success: 200 { "verified": true } and the aig_signup cookie.
signup/catalog
GET /admin/auth/signup/catalog — public, no authentication, no input. The product catalog the sign-up page renders: every public catalog row with the price checkout will charge (the catalog mirrors Stripe; shown == charged). It 404s when self-serve is off, like every signup route.
{
"trial_days": 7,
"currency": "EUR",
"plans": [
{ "slug": "custom", "plan_value": "self_serve_custom", "display_order": 20, "badge": "popular",
"self_serve": 1, "max_seats": 500, "grants": { "web_search": true },
"prices": { "month": { "unit_amount": 1300, "currency": "EUR", "interval": "month", "tax_behavior": "exclusive" },
"year": { "unit_amount": 14040, "currency": "EUR", "interval": "year", "tax_behavior": "exclusive" } },
"checkout": { "month": true, "year": true } }
],
"addons": [
{ "slug": "eu_gov", "display_order": 30, "badge": null, "grants": { "myra_hosted_models": true },
"prices": { "month": { "unit_amount": 300, "currency": "EUR", "interval": "month", "tax_behavior": "exclusive" },
"year": { "unit_amount": 3240, "currency": "EUR", "interval": "year", "tax_behavior": "exclusive" } },
"checkout": { "month": false, "year": false } }
],
"topups": [ { "slug": "wallet_topup", "currency": "EUR", "min_minor": 100, "max_minor": 100000,
"presets": [5000, 10000, 25000, 50000] } ],
"checkout_monthly_max_minor": 200000
}
- Amounts are minor units (cents);
intervalisnullfor a one-time price.max_seatsis the most seats one customer can buy on that plan (the plan's configured seat maximum;nullwhen unlimited/unknown). checkout.<interval>istrueonly when checkout can actually charge that interval right now (a resolvable price and thepaid_signup_enabledsetting on); the price shown for it is exactly the price checkout charges.prices.<interval>isnullwhen the interval has no single price — none at all, or more than one candidate (for example two prices, or prices in two currencies). A price that existing subscriptions still pay but that is no longer sold is never shown. See Catalog — resolved view.addons[].checkout.<interval>is always present (two booleans). On this public feed it is alwaysfalse: a sign-up checkout never sells an add-on, soaddons[].pricesare display prices. Only the signed-in conversion feed sets ittrue— while checkout is possible, at least one plan can check out in that interval and the add-on prices against every such plan's offer — and thenaddons[].prices.<interval>is exactly the add-on line checkout charges.checkout_monthly_max_minor— the self-serve limit: the most a self-serve checkout may reach per month, net, as an integer in EUR cents (default200000= 2 000.00 EUR — self-serve sells EUR prices only, so a plan price in another currency showscheckoutfalse);nullwhen the server cannot read the limit (checkout then answers503, so the page applies no client-side limit and follows the server's answer). Above it the sign-up page shows no pay button but "For this team size, please contact us" with a link to the contact page.topups(step 1b): a wallet top-up is any integer amount withinmin_minor–max_minor(minor units ofcurrency);presetsare suggestions. The entry appears only while the wallet is switched on (wallet_enabled) and a top-up can actually be sold (valid config, Stripe product bound) — otherwisetopupsis[]. (An earlier release removed the one-releaseoffers: []compatibility field.) See Catalog — wallet top-up configuration.- Only public rows appear. No Stripe price/product ids, lookup keys, nicknames or diagnostics ever leave the server. Row names and descriptions are not in the body — the page renders them from the
catalog.<kind>.<slug>.name/.descriptiontranslation keys.
| Status | When | Caching |
|---|---|---|
200 |
the feed | Cache-Control: public, max-age=60 (the rendered body is also cached server-side for 60 s per node and dropped on every catalog change, wallet_enabled change and self_serve_checkout_monthly_max_minor change) |
404 |
self-serve is off | no-store |
429 { "error": "rate limited" } |
more than 120 requests per 60 s from one client IP | no-store |
503 { "error": "catalog_unavailable" } |
the catalog cannot be read (never an empty 200 that would read as "nothing for sale") |
no-store |
signup/checkout
Requires a valid aig_signup cookie (a normal session token is refused — the purpose=signup check runs in both directions) and a verified email. Refused with 404 when self-serve or the paid_signup_enabled setting is off.
Accepted body — either a choice:
| Field | Rules |
|---|---|
plan |
Required. A catalog plan slug (^[a-z0-9_-]{1,64}$) that is public and purchasable, e.g. custom. The former starter / pro / …-annual values no longer exist (400 unknown_plan). |
interval |
Required. "month" or "year". |
seats |
Required. Integer ≥ 1 and ≤ the plan's max_seats (from signup/catalog). The Stripe Checkout charges exactly this quantity of the seat price, and after payment the new workspace's seat limit is this number. |
expect |
Required. { "unit_amount", "currency", "tax_behavior" } — the price the page showed. If the current price differs, nothing is created and the answer is 409 price_changed with the current offer, so the customer confirms the new price. |
consent_terms_version |
Required. The AGB consent version, same shape/rules as at AVV acceptance (1–32 chars, [A-Za-z0-9 . - _ :]). Absent or malformed → 400, no session created. Recorded on the intent before the Stripe session is created (the webhook that provisions later trusts this snapshot). |
avv_accepted |
Required while AVV is active (the default). Must be boolean true; any other value (absent/string/number/null/object) → 400, no session. The accepted version is server-pinned. |
voucher_code |
Optional; the redeemable code (moved here from request). Malformed → dropped; well-formed → recorded on the intent and redeemed post-provision. |
addon, topup, any other key |
Not accepted. A sign-up checkout sells only the seats: the EU-governed add-on is bought with the trial conversion, and a wallet top-up is loaded in the workspace afterwards. Any key outside this table (and, beside a choice, resume) → 400 unsupported_field with field naming it. Inside expect, a fourth key → 400 invalid_expect. |
The purchase must stay within the self-serve limit: seats × the seat price per month (an annual price counts as a twelfth) above checkout_monthly_max_minor → 409 above_self_serve_limit, nothing created.
— or { "resume": true } alone (the "continue checkout" button after a Stripe cancel; the page reload has lost the choice). A resume answers from the intent's own session's real status and never reads the catalog: still open → 200 with its URL; already paid → 409 checkout_pending; expired, replaced or none → 409 restart_checkout. The resume path carries no consent and is not consent-gated — its original checkout already recorded consent. It also does not re-check the self-serve limit: a session opened before the limit was lowered can still be resumed for the rest of its own lifetime (at most 24 hours).
One open checkout per email. All sign-up attempts of one email (any intent, any device) share one open Stripe Checkout Session: a new choice retires the previous open session before a new one is created, so two payable sessions can never exist at once.
On success: 200 { "checkout_url", "session_id" }. The Checkout Session is card-only, pins customer_email, shows the seat quantity × price before the card is entered, and stamps metadata[product]=ai-gateway.
The refusals named by a machine string below repeat it as a sibling top-level code, the resume answers restart_checkout, checkout_pending and checkout_unavailable included.
Status / error |
Meaning | Client action |
|---|---|---|
400 missing_field |
plan, interval, seats or expect absent |
fix the request |
400 invalid_body / invalid_plan / invalid_interval / invalid_seats / invalid_expect |
a field is present but malformed (invalid_seats also for seats above the plan maximum; the body then carries max_seats) |
fix the request |
400 unknown_plan |
not a public, purchasable plan | re-read the catalog |
400 unsupported_field |
a key outside the table above is present (an addon or a topup included; sign-up sells neither); field names it |
drop the field |
401 |
signup cookie missing/expired | start again |
403 |
email not verified | verify first |
409 already subscribed |
intent consumed, or the email already has an active subscription, or (a superseded session) the address already has an account | sign in |
409 price_changed |
the price changed since it was shown (body: offer) |
show the new price, ask again |
409 above_self_serve_limit |
the purchase is above the self-serve limit (body: limit_minor, currency) |
offer contact instead of payment |
409 checkout_in_progress |
another request for this email is creating a checkout (≤ 60 s) | retry shortly |
409 checkout_pending |
a checkout for this email is already paid and being provisioned | wait / poll signup/status |
409 restart_checkout |
(resume) the session is gone | choose the plan again |
410 code_superseded |
the session belongs to an older sign-up without consent that a later consented request superseded (also on resume; nothing recorded, no session) | use the code from the newest e-mail |
502 checkout_unavailable |
Stripe could not be reached | retry later |
500 { "error": "internal error" } |
an internal or database fault; if a Stripe session had already been created it is withdrawn (best effort) and its link is not returned | retry — normally at once; while the database is still failing a retry may get 409 checkout_in_progress for up to 60 s |
503 checkout_unavailable |
the catalog cannot offer a price for this plan/interval (including a price in a currency other than EUR — permanent until the catalog is fixed), or the stored self-serve limit cannot be read or is malformed (fails closed, never the default) | retry later; a catalog fault stays until ops fix it |
503 signup_busy |
recording the consent collided with concurrent writes on every server-side retry (Retry-After: 2); nothing stored |
send the same request again |
signup/trial
Starts the no-card 7-day free trial and is the trial's account-creation step — the second step of the two-step funnel (verifying the OTP calls it). Requires a valid aig_signup cookie — the email is already OTP-verified by request→verify, so this is not a new unauthenticated surface.
takes no body. The affirmative AGB/AVV consent was captured and recorded on the intent at step 1 (signup/request), so this endpoint reads no consent (nor any name or voucher code — the campaign voucher code, when there is one, was submitted at step 1 and is already on the intent). A stale client that still POSTs a consent body is harmless: the body is ignored and the recorded step-1 snapshot is authoritative. The consent gate is enforced structurally: the provisioning choke point (_provision_tenant_stack) refuses to provision an intent whose consent snapshot is absent or malformed, so an email-only (consent-less) intent — the paid funnel's step-1 shape, or one minted by a client that skipped the checkbox — verifies fine but cannot become a trial: the endpoint answers 422 consent_required (below) and provisions nothing. The intent stays unconsumed; the remedy is to go back to step 1, tick the consent box and request a new code. That consented request supersedes the consent-less intent, so its old code, its unused link and its signup session answer 410 code_superseded from then on instead of looping back here (see Superseded codes). The application does exactly that: it returns the prospect to the consent step with an explanatory message.
Every authoritative billing value (the plan, the credit amount, the trial length) comes from the server, never the request — a body that tries to set plan or budget_usd is ignored. The trial credit is the trial_credit_eur of the catalog's trial row (catalog; default €3) and the model set is the DB-tunable self_serve_trial plan-config row; the length is 7 days. If that catalog row is missing or cannot be read, the trial is not provisioned (a retryable error) rather than granted without its credit; a row whose credit is null (none advertised) grants none.
On success it provisions a real tenant directly (no Stripe, no subscription row), stamps trial_ends_at = now + 7 days and the credit as a lifetime (total-period) budget, sets the real aig_admin session cookie — the 30-day session (Max-Age=2592000), the same lifetime as a "stay signed in" login, for a code- and a link-verified sign-up — clears the aig_signup cookie, and returns 200 { "trial": true, "session_issued": true }. The session hand-over is single-use per sign-up (shared with signup/status): if it was already handed over, or cannot be recorded for a moment, the account is still created and the answer is 200 { "trial": true, "session_issued": false } — sign in normally. When the intent carried a voucher code it also carries an optional voucher object stating what became of it — an absent key means "say nothing", which is deliberately NOT the same as "no voucher"; see Vouchers. The trial owner is created without a name (registration collects none now — the user sets it later in their profile). Enforcement is the existing quota path: a 402 trial_expired once the 7 days pass, and a 402 trial_budget_exhausted once the credit is spent (see Billing). For every member of a trial workspace (owner and invited members), GET /admin/auth/me carries trial_ends_at (unix seconds — also after it has passed), trial_credit_eur (the euro credit frozen onto the workspace at sign-up — the figure the app shows, never re-derived through an exchange rate). trial_credit_eur is emitted only as a positive number; it is absent when the workspace has no pinned euro figure (a trial granted before the figure was pinned, or a catalog trial row whose credit is null). Trial workspaces also carry trial_budget_unlocked (boolean): true once the workspace has redeemed a voucher (its per-gateway budget_usd is then editable as long as the gateway budgets together stay within the wallet balance), false otherwise and when the read faults (fail closed). Paid plans carry none of these fields — trial_budget_unlocked is omitted for them.
Every member's real spend picture is the wallet balance (spendable_usd, where the member sees a wallet) plus the admin-set spend limits that can bound this member right now, carried as spend_limits and effective_limit_scope (MAP-3377, extended to every member of a workspace on every plan and role, so a capped member learns their limit before the gateway refuses them). The dead per-user trial-credit ledger that once fed a trial_credit_usd cap and an allowance_used_pct share is retired from the trial path, so neither field is emitted for a trial member (a paid tenant's /billing/summary allowance_used_pct, computed against the tenant spend cap, is unaffected).
spend_limits is an object keyed by scope — one entry per admin limit that can bind this member, each computed server-side from the same source the gateway enforces on (never a parallel re-derivation):
| Scope | Limit |
|---|---|
spend_cap |
the workspace's self-imposed monthly USD cap (tenant.spend_cap_usd) |
gateway |
a per-gateway cap — the external Anthropic gateway's flat $3 vendor-cost cap (external: true); trial workspaces only (a leftover trial gateway on a converted workspace is not shown) |
user |
the member's own per-user budget cap, when one is set |
team |
the member's department (team) cap, when one is set; a malformed department binding or a vanished user gives readable: false, and no department omits the entry |
Each entry is a SpendLimit:
| Field | Type | Meaning |
|---|---|---|
limit_usd |
number | the cap, in USD. The whole entry is omitted when the level has no limit (SQL null = unlimited, nothing to show). Emitted as 0 for a frozen level. |
used_usd |
number | spend in the current period (for "left" and an optional meter). |
period |
string | daily, weekly, monthly or total. |
readable |
boolean | false when the cap or the spend could not be read, or the stored cap is malformed (non-number, NaN, infinity or negative) — the app shows "ask your admin" and never treats it as unlimited (fail closed). A readable: false entry omits limit_usd and used_usd. |
scope_id |
string? | the gateway id for a gateway entry; the department id for a team entry. |
scope_name |
string? | team entries only: the department's display name. Omitted when the name is empty or unavailable (the entry stays valid). |
member_count |
integer? | team entries only: how many people share the department's budget — the workspace's active users whose department (their own assignment, else the workspace default) is this department. Shown as "shared by N people". A whole number ≥ 0; omitted when the count cannot be read or comes back malformed (never a guess, never a placeholder), and omitted for a department outside the member's workspace. It is a head count, not an amount, so it stays on the status-only shape. |
exempt |
boolean? | team entries only: true when an admin exempted this member from the department's limit. An exempt entry is never frozen (the exempt flag overrides the frozen rule for the team entry), never wins effective_limit_scope, and the gateway does not refuse the member at the department cap (their spend is still metered to it). Its status is ok for an exempt member, whatever the pool holds, and it stays present in the status-only shape. Omitted otherwise. |
source |
string? | user entries only: which level the cap came from, person, group, department or tenant (a cap inherited from a default). |
source_name |
string? | user entries only, when source is group: the name of the group whose limit applies. |
external |
boolean? | gateway entries only: true for the external (Anthropic/Haiku) trial gateway. |
Absent and malformed are different answers (invariant 11): a null/absent cap omits the entry (unlimited), a 0 cap is emitted with readable: true as a distinct frozen state (never "€0 left"), and a cap that arrives malformed or whose read faults is readable: false — it is never silently treated as unlimited. effective_limit_scope is the server's verdict of the lowest (most restrictive) readable level right now — balance | spend_cap | gateway | team | user — by remaining (limit - used; a frozen level has remaining 0 and is the most restrictive). It is balance when the wallet is the only bound, or when the wallet cannot be read and no admin level binds. An unreadable level is still listed (so the app can surface it as "unknown") but never wins effective_limit_scope, because the server cannot claim it binds. Both fields are emitted for every member of a workspace; spend_limits itself is absent when no admin level applies while effective_limit_scope still rides (as balance). If the subscription of a self-serve workspace cannot be read, the user entry is readable: false (the budget period, and with it the spend row, is unknown) rather than showing a wrong figure. A trial workspace has no per-member limit, so it never carries a user entry, even when its subscription cannot be read. If the spend-limits computation itself fails, both spend_limits and effective_limit_scope are omitted, and sign-in is never blocked.
On the trial path the shared levels (spend_cap, team, gateway) keep their amounts (limit_usd, used_usd) and also carry status and resets_at, computed by the same server rule as below, so the app never derives a status itself. A missing or unknown status is read by the app as unreadable.
spend_limits for non-trial members
Every member of a paid (non-trial) workspace also receives spend_limits and effective_limit_scope on GET /admin/auth/me, so the app can say which limit is about to stop them. A member who is not allowed to see amounts only ever learns a status: for the shared levels (spend_cap, team, gateway) the server withholds limit_usd, used_usd and any remaining amount, and the client cannot recover them from this response. Only the member's own level (user) keeps its amounts, and it also carries a status (ok below 80 % of the limit, nearly_used_up from 80 %, used_up at or over the limit; a frozen 0 limit is used_up), computed by the server with the same rule as the shared levels, so the app never derives a threshold itself. A user entry that is not readable carries no status. effective_limit_scope is still decided server-side from the real amounts before they are withheld.
| Scope | Shape |
|---|---|
user |
{ "limit_usd": 20, "used_usd": 6, "status": "ok" \| "nearly_used_up" \| "used_up", "period": "monthly" \| "allowance", "readable": true, "resets_at": 1701385200 } |
spend_cap |
{ "status": "ok" \| "nearly_used_up" \| "used_up", "period": "monthly", "readable": true, "resets_at": 1701385200 } |
team |
{ "status": "...", "period": "daily" \| "weekly" \| "monthly" \| "total", "readable": true, "scope_id": "<department id>", "scope_name": "Platform", "member_count": 63, "resets_at": 1701385200 } |
gateway |
{ "status": "...", "period": "...", "readable": true, "scope_id": "<gateway id>", "scope_name": "<gateway slug>", "resets_at": 1701385200 } |
| any level, unreadable | { "readable": false } |
statusisokbelow 80 % of the limit,nearly_used_upfrom 80 %, andused_upat or over 100 %. A frozen level (limit0) is alwaysused_up.resets_atis the unix time of the next period start (omitted for atotalperiod, which never resets).periodforuseris the period type (monthlyorallowance), never a raw ledger id.scope_nameis the department name (team; only for a department of the member's own workspace and only when it has a non-empty name) or the gateway slug (gateway). It is absent otherwise, never a placeholder.gatewayis the one gateway, among those the member may route through and that carry a budget (test and non-production gateways are skipped), that is closest to its limit. The server reads the gateway list once and at most 20 gateway spends; a workspace with more than 20 budgeted gateways answers{ "readable": false }rather than guessing.externalis never set for a non-trial member.- Fail closed. An absent cap omits the entry; a malformed cap, a failed read, or an unreadable subscription period (for
user) is{ "readable": false }, never "unlimited" and never a guessed period. An unreadable level never winseffective_limit_scope.
Busy — 503 { "error": "signup_busy" } with Retry-After: 2. Creating the account (tenant, owner user, gateways, consent record — one database transaction) can collide with another signup happening at the same moment (two new addresses that sort next to each other take overlapping index locks, and the database aborts one of the two transactions as a deadlock). The server retries that transaction itself, from scratch, up to 4 attempts with a short backoff; a retry can never create a second tenant or user (the intent is claimed inside the same transaction). When every attempt hits such a conflict the request answers 503 signup_busy (the same answer is given when a check that runs before the transaction — the active-subscription, dedup, throttle or trial-credit read — hits a retryable database fault): nothing was created, the intent is still verified and unconsumed and the aig_signup cookie stays valid, so the client simply POSTs signup/trial again — it must not re-run signup/verify (that is rate-limited per address and the code expires). The sign-up page shows a "busy — try again" panel whose button does exactly that. A lock wait that outlasts the request's database timeout still ends as a 500 (no partial account either); retrying after a moment is safe.
Already signed in — 409 { "error": "already_signed_in" }. When the request also carries a live aig_admin session (an active, un-revoked account — up to four distinct aig_admin values in the request are checked, repeats counted once), nothing is provisioned and no session is set — the sign-up session would replace that person's session — and the aig_signup cookie is cleared, so that sign-up cannot be resumed in this browser later. The page takes them to their own workspace. A session cookie that authenticates nobody (absent, malformed, expired, wrong-purpose, revoked, or a disabled account) does not block. If the live-session check itself cannot be completed (a transient database fault), the answer is the retryable 503 signup_busy below. A request carrying more than four distinct aig_admin values is not a real browser and is refused with 400 { "error": "too_many_session_cookies" } — nothing is provisioned, and repeating the same request cannot succeed. Rejected (401): missing/expired signup cookie or intent. Rejected (403): email not yet verified. Rejected (409): the intent is already consumed, the email already owns an active subscription, or the email already used its one free trial ({ "error": "trial_already_used" }) — unless a soft-deleted account still owns that address (a tenant-admin delete that kept the one-trial marker), in which case the precise { "error": "account_deactivated" } is returned instead so the page shows "your account has been deactivated, contact your administrator" rather than the misleading "trial already used". That distinction comes from an authoritative server read (a user row with deleted_at IS NOT NULL for the exact address) and fails closed: a non-matching (accent / homograph) address keeps trial_already_used; a fault in the check answers the retryable 503 signup_busy with Retry-After (or 500 when the fault is not retryable) — never trial_already_used and never a trial. Rejected (429): more than the per-domain (1000 by default, configurable — see trial_per_domain_daily) or per-IP (5, fixed) trials in a rolling 24 h — the anti-abuse throttle. The per-IP trial cap uses the same client-IP key as the request limiters (see How the public rate limits behave): an IPv4 address exactly, an IPv6 address by its /64, an IPv4-mapped spelling as the plain IPv4 address. A sign-up whose client address is blank or unusable counts in one shared ? bucket. Rejected (422): the intent carries no recorded consent (an email-only intent) — { "error": "consent_required", "message": "…" }; nothing is provisioned, counted or consumed (see Error codes). Rejected (410): the intent was superseded by a later consented request — { "error": "code_superseded", "message": "…" }; use the code from the newest e-mail. An email that already owns an active subscription or already used its trial gets that 409 instead, since a new code cannot help it. Trial eligibility is one per verified email: the email is canonicalized (lower-cased, +tag subaddressing stripped, every trailing dot removed from the domain, and dots removed for dot-insensitive providers such as Gmail) before the dedup/throttle checks, and the atomic backstop is the account email's uniqueness. A leading + (or a run of them) is part of the address, not a tag separator, so +41791234567@sms.corp.de canonicalizes to itself and is eligible; only a + after the first non-+ character starts a tag. This is a deliberate change: the previous rule stripped from the first +, which collapsed every such address at a domain onto one record, so after the first phone-style signup there every unrelated one was refused as trial_already_used. Eligibility for that group is now per address rather than per domain. Records written under the old rule are not rewritten; they cannot return a second trial to the same spelling, because the account email's uniqueness is enforced on the raw address. A mailbox that supports subaddressing can be respelled into a new raw address with the same canonical form, so for those records the transitional bound is one further trial each. An intent whose stored address cannot be canonicalized at all is refused with 500 and no tenant is provisioned — unreachable through this API, since every address is canonicalized and shape-checked before the intent is stored, so it indicates a record written outside the documented path. Any DB fault in the active-subscription, dedup, throttle or trial-credit read fails closed: a retryable fault is 503 signup_busy with Retry-After: 2, any other fault is 500 { "error": "internal error" }. Nothing is provisioned or consumed, and a second trial is never granted. Like every signup route it 404s when self-serve is off.
signup/status
Accepted query: ?session_id=<Stripe Checkout Session id> (only a value shaped like a Stripe Checkout Session id, cs_…, is ever correlated; anything else is ignored). The session_id is a correlation check only, never an auth key (cs_… ids leak via URLs/referrers): a real session cookie is issued only when a valid signup JWT bound to that intent is present, the intent is provisioned, and the stored session id equals the session_id param. On that path the endpoint sets the real aig_admin cookie — the 30-day session (Max-Age=2592000) — and clears the aig_signup cookie (returned session_issued: true). The swap is single-use per sign-up, shared with signup/trial (a sign-up that started a checkout and then took the free trial still gets exactly one session): the first request that issues it claims it atomically on the intent, and a later poll (a second tab, a replayed request with the same signup cookie) answers session_issued: false and sets nothing — sign in normally. It is also never done over a live aig_admin session: if the browser is already signed in as the new account (a second tab, or a first response that was lost after the cookie arrived) the answer is session_issued: true with no new session — the swap is still claimed and aig_signup cleared, so the sign-up cookie can never mint a session later; signed in as anyone else → session_issued: false, no session set, and aig_signup cleared (the new account's owner signs in normally). Up to four distinct aig_admin values in the request are checked (repeats counted once) — a repeated cookie name cannot hide a live session behind a malformed one; more than four distinct values → 400 { "error": "too_many_session_cookies" }, nothing set. A transient database fault while looking up the new account or the live session answers the retryable 503 { "error": "signup_busy" } with Retry-After: 2 (the success page keeps polling), and a fault while claiming the swap answers 500 { "error": "internal error" } with nothing set; otherwise it returns a plain { "status": "pending" | "provisioned", "session_issued": false } — so an expired/absent signup JWT still gets a status answer (the success page then offers a login link instead of hanging).
voucher (paid sign-up). When the sign-up carried a voucher code, the answer that issues the session (session_issued: true, and only that one) also carries an optional voucher object stating what became of the code. The pay-first funnel redeems it when the account is provisioned (the Stripe webhook), long before the browser returns, so this is a read of the recorded decision, never a redemption: { "status": "granted", "credit_usd": 7.5, "expires_at": 1801234567 } (expires_at, unix seconds, only when the credit lapses), { "status": "not_applied", "reason": "invalid" | "inactive" | "expired" | "exhausted" | "already_redeemed" | "campaign_already_redeemed" } (reason omitted when the cause was our own defect), or { "status": "pending" } (a code was claimed but no decision is recorded yet). The session swap is single-use, so the status poll keeps answering { "status": "pending", "session_issued": false } for up to 20 seconds after provisioning while a claimed code has no recorded decision, rather than issuing the session without the outcome; after that bound the session is issued with voucher: { "status": "pending" }. The key is absent (which means "say nothing", not "no voucher") when no code was submitted, when the redemption errored (an operator is paged), when the lookup failed, on the pending poll and on the JWT-less by-session fallback. The semantics of the values are those of POST /signup/trial.
Connect-OX popup and COOP
The Open-Xchange "Connect" button opens the authenticated SPA page /connect/ox?origin=<exact OX
origin>&nonce=<opaque> in a popup. The page is wrapped in the sign-in guard (a logged-out
visitor is bounced to /login?next=/connect/ox… and returned after signing in), lets the user pick
a gateway + model, and calls POST /admin/v1/me/connect/ox
to mint an inference-scoped token. It hands the result to the OX plugin by
window.opener.postMessage({ source: "myra-connect-ox", nonce, tenant, gateway, model, token }, origin)
— the second argument is the exact origin from the query, never "*", so no other window
can receive the token.
Security properties of the page (defense-in-depth around the server gate, which is authoritative):
- Frame-bust / opener guard: if the page is framed (
window.top !== window.self) or was opened without an opener (!window.opener), it refuses — no token is requested. This blocks clickjacking and a token being stolen by opening the URL directly. - Input validation: a missing/over-long/malformed
nonce(^[A-Za-z0-9_-]{1,128}$) or a non-canonicaloriginshows an error and mints nothing — a bad value is rejected, never sanitised-and-echoed. Theoriginis also shown to the user before they confirm. - COOP invariant: the handshake relies on
window.openersurviving the cross-origin open, so/connect/oxmust NOT be served withCross-Origin-Opener-Policy: same-origin(it would silently sever the return channel). The app sets no COOP header today;X-Frame-Options: SAMEORIGIN+ CSPframe-ancestors 'self'back the frame-bust above. If a global COOP is ever introduced, this route must be exempted.
The token minted here is scoped, rate-limited, and non-expiring — see the endpoint reference for the
forced controls and the connect_ox_allowed_origins allow-list (Settings).
Password and second factor sign-in (PCI DSS)
💡 Note: Rolling out. These routes are the contract of the upcoming sign-in option "Email + password + second factor" (
password_mfa). Until it is switched on, sign-in works exactly as described above.
An organisation can choose how its members sign in: Email code (email_code, the default) or Email + password + second factor (password_mfa). With password_mfa a member proves a password and then one second factor: an authenticator app (TOTP), a security key, a passkey or a recovery code. This section is the contract of the routes behind that option.
Flags: when the routes are live
- The public sign-in, setup and reset routes, the account-security routes under
/admin/v1/me/(security, password, step-up, factors, recovery codes) and the three admin user routes (second-factor/reset,password-reset-link,signin-unlock) answer404while bothpassword_mfa_enabledandadmin_mfa_enforcedare off. When one is on, they serve only people whose resolved policy ispassword_mfa. For anyone else they behave as for an unknown address, or answer404, as stated per route.signin-unlockis the exception to the policy rule: it ignores the target's resolved policy and disabled state, so a lock left over from before a policy change can still be ended. GETandPUT /admin/v1/tenants/{id}/signin-policyanswer404whilepassword_mfa_enabledis off, and for an organisation that is not onpassword_mfa_tenant_allowlist, identical to an unknown route (Admin actions).- The changed existing routes (below) change behaviour only for people whose resolved policy is
password_mfa. With both flags off nothing changes. Existing passwords and factors are kept, unused. - A flag that is absent reads as off. On the person-level routes a malformed or unreadable
password_mfa_enabledoradmin_mfa_enforced, or, whilepassword_mfa_enabledis on, a malformed or unreadablepassword_mfa_tenant_allowlist, answers503 { "error": "temporarily unavailable" }, not404.GETandPUT .../signin-policyreadpassword_mfa_enabledand the allowlist: the same503for a malformed or unreadable value of those. Whilepassword_mfa_enabledis on, a broken allowlist answers that503for everyone on these routes, also for a person whose own decision would not read it.
A malformed or unreadable flag never reads as off for a sign-in decision: a route that reads it refuses the request instead.
Which policy applies to a person
The policy is resolved per person, in this order:
- A holder of the membership
sys:adminwhileadmin_mfa_enforcedis on:password_mfa. - A person with no organisation:
email_code. password_mfa_enabledoff, or the organisation is not onpassword_mfa_tenant_allowlist:email_code.- Otherwise the organisation's
signin_policy(email_codeorpassword_mfa).
Absent flags read as off. A malformed stored value, or a read fault of anything the decision reads, refuses the sign-in step and is logged. It never falls back to the permissive email_code. Fault answers. The JSON sign-in routes answer 503 { "error": "temporarily unavailable" }. The identity-provider sign-ins (rule 1 only) answer with their flow's own transient answer instead: single sign-on (OIDC callback, SAML ACS) redirects to /login?error=sso_unavailable; a Google or Microsoft callback redirects with ?oauth_error=try_again (to /login, or to the register page's trial step when the flow started there); the app redeem answers 503 { "reason": "try_again", "page": "login" } ("signup" for a consented start). Because admin_mfa_enforced is read for every Google, Microsoft and app sign-in of an existing account and for every OIDC and SAML sign-in, a malformed or unreadable stored value stops all of them, for every person, until it is fixed (PUT accepts only a JSON boolean, so only a direct database write can cause this). A person whose organisation is soft-deleted or gone also answers 503; this applies to a person the route has found, and where a route answers a disabled or deleted account like an unknown address, that answer comes first. A corrupt stored signin_policy, or a read fault for one person, answers 503 for that person alone. Switching an organisation's option signs nobody out. There is no "trust this device".
External sign-ins stay outside the feature. A session whose amr is oidc, saml, google or microsoft is renewed as today (a demo session also renews unchanged; demo sign-in is disabled), and the step-up gate follows the step-up precedence. One exception on renewal: while admin_mfa_enforced is on, any session of a sys:admin holder that lacks pwd plus a second factor (external, demo, email or without amr) gets 403 mfa_session_required, however old it is (the cookie is untouched and lives until its exp). Normal members of an organisation that enforces single sign-on and is on password_mfa keep signing in with single sign-on. Only break-glass users use password and second factor. Exception: while admin_mfa_enforced is on, a sys:admin holder always signs in with password and second factor, independent of the organisation. Google, Microsoft, enterprise OIDC and SAML sign-ins are refused for them with admin_mfa_required.
Where the decision is made
The sign-in page learns which option applies to an address from POST /admin/auth/otp/request. That is the one per-address step that already looks up single sign-on and already branches on sso_required. The other two lookups stay unchanged on purpose. GET /admin/auth/methods is a capability probe for the platform, not per address. POST /admin/auth/sso/lookup is a prefetch while typing and is limited per IP only; a per-person answer there would be a cheap way to test which addresses exist. /otp/request is capped per address, needs no extra round trip, and is where the server enforces the rule anyway. That it can reveal whether an address uses a password is accepted (it is never revealed in break-glass mode, below). A fixed-code account never gets next: "password", whether or not it has a password.
What the sign-in page does with the answer. The page reads the first request and a Resend from the code step the same way. An otp/request answer without a next member is the e-mail code step, as before. next: "password" opens the password step (after a resend too: the organisation moved to password sign-in meanwhile, and no code was sent). Any other value, and any answer that is not a JSON object, is refused as a failed request: the page shows an error and stays on the e-mail step, never "code sent". The page posts the typed password only to POST /admin/auth/signin/password and holds it only while the step is shown; it is cleared after every outcome that is not a success. It validates the 200 body of that route fail-closed against the pending-token shape: a body that does not match is shown as a failed request and no session is assumed. A 200 from otp/verify or otp/verify-link is read the same way in all three places (the code form, the link opened in the same browser, the link confirmed after the 428 page): a user object signs in; a pending-token shape answering setup with next: "create_password" opens the setup step and signs nobody in; any other body, including a non-object, is refused as a failed request. A 403 password_signin_required from otp/verify moves the page to the password step; the same answer from otp/verify-link moves the page on without signing anyone in: when the link is opened in the same browser (the automatic redeem) to the e-mail step with a note that the organisation now signs in with a password; when it is confirmed after the 428 page (the address is then known) to the password step with a note that the organisation signs in with a password. A purpose: setup answer (next: "email_code" from signin/password, next: "create_password" from the code or link) opens the setup flow; the pending token is held in page state only, never in storage or the URL. The password step and the locked view carry a Forgot password? link: it opens a form prefilled with the typed address, and Send reset link posts it to POST /admin/auth/password/forgot. Any 200 object shows the same "a reset link is on its way" view whatever the address is; a 200 that is not an object is a failed request. The link exists only when the server answered next: "password"; with the e-mail code flow the page shows no such link. Second factor. A pending-token answer with purpose: "signin" opens the second-factor step: the authenticator code when totp is offered, with a switch to a recovery code when recovery_code is offered (and back). When passkey or security_key is offered, the step opens on that factor instead (a passkey view with the app and the recovery code as alternatives; a security-key view that asks for the key at once when no passkey is offered). The answer must then carry a webauthn object (challenge, rpId, allowCredentials, userVerification, timeout); a passkey or security-key factor with webauthn missing or null makes the whole answer malformed and no step is shown. A malformed webauthn object rejects the whole answer in the same way, even when only the app code is offered: the other methods are not offered from it (fail-closed, as for the step-up dialog). The page passes the options to the browser's WebAuthn call, one ceremony at a time, and sends the result only to POST /admin/auth/signin/finish as factor: { type: "webauthn", credential }. A cancelled, timed-out or failed browser ceremony shows a "did not finish" view with Try again, the app and the recovery code; it sends nothing. A browser that cannot do WebAuthn moves to the app or recovery-code view with a notice. Sign-in, step-up and setup share one rule for this: a browser without WebAuthn, or an insecure context, cannot do WebAuthn. Neither can the Android app, unless window.__myraNativeCaps.webauthn is the literal true (absent, "true", 1 or anything else counts as "cannot"), because its WebView can expose the browser API without serving it. A security failure of the browser (for example an rpId or origin mismatch) shows "did not finish" without Try again. 401 wrong_second_factor after a passkey is shown as a rejection without Try again. 400 invalid_field on factor after a passkey is shown as the "did not finish" view without Try again (the browser built a proof the server cannot read, so "not accepted for this account" would mislead). A security key alone (no passkey) goes through the same ceremony: while it runs the page waits with the security key view; a browser-side failure keeps that view with an error callout and Try security key again; and the three outcomes above end as they do for a passkey, without Try again. In all three cases the challenge is spent for this sign-in: the app does not retry on it and does not offer the passkey or security key again (the app and recovery views have no switch back to it); it offers the other factors or Back to sign-in, which starts a fresh email step (a new challenge). This is the app's own conservative behaviour; the server's rule for a spent challenge is not part of this contract yet. Other answers (a banner or unknown) are handled like those of a code. The page sends the factor only to POST /admin/auth/signin/finish as { pending_token, factor: { type, code }, remember_me? } (for a passkey the factor is the webauthn shape above; remember_me only when the person chose to stay signed in). The code is normalised before it is sent: six digits for the app code (spaces ignored); for a recovery code, 10 Crockford base32 characters (no I, L, O, U), spaces and hyphens and case ignored. Anything else is refused in the field and never sent. The app code is sent as soon as the sixth digit is typed; a recovery code is sent only on Verify. At most one request is in flight. The page reads the answers like this: 401 wrong_second_factor keeps the step, leaves the code in the field selected (typing replaces it; re-entering the same code does not send it again until the person presses Verify or Enter) and shows a fixed message; 400 invalid_field on factor shows the format message; 400 signin_expired and a missing_field or invalid_field on pending_token end the sign-in with a "sign in again" view; 429 factor_attempt_cap ends it the same way; 429 factor_failure_cap shows the paused view; 403 sso_required moves to the e-mail step with the SSO gate; 404 shows that the sign-in is not available; any other 400 from the application ends the sign-in with the "sign in again" view and a failed-request banner. On a 503, a network failure, a CDN answer or any other non-400 answer the banner is shown and the step is kept; the server decides a repeat (a factor it already accepted ends in the "sign in again" view). While a request is in flight, Use another account and the factor switch are disabled, so a late 200 always completes the sign-in. A 2xx is read fail-closed: no user object (or a malformed recovery_codes_left) is a failed request, no session is assumed, and the "sign in again" view is shown. One rule: before the page shows the "sign in again" view, for any reason (including a malformed 2xx), it asks GET /admin/auth/me while the step is busy. If the server already holds a session, the page continues with that user, the same rule as a magic link opened elsewhere, and shows no restart view and no banner. A 401, or any other failure of that request, shows the "sign in again" view. Nothing is signed out: no request to POST /admin/auth/logout is made by this step. The paused view, a wrong code, a 503 and a network failure do not ask. The finish request gives up after 30 seconds. After a recovery code signs in, the page shows a notice before the workspace opens (with a stronger warning when the answer carries recovery_codes_left: 0): the person continues to the workspace or goes to the security settings. The token is held in memory only and is never rendered, stored or placed in a URL.
Common rules
- Error shape. Flat:
{ "error": "<fixed text>", "code": "<code>" }. Clients readcode. Field errors carryfield. An absent value is400 missing_field, a malformed value is400 invalid_field(both existing codes,fieldnames the key), unless a row names a dedicated code. - Body gates. Every route that takes a body requires
Content-Type: application/json(unsupported_content_type), refuses duplicate keys (duplicate_key) and a body that is not a JSON object (malformed_body). - No values in the URL. These routes take no query string. Any query parameter answers
400 pii_in_query, checked before the body is read, and nothing is consumed. Tokens never appear in a path. - Fixed answers on a failed step. A refusal of the person's secret is one fixed answer per step; the text never says which input was wrong.
- Transient faults. A fault in the account lookup of
otp/request,otp/verifyandotp/verify-linkanswers503 { "error": "temporarily unavailable; retry later" }withRetry-Afteronly when the storage layer reports it as retryable; any other fault there answers500 { "error": "internal error" }. Every other fault on these flows (password sign-in, sign-in finish,setup/*,password/reset, the policy reads) answers the literal503 { "error": "temporarily unavailable" }. Nothing is consumed or counted. The changed/otp/verifyand/otp/verify-linkhave two stated exceptions where the code or link is already spent (Changed existing routes),password/resethas one: a fault after the link was consumed (Password reset), andsetup/email-codehas one: a fault after the code was accepted (see First setup).
Token types
All three tokens are the canonical base64url encoding of 32 random bytes (43 characters, no padding). Only their SHA-256 is stored. Each is single use, valid for at most 10 minutes (5 minutes for the step-up token) and travels in the JSON body only. The server reads the token from the body and nowhere else: any query parameter is refused before the body is read (400 pii_in_query, or the earlier malformed_query / unsupported_content_type answer), and a token in the path or query is never accepted. A background sweep deletes expired rows; it is hygiene only, because a token is checked against its expiry on every use.
| Token | Purpose | Used for |
|---|---|---|
pending_token |
signin or setup |
the public sign-in, first-setup and reset flows |
step_up_token |
step_up |
a fresh second-factor check while signed in |
enrollment_token |
enroll |
adding or moving a factor while signed in |
A route accepts only its own purpose and step (step table). A token presented as the aig_admin cookie fails as 401 malformed token; it is not a session.
Pending-token answers. Absent: 400 missing_field (field: "pending_token"). Present but not the canonical 43-character encoding (including a non-canonical last character): 400 invalid_field. Well-formed but unknown, expired, consumed, cancelled, of another purpose, bound to another session, or not at the step the route serves: one 400 signin_expired, so the answer is no oracle. Each step advances the stored row with one conditional update. Of two concurrent requests on one token exactly one wins; the other gets signin_expired.
A response that carries a pending token has the shape { "pending_token", "purpose", "next", "expires_at" }, plus factors and webauthn where stated. The token value stays the same across the steps of one flow. factors is always a JSON array of totp, passkey, security_key or recovery_code, naming what the person can use.
The factor object
Used by sign-in finish and by step-up:
type |
Shape |
|---|---|
totp |
{ "type": "totp", "code": "<6 ASCII digits>" }. Surrounding ASCII whitespace (space, tab, newline, vertical tab, form feed, carriage return) is trimmed first; the raw value, whitespace included, is at most 64 bytes, and the trimmed value must be exactly 6 ASCII digits (a number instead of a string, inner whitespace, signs and non-ASCII digits are refused). A code is valid for its own 30-second step and one step either side. This holds for every TOTP code on every route. The object carries exactly type and code; any other member is 400 invalid_field. Each 30-second step is accepted at most once per authenticator app: once a code is accepted, a code of the same or an earlier step is refused (401 wrong_second_factor, counted). The code that confirmed the app counts as used. A totp factor from a person without an authenticator app is 401 wrong_second_factor (counted). |
recovery_code |
{ "type": "recovery_code", "code": "XXXXX-XXXXX" }. Exactly the members type and code. The code is a string of 10 or 11 bytes: 10 Crockford base32 characters (digits and letters, no I, L, O, U, any case) with at most one hyphen inside (not first, not last). No whitespace, no other character. Anything else, an extra member or a wrong type is 400; a well-formed code that is not an unused one of the person is 401. A recovery code is accepted at step-up but is not a second factor of its own (see Step-up). Its amr entry is rc. |
webauthn |
{ "type": "webauthn", "credential": { "id", "rawId", "type": "public-key", "response": { "clientDataJSON", "authenticatorData", "signature", "userHandle" }, "authenticatorAttachment"?, "clientExtensionResults"? } }. id, rawId and the response members are base64url strings, except that userHandle may be null, "" or absent: a security key used without a stored (discoverable) credential sends none. The two optional members are what browsers add to the credential: authenticatorAttachment is a string (at most 64 bytes) or null, clientExtensionResults is an object. Both are ignored. Any other type for them, and any other member, is malformed. See WebAuthn assertion check for the full rules. |
An absent factor is 400 missing_field. An unknown type, a wrong shape, an oversize value, bad base64url, malformed CBOR or a malformed clientDataJSON is 400 invalid_field with field: "factor". That is never counted as a guess and never read as "no factor needed". A well-formed proof that does not verify (wrong code, replayed TOTP step, used recovery code, wrong origin or rpId, sign counter going backwards, bad signature) is 401 wrong_second_factor and is counted.
If the connection to the database is lost while an accepted code is being recorded, the answer is 503 { "error": "temporarily unavailable" } and that code's step may already count as used; enter the next code. A stored authenticator app the server cannot read (damaged data) also answers 503 for a totp factor and counts nothing; the same holds for a damaged stored recovery code and for any database fault while a recovery_code is checked or consumed (including a deadlock or lock-wait timeout, error 1213 or 1205): 503, nothing counted, never 401 "wrong". A recovery code is single use; if the connection is lost while the use is being committed the code may already be spent, so enter another one. the person's other factors stay usable and are still listed. The app's secret is stored encrypted with the gateway's master key and is never logged or returned after setup. A person has at most one authenticator app.
Passwords
The fields password, new_password and current_password: absent or "" is 400 missing_field. Not a string, longer than 1024 bytes, invalid UTF-8 or containing a control character is 400 invalid_field. A new password must satisfy these rules. A character is one Unicode code point: a precomposed "é" and a single-code-point emoji each count 1, an e followed by a combining accent counts 2, and nothing is normalised. A letter is any Unicode letter (\p{L}) and a digit is a decimal digit of any script (\p{Nd}, so ٣ counts, ² and ½ do not). Spaces count as characters but are neither. The rules run in this order and the first failure answers:
| Order | Rule | Answer |
|---|---|---|
| 1 | fewer than 12 characters | 400 password_too_short |
| 2 | no letter or no digit | 400 password_too_weak |
| 3 | on the shipped list of leaked passwords | 400 password_leaked |
| 4 | equal to one of the last 4 passwords: the current one and the three before it, newest first (by the order they were set, even within one second) | 400 password_reused |
The leaked list is matched exactly after folding ASCII upper case to lower case (PassWord… matches password…). Non-ASCII letters are not folded. The list is offline: it ships with the gateway, nothing is looked up over the network, and the password never leaves the process. It holds the 100000 entries that come first in the "Pwdb top 10 million" file (SecLists, Passwords/Common-Credentials/Pwdb_top-10000000.txt, MIT licence) among the lines that can pass rules 1 and 2, after folding, dropping duplicates and dropping e-mail-shaped lines. Pinned to SecLists commit 48c951a3c3afba4e647bfe6944a1fbd2fdbf2ca7 and generated on 2026-11-05; the first line of the data file records both.
If the list cannot be read or fails its own integrity check, or the letter/digit check itself errors, the answer is 503 { "error": "temporarily unavailable" }. Nothing is consumed or counted, and the request can be retried. With the list unavailable, a password that fails rule 1 or 2 still gets its 400. When the letter/digit check itself errors, rule 1 still answers first, but a password that rule 2 would refuse can get the 503 instead of password_too_weak.
A password is never logged, audited or echoed.
Rule 4 always checks four slots with the full hash cost, whether or not the account has that many earlier passwords (an empty slot costs the same as a filled one, and a match does not stop the check), so the time of the answer does not tell how many passwords an account has had. A fault in any slot answers 503, never a pass.
Locks, caps and timing
Locks and caps are checked before the secret. While one holds, the password or factor is not evaluated, and a correct secret gets the identical 429. The password lock and the two factor caps move by one conditional update in the database, never by read-then-write, so they hold across several gateway nodes. The global ceiling is the exception: it is held per node (see below). On the password and factor routes of this section, a 503 consumes and counts nothing, with these exceptions: a connection lost at the very commit of a failure count may leave that one failure counted, on setup/password a fault after the guess was counted leaves that guess counted (see there), on PUT /admin/v1/me/password a fault after the guess was counted leaves that guess counted, on the key register routes (setup/webauthn, /me/factors/webauthn) a fault after the registration was counted leaves it counted, and a session that cannot be minted after the commit answers 503 although the password was changed (see there). If it was the 10th wrong password, the lock holds, but its notice mail may not go out.
| Limit | Trigger | Answer |
|---|---|---|
| Password lock | 10 wrong passwords in a row | 429 signin_locked with Retry-After, until 30 minutes after the 10th. Wrong second factors do not count toward it. |
| Factor cap per token | 5 wrong factors on one pending, setup pending, enrollment or step-up token | 429 factor_attempt_cap; the token is burned |
| Factor cap per account | 20 wrong factors per account per hour, shared by sign-in, setup, enrollment and step-up | 429 factor_failure_cap |
Global ceiling on signin/password |
default 300 evaluated wrong passwords per 60 seconds per gateway node | 429 signin_rate_limited with Retry-After until the window ends |
How the counters move. A correct password ends a failure streak but never a running lock. A streak starts over at 1 after a lock has run out, and wrong passwords during a lock do not extend it. A lock ends at its second exactly: from the second the lock was set to end, the account is open again. The per-account factor hour is a fixed window that starts at the first wrong factor; the cap ends when that hour does, and a right factor does not reset it. Ending the password lock (for example by password/reset/complete) touches the password counter only, never the factor counter.
The global ceiling guards against password spraying. It counts only evaluated wrong passwords of existing password holders, including a break_glass request from a holder who is not on the list. A malformed request, an unknown or disabled address, a lock or a single sign-on refusal never counts. It is held in the node's shared memory like the other sign-in counters. Its windows are aligned to the minute, and a failure counts toward it only after the failure was stored; checking and counting are two steps, so concurrent requests can overshoot the ceiling by the number in flight. There is no per-IP cap, because the client address comes from X-Forwarded-For, which a caller can set.
Housekeeping. The same background sweep deletes second-factor counter rows whose window is more than two hours old and that carry no live lock. Password counters are never aged out, so a lock or a failure streak cannot be cleared by waiting for the sweep.
Timing. An unknown or disabled address runs one dummy Argon2id check with the current parameters, so the answer time does not separate it from a wrong password. On signin/password every address that passes the body checks and the single sign-on check makes the same database reads in the same order: the account lookup, the sign-in policy reads, the password-row check, the stored password, the password lock. Anyone who is not a password holder (unknown, disabled, deleted, an email_code person, a fixed-code account, a password_mfa person without a password, a break-glass non-member without a password) runs them against an id that has no row and then the dummy check; nothing is written for them. Stated residuals: a counted failure adds the failure-counter write and an audit row, so a holder's wrong password is a few milliseconds slower than an unknown address (the Argon2id check, about 20 to 35 ms, dominates both); a success adds the factor reads and the pending-token writes; for a holder without a factor it also adds the code write and the mail hand-over (the mail is sent after the answer, so the answer time does not depend on the mail server). A stored hash may carry parameters up to about 4 times the current cost (the hashing helper's cost ceiling), so an account with an old or high-cost hash answers measurably slower than an unknown address until its next successful sign-in rehashes it; the cost ceiling bounds that difference. When the stored parameters are not the current ones, a successful sign-in rehashes the password with the current parameters (one more Argon2id, so that success is slower); the password itself, its change time and its history are unchanged. While admin_mfa_enforced is on, a sys:admin holder skips the organisation's sign-in option read. Every request that reaches the check costs one Argon2id, also for an unknown address; the ceiling does not count those, and the gateway's nginx has no limit_req zone for /admin/auth/, so a flood of unknown addresses is bounded only by limits in front of the gateway. Each request costs exactly one Argon2id; there is no amplification.
Single sign-on enforcement
An organisation that requires single sign-on is checked on signin/password before the password is evaluated, and again at every step that issues a session (signin/finish, setup/finish, password/reset/complete). That re-check is membership-only, exactly as /otp/verify does it: the session-issuing routes never receive break_glass. On an enforced domain a list member proceeds, a non-member gets 403 sso_required, and a settings fault gets 503 sso_lookup_unavailable. In break-glass mode the login page offers both the email-code entry and the password entry, because the answer never says which applies.
| Case | signin/password |
Membership-only re-check when the session is issued |
|---|---|---|
| domain not enforced | proceed | proceed |
enforced, no break_glass |
403 sso_required |
list member: proceeds; non-member: 403 sso_required |
enforced, break_glass: true, member of the list |
proceed (also while the tenant's SAML validator is unconfigured) | list member: proceeds |
enforced, break_glass: true, not a member |
handled as a wrong password for that address: an existing password holder's attempt is counted as a failure even when the password is correct (it never resets the counter; it moves the per-account lock and the global ceiling, so it can reach 429 signin_locked), anyone else gets the dummy Argon2id verify; both answer 401 invalid_credentials. For an existing holder a real Argon2id verify of the submitted password runs, so the timing matches the dummy-verify branch. Membership is never revealed. |
non-member: 403 sso_required |
break_glass present, not a boolean |
400 invalid_request |
none |
enforced, SAML unconfigured, no break_glass |
503 sso_lookup_unavailable |
list member: proceeds; non-member: 403 sso_required (503 sso_lookup_unavailable only for an unreadable configuration or a membership lookup fault) |
| configuration unreadable | 503 sso_lookup_unavailable (fails closed) |
settings fault: 503 sso_lookup_unavailable |
password/forgot accepts an optional boolean break_glass (any other type, including null, gives 400 invalid_request). The answer is always the generic 200. On an enforced domain the reset mail goes only to a list member who has a password, and only with break_glass: true; a password-less member bootstraps through the email code (see Changed existing routes). Without break_glass on an enforced domain the answer is the generic 200 and no mail, decided from the domain alone: no per-address read runs. With break_glass: true the member, a non-member, an account of another organisation and an unknown address all get the same answer and the same reads (the account lookup, the domain, the membership, then the policy, password and brand reads); a settings or membership fault is 503 sso_lookup_unavailable.
No exemption for Myra admins. A sys:admin holder whose address is on an SSO-enforced domain signs in like any member there, as a break-glass user: the tenant must list them, because OIDC / SAML is refused for them while admin_mfa_enforced is on.
Disabled and deleted accounts
A disabled or deleted account (any reason, including inactive_90_days) is answered exactly like an unknown address. On signin/password that is 401 invalid_credentials and the password is not evaluated. On password/forgot it is the generic answer and no reset mail; the existing blocked-account notice of /otp/request is the only mail. Any open pending token of the account fails with signin_expired. POST /admin/v1/users/{id}/enable re-enables the account and clears disabled_reason.
Step-up
One rule applies everywhere, checked in this order:
- A
sys:adminholder whileadmin_mfa_enforcedis on whose sessionamrlackspwdplus a second factor:403 mfa_session_requiredon every step-up-gated action (likeimpersonation/start). - Any other session with an external
amr(oidc,saml,google,microsoft) or ademosession (demo sign-in is disabled): step-up is not required on any step-up-gated action and the field is ignored. These actions are: new API token, user token, device approval, erase own account, sign-in option change, second-factor reset, password reset link and sign-in unlock. The exception is the account-security routes under/admin/v1/me/: see the session requirement in Account security while signed in. -
Otherwise, an action that is step-up-gated needs a verified
step_up_tokenin its body when the caller's resolved policy ispassword_mfa; for any other caller the field is ignored. The rules below apply to this case. -
Missing, malformed, unverified, expired, used, or bound to another session:
403 step_up_required, nothing done. Absent and malformed share the restrictive answer on purpose. - A
password_mfacaller who has no factor (a session from before the organisation switched, living until its expiry):409 no_second_factor. Sign in again to set one up. Recovery codes are offered and accepted at step-up but do not count as a factor: a person who has only recovery codes (no authenticator app, passkey or security key) also gets409 no_second_factor. - A presented token is consumed even when the action then fails on another check, such as a wrong current password. It is spent when the action is accepted for processing, before the action itself runs; of two requests with one token exactly one is accepted, the other gets
403 step_up_required. - A burned token (5 wrong factors) on a gated action is answered
403 step_up_requiredlike any other unusable token; onlyPOST /admin/v1/me/step-upitself answers429 factor_attempt_capfor it. - A session that has no binding (its
auth_timeis present but malformed, or it has neither a usableauth_timenor a usableiat) cannot use or mint a step-up token: gated actions and both step-up routes answer403 step_up_required. - While viewing as another user (impersonation), step-up and every write route under
/admin/v1/me/…in this section answer the existing409 { "error": "not available while viewing as user" }and do nothing. - On every other step-up-gated action, the rules above evaluate the signed-in person (the admin who is viewing as the user), never the viewed user: that person's session
amrand id for rule 1, and that person's resolved policy for rule 3. Such an admin cannot get a step-up token while viewing as the user, so an action that needs one answers403 step_up_requireduntil they stop viewing as the user. - A verified token is good for one action, until its
expires_at, and only for the same person and the same sign-in. It is bound tosubandauth_time. Renewal keepsauth_time, so a verified token survives it. A password change or reset cancels it, like every other open pending row of the person (see Sessions issued by these routes). Two sessions of one person signed in within the same second share the binding; this is accepted.
Sessions issued by these routes
- A step that issues a session answers like
/otp/verify: theaig_admincookie,{ "user": … }andCache-Control: no-store. The session carriesamr["pwd", X]withXone ofotp(authenticator app),hwk(security key),swk(passkey) orrc(recovery code).last_login_atis stamped only there. remember_me: only a literaltruegives the 30-day session. Absent or any other value falls back to the 8-hour default, as on/otp/request. A 30-day "stay signed in" session is allowed withpassword_mfa; the next sign-in after it ends needs both steps again.- A password change or reset cancels every other open pending row of the person (pending sign-ins started with the old password, setups, step-ups, enrollments), as an admin's factor reset does.
- Ending other sessions keeps this one. After a password change, the next request with the new cookie answers
200and every session issued before the change, in the same second too, answers401. A password reset ends all sessions and issues none. - Limits. The session floor is stamped from the clock of the node that commits the change. A node whose clock runs behind by more than the one-second resolution may mint or accept a session differently; this is the same cross-node clock-skew limit that already applies to every session floor. The cache invalidation after a change (
invalidate_pairs) is per node and best effort: other nodes forget the old sessions when their cache entries expire, as for MAP-4110.
Which step a route accepts
The stored row decides; the client cannot pick a step.
| Route | Token purpose | Accepted when | Next after success |
|---|---|---|---|
signin/finish |
signin |
started by password or reset_link, no factor proven yet |
a session (from password); new_password (from reset_link) |
password/reset/complete |
signin |
started by reset_link and a factor was proven |
a session |
setup/password |
setup |
the password step is not yet done in the row | choose_factor |
setup/email-code |
setup |
started by password, the email step is not yet done in the row |
choose_factor |
setup/totp, setup/totp/confirm, setup/webauthn/options, setup/webauthn |
setup |
the password step is done in the row and, in a row started by password, the email step too |
choose_factor (more factors may be added) |
setup/finish |
setup |
any open step; without the password step, the email step (row started by password) or an enrolled factor in the row it answers 409 setup_incomplete |
a session and recovery codes |
signin/cancel |
signin, setup |
any open step | none |
/admin/v1/me/factors/*/confirm, /admin/v1/me/factors/webauthn |
enroll |
same session (sub and auth_time), not yet confirmed |
none |
/admin/v1/me/step-up |
step_up |
not yet verified, same session | none |
| step-up-gated actions | step_up |
verified, same session, unused | none |
All conditions are row state, meaning what was done in this pending row, never the person's stored state. first_factor records how the row started: password, email_code (first setup), reset_link, or session (step-up and enrollment rows, which start from a signed-in session). factors_done records the steps done in the row: pwd once the password step is done in it, email once the email code step is done in it, and the factor type once a factor is proven or enrolled in it. Rows from signin/password start with the password step done and need the email step before any factor is set up. Rows from first setup (/otp/verify) and from a reset link start without the password step; they began with a mailed code or link, so they have no email step. The email step is not a factor and never appears in the session amr.
Any other combination answers 400 signin_expired (pending and enrollment tokens) or 403 step_up_required (step-up tokens). An enrollment token bound to another session is answered signin_expired. A session whose auth_time is present but malformed has no binding, and its tokens are answered as bound to another session. A session without an auth_time claim binds on iat, the value renewal carries forward; one with neither a usable auth_time nor a usable iat has no binding. A setup/password in a row started by a reset link sets a new password for a person who already has one. The reset rules apply: new-password rules including history, other sessions ended, other pending rows cancelled, lock cleared.
Changed existing routes
| Route | Change |
|---|---|
POST /admin/auth/otp/request |
A person on password_mfa who has a password gets no code and no mail: 200 { "message": <the generic text>, "next": "password" }. Everyone else is unchanged, including first setup: a password_mfa person without a password still gets the code. On a domain that enforces single sign-on, a request with break_glass: true behaves as in Require single sign-on: the same generic body for every address, member or not, and never a next field. A code is mailed only to a list member whose policy allows a code: an email_code member, or a password_mfa member without a password yet (who bootstraps through /otp/verify, which answers the setup pending token). A password_mfa list member who has a password gets the generic body and no code; they use the password. Every fixed-code account in password_mfa gets the generic body and no code, with or without a password, and never next. Timing in break-glass mode (E69): while the sign-in flags are on, every break_glass: true request on such a domain makes the same database reads in the same order, whatever the outcome: the user lookup, the single sign-on discovery, the break-glass membership read (also for an unknown address, as a read that finds no row), the sign-in option reads and the password-row read (for a non-member against an id that has no row; no row is ever written for it), and then the blocked-account lookup. The mail's product name is read after the answer. The one remaining database difference is the code row stored for an eligible member. Remaining non-database differences: building the code and link and scheduling the mail for an eligible member, and the in-process time of the extra rows a member's reads return. One more read difference: a sys:admin list member while admin_mfa_enforced is on skips the organisation's sign-in option read. With both flags off the route is unchanged. The password lock part of "same lock and timing" is the subject of signin/password (S2-L3). |
| OIDC and SAML callbacks | A sys:admin holder while admin_mfa_enforced is on is refused like a denied single sign-on: 302 to /login?error=admin_mfa_required, nothing minted. The check runs after the organisation check of the link (a link of another organisation keeps its sso_denied, and the identity provider's own MFA requirement keeps its sso_mfa_required) and before the link e-mail / name refresh, the group and department sync, last_login_at, the sso.login / saml.login row and the session; this holds for a linked, a concurrently linked and a first-linked account. On an account's first single sign-on, the identity link (and, with just-in-time provisioning on, the new account) is already written before the check (it is what a successful sign-in writes, and it grants nothing while enforcement is on or the check faults: a just-in-time account holds no platform role, so it is never refused, and after a fault the next sign-in proceeds as a linked one). On SAML the AuthnRequest is consumed and the assertion id recorded (replay protection) either way. The refusal is never counted toward the SSO refusal lockout, sends the same headers as the sibling denials, and writes the platform audit row sso.admin_mfa.login_denied / saml.admin_mfa.login_denied (audit log). Normal members, including members of a password_mfa organisation, sign in unchanged. Faults: fault answers (sso_unavailable). |
POST /admin/auth/otp/verify and /otp/verify-link |
A password_mfa person with a password, and every fixed-code account in password_mfa: 403 password_signin_required, the code is consumed, no cookie. A password_mfa person without a password gets no cookie but 200 { "pending_token", "purpose": "setup", "next": "create_password", "expires_at" }; every earlier pending token of that person is cancelled first. The account re-check, the disabled/deleted check and the single sign-on re-check run first for every outcome, so a normal member of an organisation that enforces single sign-on gets 403 sso_required, never password_signin_required. Faults: on /otp/verify the sign-in option is read before the code is checked (503 temporarily unavailable, nothing consumed). Two 503 answers come after the code or link was used up, so the person requests a new one: on /otp/verify-link, a fault reading the sign-in option or the password row after the link was redeemed (the link names no person before that); and on both routes, a fault storing the setup token after the code or link was accepted. |
| Google and Microsoft callback and app redeem | A sys:admin holder while admin_mfa_enforced is on: the login page gets ?oauth_error=admin_mfa_required (302, also when the flow started on the sign-up page: the account exists), the app redeem gets 403 { "reason": "admin_mfa_required", "page": "login" } (exactly these two keys). Nothing is minted. The check runs for an existing account (and for the account that won a concurrent double registration) after the single sign-on enforcement check (an enforced domain still sends the person to the organisation's identity provider, where the refusal happens) and the disabled / deactivated checks, and before the identity link, last_login_at, the oauth.login row and the session. A newly provisioned trial account is never checked (it holds no platform role). The state or handoff code is used up either way; for the double-registration loser the synthetic sign-up intent and the two anonymous funnel counts exist, as for every loser. Same headers as the sibling denials; the platform audit row oauth.admin_mfa.login_denied (audit log). Faults: fault answers (try_again, app 503 { "reason": "try_again", "page" }). |
POST /admin/auth/renew |
Precedence: a session with an external amr (oidc, saml, google, microsoft) or a demo session (demo sign-in is disabled) is renewed unchanged, except for a sys:admin holder while admin_mfa_enforced is on, who gets 403 mfa_session_required. The password_mfa refusal applies only to email / static_otp sessions and sessions without amr (or whose amr lacks a second factor), for a person now on password_mfa: 403 mfa_session_required. The cookie is untouched, nothing is minted, and the session lives until its exp. A pending token as the cookie is 401 malformed token. A fault while deciding (an unreadable or malformed sign-in switch or stored sign-in option, a failed role read) is 503; nothing is minted. |
POST /admin/auth/impersonation/start |
While admin_mfa_enforced is on, a sys:admin holder's session whose amr lacks pwd and a second factor: 403 mfa_session_required, checked after the owner-role 403 and before the body is read, audited as impersonation.denied with status 403. Other owners are not gated here. An unreadable or malformed admin_mfa_enforced or a failed role read is 503; nothing is written. |
POST /admin/v1/me/tokens, POST /admin/v1/users/{id}/tokens, POST /admin/v1/device/approve, DELETE /admin/v1/me/erase |
Step-up-gated (rule). The step-up is checked after the route's own authorization and input checks (an unknown or foreign target, a refused label, scope or lifetime, a gateway outside the tenant, self-mint off, the shared-demo and protected-account refusals) and right before the write, so a request that would be refused anyway spends no token and answers its own 400, 403 or 404 first (for a Myra admin on a pre-enforcement Google or OIDC session that includes 403 mfa_session_required). A caller who needs a token must send application/json with no query. The token is read from the same request body the route itself reads, including a body large enough that the server spools it to a file. For POST /users/{id}/tokens the signed-in admin's sign-in policy decides, not the target user's. An exempt caller's step_up_token is ignored, except on DELETE /me/erase while sign-in with password and second factor is switched off, where any body is still 400 invalid_request. A malformed or unreadable rollout switch answers 503 and nothing is done. |
GET /admin/v1/users (every scope, including scope=all and scope=deleted_tenants), GET /admin/v1/tenants/{id}/users and GET /admin/v1/users/{id} |
New per-member fields: second_factor ("set_up", "not_set_up", "not_required" or "malformed"), signin_locked_until (unix seconds or null), disabled_reason (null for now; "inactive_90_days" is reserved). The three are present exactly when the row is not deleted, password_mfa_enabled is on, and the row's organisation is live and its resolved policy is not email_code. They appear together or not at all. not_required means the member signs in through single sign-on (the same decision as the sign-in gate; there is no platform-admin exception, with admin_mfa_enforced on or off). set_up means at least one valid factor row exists. malformed (with signin_locked_until null) marks a row whose policy value is not a known one, whose factor row has an unknown type or kind, or whose lock lies more than 24 h in the future; it is never shown as "no second factor", and the other rows of the list are unaffected. The values come from bounded batch reads, so the cost does not grow with the number of rows. If any batch read fails the whole answer is 503 (never a list with guessed values). A malformed or unreadable password_mfa_enabled, or, while it is on, password_mfa_tenant_allowlist, answers 503 { "error": "temporarily unavailable" } for the whole list (for GET /users/{id}, for that person), not a list without the fields; it is read only when the answer holds at least one live row with an organisation. While password_mfa_enabled is on, these answers carry Cache-Control: no-store. The Members list treats a partial or wrong-typed set as malformed. |
GET /admin/v1/tenants (platform admin only) |
Each row gains signin_policy: "email_code" or "password_mfa", or "malformed" when the organisation is on the allowlist and its stored option is not one of the two (or its row is gone between the two reads). It is present on every row only for a platform admin while password_mfa_enabled is on; it is absent otherwise (organisation admins, members, a platform admin viewing as another user, flag off). A database fault reading the stored options answers 503 for the whole list. A malformed or unreadable password_mfa_enabled, or, while it is on, password_mfa_tenant_allowlist, answers 503 { "error": "temporarily unavailable" } for the whole list, not a list without signin_policy. It is the option as it applies to the organisation's members (resolution steps 3-4 of the sign-in policy: the stored option when the organisation is on password_mfa_tenant_allowlist, otherwise email_code), not the per-person resolution (steps 1-2) and not a stored value that is not in force, so a report shows what is enforced. For an organisation on the allowlist this is the option GET /admin/v1/tenants/{id}/signin-policy returns; for any other organisation that route answers 404, while the list shows email_code. The web app shows a present value outside the two as an "Invalid value" error cell on that row (never as email_code); the rest of the list stays usable. |
Sign in
All three routes are public.
| Route | Body | Answer |
|---|---|---|
POST /admin/auth/signin/password |
{ email, password, break_glass? } |
200 { pending_token, purpose: "signin", next: "second_factor", factors, webauthn?, expires_at }. A password holder with no factor yet gets 200 { pending_token, purpose: "setup", next: "email_code", expires_at } and an email code is mailed (see First setup). |
POST /admin/auth/signin/finish |
{ pending_token, factor, remember_me? } |
A session. From a reset link: 200 { pending_token, purpose: "signin", next: "new_password", expires_at } and no session. The answer adds "recovery_codes_left": 0 only when a recovery code was just used and it was the last one; every other sign-in, including one by a person who holds a factor but no recovery codes, carries no recovery_codes_left member. Order: flag (404), body shape, token (400 signin_expired for an unknown, expired, spent or foreign row), the single-sign-on re-check (also for reset-link rows), then the factor. Each wrong factor is counted before it is verified (5 per token: 429 factor_attempt_cap; 20 per hour per account: 429 factor_failure_cap), so parallel requests cannot exceed a cap; an accepted factor gives the count back. Two requests with two different valid factors on one token: the first wins, the second gets 400 signin_expired and its factor is spent. last_login_at is stamped only when a session is issued. A refused mint (for example a suspended organisation) leaves the row and the counts untouched. |
POST /admin/auth/signin/cancel |
{ pending_token } |
200 { "ok": true } for any well-formed token, known or not. Absent: 400 missing_field. Malformed: 400 invalid_field. |
signin/password checks, in this order: flag (404), global ceiling (429 signin_rate_limited), content type and body shape, email shape (as /otp/request), password field shape, single sign-on enforcement, password lock (429 signin_locked, password not evaluated), then the password, then (only for a holder with no factor) the email-code request cap. A wrong password, an unknown, disabled or deleted address, and an email_code person all give one 401 invalid_credentials. A holder with no factor over the request cap of /otp/request gets 429 { "code": "otp_request_cap" }: no token, no mail. A repeated submit replaces the older open pending token: one live token per person. webauthn holds the request options { challenge, rpId, allowCredentials, userVerification: "preferred", timeout } and is present only when the person has a passkey or security key.
signin/password in detail. email follows the /otp/request address rules, with one difference: a present value that is not a string (null, a number, a boolean, an object) is 400 invalid_email, not email required (absent and malformed are different answers). password follows Passwords: absent or "" is 400 missing_field, anything else that is not a valid password field (including null) is 400 invalid_field, both with field: "password". break_glass absent is false; anything but a boolean, null included, is 400 invalid_request with field: "break_glass". Other body members are ignored. None of these refusals is counted. Every answer after the flag check carries Cache-Control: no-store. Both 429 answers carry Retry-After. The 10th wrong password in a row is itself answered 429 signin_locked. One fixed 401 invalid_credentials answers a wrong password and everyone who is not a password holder: an unknown, disabled or deleted address, an email_code person (also one who still has a password), a fixed-code account and a password_mfa person without a password (who starts with the email code of /otp/request). factors lists only the factors the gateway can verify; a person whose stored factors include none it can offer gets 503 { "error": "temporarily unavailable" }, never a no-factor answer. Recovery codes are a fallback for a factor, not a factor: an offer of nothing but recovery_code is the same 503. A password holder with no stored second factor goes to the email-code setup step above even when unused recovery codes are left: recovery codes alone never count as a factor. A new pending token replaces the person's older open ones; two submits for the same person at the same moment can leave neither token usable (each one's clean-up removes the other's token), never two, and the person then signs in again. A fault anywhere answers 503 { "error": "temporarily unavailable" } and counts nothing (a single sign-on fault keeps its own 503 sso_lookup_unavailable). Counted failures, the lock and an issued pending token are audited as auth.password_failed, auth.password_locked and auth.password_accepted (a pending sign-in or setup token); the first lock of an account also sends the sign-in locked mail.
First setup
Public routes with purpose: setup; the steps follow the step table. There are separate entry paths. A person without a password gets an email code from /otp/request, and /otp/verify answers next: "create_password" (bootstrap); a reset link for a person without a factor also starts purpose: setup. A person who has a password but no factor, including after an admin reset of the factors, signs in with signin/password, which answers purpose: "setup", next: "email_code" and mails an email code. A password alone never leads to factor setup: the code proves control of the mailbox before a new factor is added. Only after setup/email-code does the row accept the factor routes. A reset link already proves the mailbox, so a row started by it has no email step.
The email code. It is the existing sign-in code of POST /admin/auth/otp/request, not a new kind: the same code store, the same code mail in the same language but without the one-click link, the same lifetime (the code window), the per-address request cap (10 per code window), the keep-live rule and the shared guess budget. A repeated signin/password replaces the pending token and mails a new code; earlier codes stay live. The code mails of signin/password count against the same 10-per-window request cap as /otp/request (over it: 429 otp_request_cap, no token, no mail). Open product question: whether setup mails should have a separate cap. A 503 on the setup branch after the cap check has spent one request-cap slot; a code stored before the fault stays live until it expires but cannot be used, because the answer carries no pending token. The code is checked only by setup/email-code against the address of the pending row. Typed into /otp/verify it answers 403 password_signin_required and is consumed, as for every password holder; it never issues a session.
| Route | Body | Answer |
|---|---|---|
POST /admin/auth/setup/password |
{ pending_token, password } |
200 { pending_token, purpose: "setup", next: "choose_factor", expires_at } carrying the same token, its password step now closed. See setup/password in detail below. |
POST /admin/auth/setup/email-code |
{ pending_token, code } |
200 { pending_token, purpose: "setup", next: "choose_factor", expires_at }. code absent or not a string: missing_field / invalid_field. The shape check of /otp/verify follows (over 64 bytes invalid_field; after trimming not 4 to 32 bytes 400 invalid_otp), never counted. Wrong or expired: 401 invalid_otp (counted). The caps of /otp/verify apply: 5 wrong guesses exhaust the code (429 otp_attempt_cap, a new signin/password mails a new one), 20 rejected attempts per address per hour 429 otp_failure_cap. A ? query string is 400 pii_in_query. Success retires every live sign-in code of the address. The password lock does not apply to this route and its wrong codes do not count toward the factor caps; each wrong code is audited as auth.otp_failed (and auth.otp_blocked when a cap answers). A person who is no longer eligible for this step (disabled, deleted, address changed, or switched to another sign-in option) gets 400 signin_expired and nothing is consumed or counted. This includes a person who enrolled a factor after the token was issued. Two concurrent requests with the right code have one winner; the other gets 400 signin_expired. A code that was already used, and a code from an earlier row that a newer /otp/request or signin/password retired, also answer 400 signin_expired, not 401. A database fault after the code was accepted answers 503 and the code is spent: the person signs in again for a new one. |
POST /admin/auth/setup/totp |
{ pending_token } |
200 { secret: "<base32>", otpauth_uri } (secret is base32 (A-Z, 2-7, no padding, at least 16 and at most 128 characters) and otpauth_uri is an otpauth://totp/ URI of at most 2048 printable ASCII characters whose secret parameter is that same secret, appearing once; digits, period and algorithm are absent, or appear once as 6, 30 and SHA1 (algorithm in any letter case); the web app refuses any other answer as malformed and shows no QR code or key). A new call replaces an unconfirmed secret. At most 10 secrets per pending token: the 11th call answers 429 rate_limited and does not burn the token. An app already confirmed in the row, or already stored for the person: 409 totp_already_set_up. |
POST /admin/auth/setup/totp/confirm |
{ pending_token, code } |
200 { factor }. code absent: missing_field. Not a string of 6 ASCII digits after trimming: invalid_field. Wrong: 401 wrong_second_factor (counted). A second app: 409 totp_already_set_up. The factor caps apply: 5 wrong codes on the token burn it (429 factor_attempt_cap), 20 per account per hour (429 factor_failure_cap). The same caps apply to POST /admin/v1/me/factors/totp/confirm with its enrollment token. Without a secret from setup/totp in the row (none was made, or a passkey or security-key options call replaced it): a counted 401 wrong_second_factor. A resend after a success: 400 signin_expired, not counted. |
POST /admin/auth/setup/webauthn/options |
{ pending_token, kind } |
200 { publicKey } with creation options: attestation none, ES256 and RS256, platform or cross-platform attachment, userVerification: "preferred", excludeCredentials. kind absent: missing_field. Not "passkey" or "security_key": invalid_field. |
POST /admin/auth/setup/webauthn |
{ pending_token, name, credential } |
200 { factor }. credential is { "id", "rawId", "type": "public-key", "response": { "clientDataJSON", "attestationObject" } }, all values base64url strings. The same key twice: 409 factor_already_registered. credential absent: missing_field. Malformed, oversize or bad CBOR: invalid_field. The checks are listed under WebAuthn registration check and credential store. |
POST /admin/auth/setup/finish |
{ pending_token, remember_me? } |
A session plus "recovery_codes": [10 strings], shown once. From a row started by a reset link it also carries "other_sessions_ended": true (the reset rules apply); a row started by sign-in carries no other_sessions_ended member. The recovery_codes follow the rule below and the web app refuses any other answer as malformed. Password, email step (row started by password) or factor missing: 409 setup_incomplete. One request finishes a token: a second submit, during or after the first, answers 400 signin_expired and neither creates nor stores codes; while a request is finishing, setup/webauthn/options, setup/webauthn, setup/totp and setup/totp/confirm on the same token answer 400 signin_expired too (uncounted). A server fault (503) leaves the token usable for a retry. |
setup/password in detail. Two kinds of row reach this route. A row started by the email code (create_password, no password yet) sets the first password; a row started by a reset link replaces the current one. The route checks that the row and the person agree: a reset row for a person who has no password, or a create row for a person who already has one, answers 400 signin_expired. The order of the checks is: the flags; pending_token (then password; a bad token is answered first); the row (a row that has used up its guesses answers 429 factor_attempt_cap at once, with no hashing); whether the password step is still open in the row; the person (see below); the length, letter/digit and leaked-list rules, which answer before anything is counted; then the guess count and the history rule. Every answer carries Cache-Control: no-store, and a password is never in an answer, a log line or an audit row.
Answers. 200 { pending_token, purpose: "setup", next: "choose_factor", expires_at } carrying the same pending_token, whose password step is now closed (a second submit answers 400 signin_expired); no cookie is set. 400 missing_field or invalid_field on pending_token or password, 400 pii_in_query for a ? query. 400 password_too_short, password_too_weak, password_leaked, password_reused. 400 signin_expired for an unknown, expired, spent or closed row, a row already past this step, a person who is no longer eligible, a mismatch between row and person, a second submit of the same row (single use) and a factor enrolled after the row was issued (E99). 429 factor_attempt_cap. 404 while the feature is off. 503 { "error": "temporarily unavailable" } for any fault (list, hash, storage, a commit that fails), and then nothing is stored.
Caps. The history rule costs four hashes, so each evaluated password is counted against the row before it is hashed, with the same limit of 5 wrong guesses per row as the factor routes. A password_reused answer keeps its count; only a winning submit gives it back. A 503 after the count keeps it too (a fault never gives a guess back, as on signin/finish), so five faults on one row also end in 429 factor_attempt_cap. The length, weak and leaked answers are not counted. After the 5th the row answers 429 factor_attempt_cap and the person signs in again. The password lock and the factor failure cap do not apply to this route.
The person is re-checked. The route does not trust the row alone: a person who was disabled, deleted, moved to another sign-in option or given another address since the row was issued, and a person who has enrolled a second factor since (E99), gets 400 signin_expired and nothing is stored or counted.
One commit. The new password, its history, the end of the old sessions (reset only) and the step in the row are one transaction. A concurrent second submit of the same row has one winner; the other answers 400 signin_expired. A database fault answers 503 and rolls everything back, so the row stays usable for a retry; the guess counted before the hash stays counted (see Caps).
First password. The row is advanced (pwd done), nothing is added to the history, no mail is sent, and the change is audited as auth.password_set.
Reset. The old password moves into the history, every device sign-in family of the person is ended, all browser sessions are ended (those issued in the same second as the reset are ended too, see the residual), every other open sign-in or setup row of the person is cancelled, the password lock and the failure count are cleared, and the password reset mail is sent after the commit. API tokens are kept. The change is audited as auth.password_reset.
Residual. The session floor has a one-second resolution and a session whose issue time is at or before the floor is refused, so a session minted in the very same second as the reset is ended too, including one created after the floor was stamped in that second. The only remaining bound is the clock: nodes with skewed clocks disagree by their skew.
What the web app does. A purpose: setup answer opens one setup flow inside the sign-in card, with a step trail (Email code or Password, Method, Set up, Recovery codes). email_code (a password holder, who already has a password) starts at the e-mail code step (heading "Check your email"; a wrong code keeps the field for a retry), and the answer to the code goes straight to the choice of method; the page never asks for a password there and never calls setup/password (the step trail keeps "Email code" as its first step). create_password starts at the new-password step (the same form as the reset page), then the choice of method. Both lead to the choice of method: passkey, security key or authenticator app. In a browser without WebAuthn (or an insecure context) passkey and security key are shown disabled with a note and the app is preselected. The same shared rule applies in the Android app. It counts as a browser without WebAuthn unless it advertises webauthn: true in window.__myraNativeCaps, which it does only when it enabled WebAuthn in its WebView and read the setting back. The page accepts only the literal true; an absent value (as in an older app build) and any other value, such as "true", 1 or an object, count as "cannot". So a WebView that exposes the browser API but cannot serve it never offers a passkey that would fail. The iOS app and the web do not read this capability. For the app to use passkeys (to create one and to sign in with it), the WebAuthn rpId host must serve /.well-known/assetlinks.json with the delegate_permission/common.get_login_creds relation for the app (the file served with the web app carries it for the app host; an rpId on another host must serve it too), and the app must be signed with a certificate listed there. The authenticator app and the recovery-code finish are described below. The passkey and security-key steps are described in the next paragraph. An expired token (400 signin_expired), the code caps (otp_attempt_cap, otp_failure_cap), setup_incomplete, a malformed answer or any other 400 show a restart view with Sign in again; a 404 shows "Setting up sign-in is not available right now."; a 503, a network failure, a timeout or a CDN answer keeps the step and its input and shows a banner; Use another account cancels the pending sign-in. A late answer to a step the person has already left is dropped.
Passkey and security key in the web app. Choosing a passkey or a security key asks POST /admin/auth/setup/webauthn/options with { pending_token, kind } when the step opens (and again after a refusal, see below) and shows the name step (frames B2p and B2k). The name is suggested from the browser and device and can be edited. The field takes at most 40 characters. The rule it is checked against is the server's (1 to 64 characters after trimming, no control characters), and the browser checks it before anything is asked of the authenticator. The creation options are read fail-closed, as for the profile enrolment (a canonical base64url challenge, an rp.name, a user.id of 1 to 64 bytes, 1 to 16 pubKeyCredParams, only known attestation and authenticatorSelection values); a malformed answer shows the restart view and the browser is never asked. The page then makes one navigator.credentials.create call (with the options' timeout, or 60 seconds when they carry none), with a Cancel button while it waits, and sends the result only to POST /admin/auth/setup/webauthn as { pending_token, name, credential }; the answer must be a factor of the kind that was asked for. While it waits, the form stays on screen with the name and the button disabled. A cancelled or timed-out ceremony (Cancel included), and a browser failure, send nothing, keep the form and show a callout with Try passkey again / Try security key again (a security failure of the browser, or a browser without WebAuthn support, does not offer another try; Back is then the main action). A key the authenticator already holds for this account (excludeCredentials) makes the browser refuse before any credential exists: the page shows "already added", sends nothing and keeps the same options. 409 factor_already_registered shows "already added" too, but there a credential was created: the page drops it and fetches new options. The same applies to a credential the server refuses (401 wrong_second_factor, or a 400 on credential): a callout, the credential dropped, new options, and the next try prompts the authenticator again. A lost answer does not prompt twice. When the browser created the credential but setup/webauthn got no usable answer (network failure, 503, timeout), the created credential is kept in memory and the next Try again resends that same credential; the authenticator is not asked again, so no second key is created. This also holds after Back and a return. A name refused by the server (invalid_field or missing_field on name) keeps the credential and focuses the name field. signin_expired, an error on pending_token, 429 factor_attempt_cap and 429 factor_failure_cap show the restart view; a resend that is definitely refused ends the setup the same way. Neither the credential nor the options are put in a URL, storage or an attribute. The shared form lives in common/components/mfa/WebauthnEnrol/ and knows no token, so the profile enrolment can reuse it. After the recovery codes, the done step names the factor and offers a tip (a second passkey or the app; for a security key, a second key).
Authenticator app and recovery codes in the web app. Choosing the app asks POST /admin/auth/setup/totp once and shows the QR code (drawn in the browser from otpauth_uri, no request is made for it) and the key in groups of four with a Copy key icon button (announced as "Key copied"); neither is put in the URL, storage, the page title or any attribute. Back and a return to the step show the same key without a new request, because a new setup/totp call would replace the secret the person may already have scanned. The page sends the code to setup/totp/confirm only when it is six digits after spaces are ignored; empty and malformed input are refused in the field and never sent. 401 wrong_second_factor and a 400 invalid_field or missing_field on code keep the QR code and the typed code (selected, focused) and show a message; 429 factor_attempt_cap and 429 factor_failure_cap end the setup with the "sign in again" or paused view; 409 totp_already_set_up restarts the setup. A network failure or 5xx is a banner and the step stays. After the app is confirmed the page calls POST /admin/auth/setup/finish once, with remember_me only when the person chose to stay signed in, and shows the ten recovery codes once, with Copy and Download; Finish setup stays disabled until the person ticks that the codes are saved. setup/finish is one-shot, so a repeat after a lost answer would be 400 signin_expired: the page then asks GET /admin/auth/me (30 seconds) before showing the restart view. A 401 shows the restart view. If a session exists it says that the codes could not be shown and that new ones can be created under My account > Security. If the answer is unknown (network failure, timeout, 5xx) the page shows a banner and keeps the step; on the first setup/finish request any of these is retried by Try again, which sends setup/finish again; if the first request was in fact processed, the repeat answers 400 signin_expired and the page asks GET /admin/auth/me as above. After a lost or expired answer whose GET /admin/auth/me check was inconclusive, Try again only asks GET /admin/auth/me again and never sends setup/finish a second time. The codes are never logged and never put in the URL, title or storage.
A factor name is validated the same way everywhere (setup, add and rename): absent, "" or whitespace only is 400 missing_field; not a string, invalid UTF-8, longer than 64 code points, or containing a control or format character (the has_control_or_format classifier: zero-width, bidirectional, line and paragraph separators, joiners such as a ZWJ emoji sequence; a variation selector after a valid base character is allowed) is 400 invalid_field. Surrounding whitespace is trimmed before the length check. A refused name is never stripped into a valid one. The server applies the same rule when it stores a name: the authenticator app added by setup/totp/confirm gets the fixed name Authenticator app, which passes it. Names stored before this rule was tightened are still listed and shown.
The factor object in answers is { id, type: "totp" | "webauthn", kind: "app" | "passkey" | "security_key", name, created_at, last_used_at }. Times are unix seconds; last_used_at may be null. id is a string (a UUID), unique within a factors list; the web client treats a duplicate id as a malformed answer.
Account security while signed in
These routes use the session cookie and answer 404 for a caller not on password_mfa.
Adding a factor in the web app. The Security view's chooser asks for step-up before starting app or WebAuthn enrolment (overriding design C11's no-step-up note). Step-up tokens are single-use: a refused credential or failed options request needs a new confirmation before fetching options again. No recovery codes are issued on addition. Enrolment requests use a bounded 30-second timeout; 401 wrong_second_factor is a business refusal, not a sign-in redirect. Wrong app codes remain field errors; bad code shape is rejected without sending. Name refusals keep the credential for a corrected submission; duplicate or rejected credentials fetch new options only after fresh step-up. Expired enrolment and attempt/failure caps close the flow with a notice; mfa_session_required and viewing-as refusals close it with the matching session notice. An own 404 closes and refreshes; a foreign 404 remains a generic failure. Malformed options never start a ceremony; malformed or wrong-kind success answers never produce a success toast. A network, timeout, server or malformed write answer refreshes the factor list because the write might have applied, and leaves any retry to the person. Chooser restrictions are UX only: the server enforces eligibility, tokens and factor limits.
Moving the app in the web app. The Security view shows Move app to a new phone only for a person with an app factor. It asks for step-up first, without excluding the app (the current app, another factor or a recovery code confirms; the old phone may be lost), then sends POST /admin/v1/me/factors/totp/move with that single-use token and confirms with POST /admin/v1/me/factors/totp/confirm and the move's enrolment token. A start refused with 403 step_up_required asks for a new step-up before the next start; the spent token is never sent again. Cancel at any point sends nothing: there is no cancel route, and the pending enrolment expires on its own while the old app keeps working. 409 totp_not_set_up (at start or confirm) closes the dialog with a notice and re-reads the list. A lost confirm answer (network, timeout, server error, or a success answer that is malformed or not of kind app) is never shown as success: the dialog stays with a banner and the list is re-read. A move keeps the factor's id, name and creation date, so the list cannot show whether it committed; a later 400 signin_expired after such a loss is reported as "most likely moved".
Session requirement. The password, factor (add, move, confirm, rename, remove) and recovery-code write routes under /admin/v1/me/, and /admin/v1/me/step-up*, answer 403 mfa_session_required for any session whose amr lacks pwd plus a second factor (external sessions such as oidc, saml, google, microsoft, and demo sessions included). Sign in with password and a factor to manage them. GET /admin/v1/me/security stays readable. The requirement is enforced for every route of this list, including one that is not yet available: such a route answers the requirement's 404, 409 or 403 first, and the unknown-route 404 only for a session that meets it. These refusals change nothing. They reach the audit log like any refused admin request (a 403 as an access-denied event); while viewing as a user they write no audit row of the viewing-as write.
On these routes the answers come in this order: 404 (caller not on password_mfa), 409 not available while viewing as user, 403 mfa_session_required, then the route-specific answers. GET /admin/v1/me/security is the exception: after the 404 it answers 403 impersonation_forbidden while viewing as a user (not 409), then its own answers.
| Route | Body | Answer |
|---|---|---|
GET /admin/v1/me/security |
none | 200 { password_set, password_changed_at, factors: [factor], recovery_codes_left } with Cache-Control: no-store. password_changed_at is unix seconds, or null without a password. factors is a JSON array ([] when none) of the factor object in answers (above), { id, type, kind, name, created_at, last_used_at }, oldest first; the pairs are totp+app, webauthn+passkey and webauthn+security_key, and last_used_at is null when never used. recovery_codes_left is the number of unused recovery codes, 0 to 10. No secret is ever returned. Any query string: 400 pii_in_query; more than 100 query parameters: 400 malformed_query. Viewing as a user (after the 404): 403 impersonation_forbidden. A stored row that is not one of these shapes, or a read failure: 503 { "error": "temporarily unavailable" }. |
POST /admin/v1/me/step-up/options |
{} |
{ step_up_token, factors, webauthn?, expires_at } with Cache-Control: no-store. factors is a JSON array of the offered names (totp, then passkey / security_key with the most recently used kind first); webauthn is present exactly when passkey or security_key is offered and is { challenge, rpId, allowCredentials, userVerification: "preferred", timeout: 120000 }: a 32-byte base64url challenge, the app's RP ID, the person's stored credential ids as { type: "public-key", id } (oldest first, no transports, at most 64; more stored keys answer 503). See WebAuthn challenge. The body may be absent; any member is ignored, the body gates apply. 409 no_second_factor for a caller with no factor, only when the session requirement does not already answer, that is for a session with pwd plus a second factor whose person has no factor left. factors may also name recovery_code (last, and only while the person has an unused code). A person whose only offer would be recovery_code gets 409 no_second_factor, not a token. A session with no binding: 403 step_up_required. It cancels every other open pending row of the person first (an earlier step-up token, an open enrollment), so a person has one live step-up token. |
POST /admin/v1/me/step-up |
{ step_up_token, factor } |
{ "ok": true, expires_at } with Cache-Control: no-store; expires_at is the token's own, never extended. The caps of Locks, caps and timing apply. Answers in this order: 403 step_up_required (token missing, malformed, unknown, expired, used, already verified or another session's); 429 factor_attempt_cap (the token is burned, whatever the factor); 400 missing_field / invalid_field with field: "factor" (never counted); 429 factor_failure_cap (checked before the factor is evaluated); 401 wrong_second_factor (counts on the token and on the account); 503 on a fault. Every guess is counted on the token and the account before the factor is evaluated: a right factor gives the count back, a wrong one and a fault keep it (a fault is never a free guess). |
PUT /admin/v1/me/password |
{ current_password, new_password, step_up_token } |
200 { "ok": true, "other_sessions_ended": true } with Cache-Control: no-store and a fresh cookie for this session (same auth_time, amr and sign-in method). Audited as auth.password_changed. |
POST /admin/v1/me/factors/totp |
{ step_up_token } |
{ enrollment_token, secret, otpauth_uri, expires_at } (secret and otpauth_uri follow the same rule as setup/totp, including the digits / period / algorithm rule). A second app: 409 totp_already_set_up, decided before the step-up token is looked at, so the token is not spent. The enrollment token lives 10 minutes and is bound to the session that asked for it. One secret per token. Cache-Control: no-store. |
POST /admin/v1/me/factors/webauthn/options |
{ kind, step_up_token } |
{ enrollment_token, publicKey, expires_at } with Cache-Control: no-store. publicKey holds the same creation options as setup/webauthn/options, and excludeCredentials lists every passkey and security key the person already has. kind absent: missing_field. Not "passkey" or "security_key": invalid_field. A person who already has 64 keys gets 503. That answer and the kind refusals come before the step-up token is looked at, so the token is not spent. The enrollment token lives 10 minutes and is bound to the session that asked for it. The kind is stored with its challenge. |
POST /admin/v1/me/factors/totp/move |
{ step_up_token } |
Same shape and secret rule as adding an app. A person without an app: 409 totp_not_set_up, decided before the step-up token is looked at (the token is not spent). The old secret keeps working until the new one is confirmed; if it is never confirmed, nothing changes. |
POST /admin/v1/me/factors/totp/confirm |
{ enrollment_token, code } |
{ factor }. code follows the rule of every TOTP code (6 ASCII digits after trimming): absent missing_field, malformed invalid_field with field: "code". A wrong code is 401 wrong_second_factor (counted); 5 wrong codes burn the token (429 factor_attempt_cap), 20 per account per hour pause it (429 factor_failure_cap). The confirm does what the start recorded: an add stores the app (auth.second_factor_added, mail factor_added); a move replaces the secret of the existing app in one transaction, and the answer keeps its id, name and created_at (auth.second_factor_moved, mail app_moved). An app that appeared (add) or vanished (move) meanwhile: 409 totp_already_set_up / 409 totp_not_set_up, not counted. A token already used, expired or of another session: 400 signin_expired. A lock wait that times out: 503. The old secret is refused from the commit on; sessions are not ended. |
POST /admin/v1/me/factors/webauthn |
{ enrollment_token, name, credential } |
{ factor } with Cache-Control: no-store. name and credential as on setup/webauthn; the kind comes from the options call (a kind member here is ignored). A refused registration is 401 wrong_second_factor and keeps the challenge, so the same ceremony can be retried. The caps of Locks, caps and timing apply. The same key twice, or a key of another account: 409 factor_already_registered, counted. A resend after a success, or a token of another purpose or another session: 400 signin_expired, not counted. An authenticator-app enrollment token: a counted 401 wrong_second_factor. A lock wait or a fault: 503. Audited as auth.second_factor_added, with a factor_added mail. No session is ended. |
PATCH /admin/v1/me/factors/{id} |
{ name } |
{ factor } with Cache-Control: no-store. No step-up. The name rule is above; unknown body members are ignored. A malformed id, an unknown id, or another person's: one byte-identical 404 { "error": "not found", "code": "not_found" }. A lock wait or database fault: 503 { "error": "temporarily unavailable" }. Writes the audit row auth.second_factor_renamed (the name is never audited). |
POST /admin/v1/me/factors/{id}/remove |
{ step_up_token } |
{ "ok": true } with Cache-Control: no-store. Answers in this order: the body gates, 404 (malformed, unknown or another person's id, the same body as rename), 409 last_factor_required (the last factor; decided before the step-up is looked at, so it does not burn the token), 403 step_up_required (missing, expired or burned token), then the removal. The count and the delete run in one transaction under the person's row lock, so two removals at once never leave the person with none: one wins, the other gets 409 (or 403 when the winner's cancel already deleted its token). Writes auth.second_factor_removed. |
POST /admin/v1/me/recovery-codes |
{ step_up_token } |
200 { recovery_codes: [10 stringsXXXXX-XXXXX] } with Cache-Control: no-store. The old set is void. The step-up is required; 409 no_second_factor for a person without a real factor (recovery codes do not count); 503 on a database fault. See the paragraph below. |
PUT /admin/v1/me/password answers in this order: the body gates (no query string, JSON object, no duplicate keys), current_password (missing_field / invalid_field), new_password (the same), then the step-up (403 step_up_required before the current password is evaluated, so a stolen cookie cannot guess it; the step-up token is spent before any password hashing), then the lock (429 signin_locked), then the current password (401 invalid_credentials), then the new-password rules (password_too_short, password_too_weak, password_leaked), then reuse of one of the last passwords (password_reused).
Lock. A wrong current password counts toward the same password lock as signin/password and writes auth.password_failed. The guess is counted before it is checked, so two parallel calls cannot both get a free guess: a loser of such a race had its guess counted first. The 10th wrong guess locks and answers 429 with the lock mail. A right current password ends the failure streak and never sends the lock mail, even when a parallel wrong guess just caused the lock (the lock is then lifted again).
Commit. In one transaction the password is replaced (only if it is still the one that was checked, otherwise 403 step_up_required), every other open pending row of the person is cancelled, every device sign-in family is ended and every browser session is ended. The session floor is read after the user row is locked, and the new session of this caller is minted one second above it, so it survives while every other session, including one minted in the same second, is ended. The password_changed mail is sent after the commit. API tokens are kept. If the session cannot be minted after the commit, the answer has no cookie: the password is changed, every session is ended, and the person signs in again. The answer is the same as for a mint refused before the commit: 403 tenant_suspended for a suspended workspace, otherwise 503.
Order difference to the reset. The change cancels the pending rows after the password is replaced; the reset does it in the other order. Both are inside one transaction, so a client cannot see the difference.
How the web app uses it. Account › Security sends the body after a successful step-up and accepts the 200 only with ok: true and other_sessions_ended: true; anything else is treated as not confirmed. Only a 401 invalid_credentials is shown as a wrong current password; any other 401 is an expired session and leads to the sign-in page. 400 password_too_short, password_too_weak, password_reused, password_leaked, missing_field and invalid_field (by field) are shown under the field; 429 signin_locked, 403 step_up_required, 403 mfa_session_required and 409 no_second_factor have their own messages. A 404 carrying the gateway's own error body (the account is no longer on password_mfa) closes the dialog and re-reads the page; a 404 from anything else, such as a proxy, is shown as a plain refusal that keeps the dialog and the typed values and does not re-read. A 5xx, a network error or a malformed 200 says the change is unconfirmed and re-reads the page. Each retry asks for a new step-up.
POST /admin/v1/me/recovery-codes. Answers come in this order: the route gates above (404, 409 while viewing as user, 403 mfa_session_required), 409 no_second_factor for a person who has no authenticator app, passkey or security key (recovery codes do not count as a factor), the step-up (403 step_up_required, the token is spent here), then the new set. Ten codes are made, each 50 random bits written as XXXXX-XXXXX; the previous set is void in the same database transaction, and one audit row user.recovery_codes_regenerated (no code, no hash) is written in it. A fault before the commit answers 503 and the old set stays valid. After the commit the "new recovery codes" notice mail is sent best effort (a failed mail does not change the answer), then the 200 is returned. The codes are shown once; they are not stored in readable form. At rest each code is kept only as a look-up Argon2id hash (a fixed salt per code, 4 MiB, 1 pass, 1 lane; see the password-hashing note in the internal docs): a code has 50 random bits, so the cost is set for a quick look-up, not for guessing a password. A check always does the same work whatever the person has left or the code looks like, so timing does not tell which part was wrong. Using a code at step-up writes no audit row.
New recovery codes in the web app. Account › Security asks for a confirmation first (the old unused codes stop working at once), then a step-up, then sends { step_up_token } once. Each issued code is 10 Crockford base32 characters (no I, L, O, U), optionally split by one hyphen and without spaces, so it is accepted as a recovery_code factor; the 10 codes are distinct (compared without the hyphen and ignoring case). This holds for POST /admin/v1/me/recovery-codes and for the recovery_codes of POST /admin/auth/setup/finish. The web app refuses any other answer as malformed: it shows no codes, says the outcome is unconfirmed and re-reads the page. The codes are shown once in a dialog, as XXXXX-XXXXX, with Copy and Download (myra-recovery-codes.txt); the dialog closes only after the person ticks that the codes are saved, or confirms to close without saving. They are never logged and never put in the URL, the page title or browser storage. 403 mfa_session_required, 403 step_up_required and 409 not available while viewing as user have their own messages; a 404 carrying the gateway's own error body re-reads the page, any other 404 is a plain failure. A 5xx, a network error or a timeout says the result is unconfirmed (the old codes may no longer work), re-reads the page, and a retry asks for a new step-up.
Renaming and removing a factor (MAP-4100). Removing a factor cancels every pending sign-in and setup of that person, including those open on other browsers (one delete by user_id, served by idx_apd_user (user_id), migration 0926_map3890_pci_auth_schema.sql line 102). Recovery codes are not touched. Sessions that signed in with the removed factor are not ended. After the commit the person gets the security e-mail; it names the factor only if its name passes the name rule. Rename needs no step-up and takes the user row in share mode, so it never blocks a removal for long.
Adding and moving the authenticator app (MAP-4099). Both routes check the app first and the step-up second, so a refusal never spends the step-up token. The move changes the secret of the one app row in a transaction that holds the person's user row; a sign-in or step-up with an old-app code that is in flight at that moment is refused (its check loses and re-reads the new secret), and there is exactly one app row at every instant. A confirm and an admin reset of the factors, or a removal, serialise on the same user row: whichever commits first wins, and the other answers 400 signin_expired and stores nothing. If the connection is lost while the commit runs, the app may be stored or moved; the factor list shows which.
Adding a passkey or security key (MAP-4107). The options call checks everything it can refuse before the step-up: the kind, the session, the person and the stored keys (the excludeCredentials list and the bound of 64 keys per person). These checks only read and write nothing, so a refused call spends no step-up token. Options built for a caller who then fails the step-up are thrown away. The register call answers in this order:
- the body (
enrollment_token, thenname, thencredential, each absentmissing_fieldor malformedinvalid_field; nothing is read or counted before this); - the token (a token burned by 5 wrong factors
429 factor_attempt_cap; another purpose, another session, unknown or expired400 signin_expired); - the account's factor-failure cap (
429 factor_failure_capwithRetry-After, even for a valid key); - the stored challenge;
- the registration check;
- the insert.
Every registration that reaches the check is counted first: once on the token (at most 5) and once on the account (at most 20 per hour). Parallel registrations on one token therefore cannot go past either cap. A success gives both counts back. A refusal, a 409 and a fault after the count keep it. The insert runs in one transaction that first locks the person's user row, then the enrollment row, then the factor rows. Two adds of one person therefore run one after the other, and at most 64 keys are ever stored: at the bound the second add answers 503. An admin reset of the factors or a factor removal serialises on the same user row. Whichever commits first wins. A reset that runs first leaves the add 400 signin_expired with nothing stored; an add that commits first is then deleted by the reset. If the connection is lost while the commit runs, the key may be stored; the factor list shows it.
Renaming and removing a factor in the web app. Only a 404 carrying the gateway's own error body says the factor (or this account's password_mfa sign-in) is gone: the factor list shows that and re-reads the page. A 404 from anything else, such as a proxy, is a plain failure (the rename field stays open; a removal says the factor could not be removed) and does not re-read. An expired session leads to the sign-in page and shows no message.
Where the setup screens depart from the design, on purpose: the e-mail code step has no design frame and reuses the look of the sign-in code step; "Use another account" replaces "Sign out" (nobody is signed in yet); the security key is shown disabled in the no-WebAuthn view; the design text names no organisation and has no admin variants; sso_required on a setup step is handled defensively only (the person leaves the setup and sees the single-sign-on notice).
Adding a factor is step-up-gated, so a stolen cookie cannot plant its own factor and then pass every other step-up. Removal is a POST because some proxies drop the body of a DELETE. The factor used for the step-up may be removed only if another factor remains. The enrollment_token follows the pending-token answers.
Password reset
All routes are public.
| Route | Body | Answer |
|---|---|---|
POST /admin/auth/password/forgot |
{ email, break_glass? } |
Always the generic 200 { "message": "If that email is registered and can reset its password, a link has been sent." } with Cache-Control: no-store: unknown, disabled, deleted, email_code person, a fixed-code account, a password_mfa person without a password, or over the cap of 10 per address per code window. The link is mailed only to a password_mfa person who has a password (and is not a fixed-code account); a person without a password sets one up through the email code (First setup), on every domain. No mail beyond the cap; over the cap the answer and the cookie are the same. The cap is held per gateway node, like the /otp/request cap. There is no per-client-IP cap, for the same reason as on /otp/request (the client address comes from X-Forwarded-For, which a caller can set). The email shape is checked as on /otp/request (email required or invalid_email, the same bodies). Sets __Host-aig_login_nonce (Max-Age 1800, the link lifetime) like /otp/request, so the link binds to the browser. break_glass must be a JSON boolean: any other value, including null, is 400 { "code": "invalid_request", "field": "break_glass" } (/otp/request keeps reading null as absent); on an SSO-enforced domain see Single sign-on enforcement. |
POST /admin/auth/password/reset |
{ token, confirm? } |
Consumes the single-use link (valid 30 minutes; a newer request supersedes it) and answers 200 { pending_token, purpose: "signin", next: "second_factor", factors, webauthn?, expires_at } with Cache-Control: no-store. factors is what the account can use; webauthn is present only when a passkey or security key is offered. A person with no factor yet gets 200 { pending_token, purpose: "setup", next: "create_password", expires_at }: the setup flow runs from setup/password, never a session without a factor. The new pending token replaces any open one of the person. |
POST /admin/auth/password/reset/complete |
{ pending_token, password, remember_me? } |
A session plus "other_sessions_ended": true. Ends every other session, cancels the open pending rows and ends the password lock. Single sign-on enforcement is re-checked (403 sso_required). |
Mail cap. At most 5 password-reset mails per hour per address are sent, counted across the whole cluster (a fixed hourly window, so a burst straddling the window boundary can briefly reach up to twice the cap). Above it the route gives its normal success answer, with the same status, body and headers: no mail is sent and no code or link is stored. A per-node emergency brake of 120 mails per minute across all code-mail routes does the same and writes an error-log line for operators. A database fault while counting is the route's usual transient 503. Limits (accepted side effects). A stranger who keeps sending 5 requests per hour for a victim's address can keep the victim from getting a new reset link for that hour (an earlier, still-valid link keeps working); and the per-node emergency brake (120 mails per minute) can be used up by requests for about two dozen known addresses, after which no code or reset mails go out from that node for the rest of the minute.
A token that is absent, malformed, unknown, expired, used, superseded or voided by an email change gives one 400 { "error": "invalid_or_expired", "code": "invalid_or_expired" }, the magic-link rule. password/reset has no request ceiling: the token carries 256 random bits, so guessing it is infeasible, and an unknown token costs one indexed lookup. In another browser, 428 link_confirm_required (with the account's email) follows, then confirm: true; a confirm that is not a boolean (also null) is 400 { "code": "invalid_field", "field": "confirm" } before anything is read. A malformed or foreign nonce cookie is 403 link_other_browser, also with confirm: true. The binding works exactly as for the magic link; neither refusal consumes the link.
A link whose account no longer qualifies (disabled, deleted, the organisation switched to email_code, the password removed, or a fixed-code account) gives the same 400 invalid_or_expired, and the link is spent by that attempt: re-enabling the account within the 30 minutes does not bring it back. Request a new link. A fault while the account is checked (a 503) spends nothing. A factor set that cannot be read consistently (stored factors but nothing on offer, or nothing but recovery_code on offer, or a passkey offered without its options) is 503, never "no factor". A 503 after the link was consumed (the factor challenge or the pending token could not be created) means the link is spent: request a new one; a replay of it is invalid_or_expired. password/reset does not re-check single sign-on (it issues no session); password/reset/complete does.
Timing. For every address that passes the body checks, the cap and the single-sign-on gate, password/forgot sets the same cookie and runs the same reads in the same order: the account lookup, the sign-in policy reads, the password check and the brand read. An address with no live account (unknown, disabled, deleted, or a break-glass non-member, also one with an account in another organisation) runs them against an id that has no row; nothing is written for it. The remaining differences are stated: the eligible person's link row is written and the token is minted and mailed on a timer after the answer; the cap is per gateway node; while admin_mfa_enforced is on, a sys:admin holder's policy read stops after the role read (as on /otp/request); when the allowlist names organisations instead of *, a member of a listed organisation makes one more read (its stored policy) than an address without an account; and with *, an account that belongs to no organisation makes that read one fewer. Any fault in these reads is 503 { "error": "temporarily unavailable" } for every address.
An address change voids open links. When an account's address actually changes, by an administrator (PATCH /admin/v1/users/{id}) or by SCIM, the old address's open reset links, sign-in codes and magic links are deleted in the same transaction as the change; a link mailed to the old address is then invalid_or_expired. The old address is matched as stored and in lower case, so a change of letter case only also voids the links of the new spelling (request a new link). A failure to delete them rolls the whole change back. A soft delete deletes nothing: the link's address then belongs to no live account, so the link no longer works either. A reset link is a link only: it carries no code, and a code typed at /otp/verify never matches it.
What the reset page does. The mail links to /reset-password#token=<43 characters>. The contract does not name this URL; the web app defines it here, so the mail templates must use exactly this form. The token rides the URL fragment, so it never reaches a server log or a Referer; the app reads it once at start-up and removes it from the address bar before anything renders. A fragment that does not hold exactly one token of 1 to 128 base64url characters is dropped and shown as a dead link; nothing is sent. A signed-in browser drops the token and sends no request. The token is posted once to POST /admin/auth/password/reset. The answers are read fail-closed: a 200 pending answer with next: "second_factor" opens the same second-factor step as sign-in (the authenticator code, a recovery code, a passkey or security key); 400 invalid_or_expired, and any other 400 (re-posting the same token would fail the same way), shows "This link no longer works" with Request a new link, which opens the sign-in page on the forgot form; 428 link_confirm_required asks for a confirmation and then posts confirm: true; 403 link_other_browser and 404 have their own views; any other failure of the reset request that is not a 400 (503, a network failure, 500, 409, a 403 other than link_other_browser, and so on) shows the error banner and offers Try again; a 200 with any other body is a failed request and no factor step is shown. The factor goes to POST /admin/auth/signin/finish; the reset answer must be { pending_token, purpose: "signin", next: "new_password", expires_at } and a body with a user is refused. The new password is checked in the browser first (12 characters or more, a letter and a digit; a failing password is never sent) and then posted to POST /admin/auth/password/reset/complete. The 200 is accepted only with a user object and other_sessions_ended: true; an absent or false value is a failed request, not "probably ended". The server codes password_too_short, password_too_weak, password_reused and password_leaked are shown at the field; a 403 sso_required shows an in-page single-sign-on view with Back to sign-in and does not navigate; signin_expired, an error on the pending_token field, or a malformed 200 makes the page probe for a session: if one is found, the user is signed in; if the probe answers 401, the page says "This reset has expired. Request a new link."; if the outcome is unknown, it shows the "could not confirm" view. A signed-in page shows "All set" with Go to workspace, and the other sessions were ended. When the second factor was a recovery code and the answer of signin/finish carried recovery_codes_left: 0, the "All set" view also shows the last-recovery-code warning of the sign-in notice, with an action to the security settings (/profile/security) next to Go to workspace. The value is read by the same rule as on sign-in: absent means no warning; 0 means the warning; any other value (a negative number, a string, null, 3) makes the whole answer malformed.
Where the page departs from the design, on purpose: (1) the design puts "Set a new password" before the second factor; the contract proves the factor first, so the page follows the contract. (2) The reset URL is defined by the web app, as above. (3) The page has no "stay signed in" choice and sends no remember_me, so the session is the short one (8 hours). (4) A person with no factor yet gets setup with next: "create_password"; the page opens the setup flow from the password step, with the reset entry text, and starts no session until the setup finishes. (5) The hint "Not one of your last 4 passwords" is checked by the server only (password_reused); the browser cannot check it.
Admin actions
| Route | Body | Answer |
|---|---|---|
GET /admin/v1/tenants/{id}/signin-policy |
none | { signin_policy, enforced } |
PUT /admin/v1/tenants/{id}/signin-policy |
{ signin_policy, enforced?, step_up_token? } |
200 { signin_policy, enforced }. Audited as tenant.signin_policy_changed. |
POST /admin/v1/users/{id}/second-factor/reset |
{ step_up_token? } |
200 { "ok": true }. In one database transaction with its audit row it removes all second factors, voids recovery codes, cancels open pending sign-in rows, ends browser sessions, device logins and MCP OAuth grants, and unbinds push device tokens. It keeps API tokens, the password and the sign-in attempt counters. Then it sends the admin-reset security mail. Audited as user.second_factor_reset. |
POST /admin/v1/users/{id}/password-reset-link |
{ step_up_token? } |
200 { "ok": true }. In one database transaction with its audit row it replaces any open reset link of the member and stores a new one (valid 30 minutes), then sends the reset mail worded "Your admin sent you this link". The link needs the member's confirmation on opening (428 link_confirm_required), because it was not requested in the member's own browser. The admin gets no cookie and never sees the link. Audited as user.password_reset_link_sent. Refusals: 409 no_password_signin (the target does not use password sign-in, has no password or is disabled) and 429 otp_request_cap (shares the per-address cap of the forgot-password request). |
POST /admin/v1/users/{id}/signin-unlock |
{ step_up_token? } |
200 { "ok": true }, Cache-Control: no-store. Ends the target's password sign-in lock. 409 not_locked when there is no live lock. Audited as user.signin_unlocked; no mail is sent. |
Sign-in policy. It needs the SSO_MANAGE permission and access to the tenant, as sso-enforcement does. Both routes answer 404, identical to an unknown route ({ "error": "not found", "code": "route_not_found" }), while password_mfa_enabled is off and for an organisation that is not on password_mfa_tenant_allowlist (decision of 2026-11-04: the same answer as the flag being off). Order, both routes: the 401 of the session, then 404 (flag off), then 404 { "error": "not found" } for an unknown or deleted organisation or one the caller cannot reach (another organisation's id; the allowlist is not read for it), then 404 (not on the allowlist), then 403 permission_required (no SSO_MANAGE). So the flag and the allowlist answers are the same for every caller who can reach the organisation, and a caller cannot learn whether another organisation is on the allowlist. A foreign organisation's 404 and a not-allowlisted 404 differ in body; this is accepted, since the flag is platform-wide and the allowlist is read only for an organisation the caller can reach. A malformed or unreadable flag or allowlist is 503 { "error": "temporarily unavailable" }. Every answer after these carries Cache-Control: no-store.
GET refuses any query argument (400 pii_in_query) and answers exactly { "signin_policy": "email_code" | "password_mfa", "enforced": true | false }; a stored value outside these is 503 { "error": "temporarily unavailable" }, never email_code. PUT then checks, in this order: any query argument 400 pii_in_query, 400 unsupported_content_type, 400 malformed_body (not a JSON object; a repeated key is 400 duplicate_key), a key other than signin_policy, enforced and step_up_token 400 { "code": "invalid_request" } (the key is not echoed), signin_policy absent or null (400 invalid_request, field: "signin_policy", "signin_policy is required") or not exactly one of the two values, with no case folding or trimming (400 invalid_request, field: "signin_policy", "signin_policy must be email_code or password_mfa"), enforced present and not a boolean, null included (400 invalid_request, field: "enforced"), enforced sent by a caller who is not a platform admin, true or false (403 { "code": "forbidden" }); then the step-up; then the change. enforced absent keeps the stored flag.
The step-up rule applies, and only a downgrade (to email_code from a stored option that is not a valid email_code) needs it; an upgrade, a no-op save and a change of enforced never do. 403 mfa_session_required (rule 1) comes first. A session with an external amr changes the option, a downgrade included, without a token, and the field is ignored (E82). A caller whose own resolved policy is email_code because of another organisation or no organisation is not asked for one either. A caller whose policy is email_code from this organisation's own row, and every caller on email_code while viewing as another user (the viewer's own session is judged), is treated as needing one for a downgrade. A caller on password_mfa sends a verified step_up_token; a presented token is consumed before the change, also when the change is then refused; an unusable one is 403 step_up_required (409 no_second_factor for a caller with no factor). A downgrade without a token is 403 step_up_required, also for a caller with no factor. The downgrade, a malformed stored flag (503) and 409 policy_enforced_by_myra (an organisation admin while Myra enforces the option; a platform admin is not refused and may change enforced) are decided when the change is written, under the organisation's row lock. The change and its audit row tenant.signin_policy_changed (before / after = { signin_policy, enforced }; a stored value that was malformed is recorded as "malformed") are one write: a refused or failed change writes neither. A save that changes nothing is still written and audited. Changing the option signs nobody out, in either direction.
Member notice on the switch. When a PUT changes the stored option from email_code (or from an unreadable stored value) to password_mfa, every live member of the organisation who was created before the switch gets the mail "Your sign-in is changing" ("Deine Anmeldung ändert sich" in German). It is sent once per change: a repeated PUT of the same option, a save of enforced alone and a downgrade send nothing, and two PUTs at the same moment send one set (the second finds the option already password_mfa). A later switch back to password_mfa starts a new set. Not mailed: disabled or deleted members, members created in or after the second of the switch (E120), members whose address requires single sign-on, and members to whom the admin sign-in rule already applies. The mails go out after the PUT has answered, in pages of 100 members, each page in its own background timer. Before each page the switch is checked again: the notice stops when the flag is off, when the option is email_code again or unreadable, or when a newer switch (or a switch back) was saved; a repeated save of password_mfa or a change of enforced alone does not stop it. It is best effort: a failure is logged (the line holds the tenant, the page and the counts of sent, skipped and failed mails, never an address), it never changes the answer of the PUT, and a lost chain is not resumed (E119).
Invitation wording. A new invitation, and a resent one, into an organisation whose effective option is password_mfa names its steps (enter your email and request a code, enter the 6-digit code, create a password, set up a second factor and save the recovery codes) instead of "Continue with Email code". An organisation on email_code, one with the flag off, and an invitee whose address requires single sign-on keep the old text (E123). If the option cannot be read, no invitation is sent and one error line is logged.
Losing the role mid-flow (E38). Every request checks the permission again, as on every admin route: an admin whose role was removed after the card was loaded gets 403 permission_required on the next request, and nothing is written. Accepted residual: a role removed between one request's permission check and the moment its change is written does not stop that one request; the next one is refused.
How the web app reads it. The Sign-in protection card treats a 404 from GET as "not available" and shows nothing. Any other failure, and a 200 body that is not an object, whose signin_policy is not one of the two values or whose enforced is not a boolean, is a load error with Retry, never email_code. Unknown extra keys are ignored. For the idle-timeout hint the card reads session_idle_timeout_s from GET /admin/v1/tenants/{id}: absent or null means no idle timeout, a positive integer is seconds, and anything else (a string, 0, a negative or fractional number) is a load error, never "no idle timeout". How the web app writes it. Saving asks for confirmation, then calls PUT /admin/v1/tenants/{id}/signin-policy with { "signin_policy": ... }. enforced is sent only by a platform admin. Only a downgrade (password_mfa to email_code) asks for a step-up first: a verified step-up adds step_up_token to the body; when the step-up answers not required, or the session cannot take part in one, the request is sent without a token and the server decides; cancelling the step-up sends nothing. A 200 body that does not parse as above is a save error, not a success: the draft is kept and the card shows the generic failure. Known error codes (invalid_request, malformed_body, forbidden, step_up_required, mfa_session_required, policy_enforced_by_myra, no_second_factor, and a 404) get their own sentence, and only on the status listed above; anything else is generic. 409 policy_enforced_by_myra also re-reads the policy and shows the server's current state instead of a retry. A 403 step_up_required on a save the card did not see as a downgrade means the stored option changed since the card was loaded: the card says so and re-reads the policy instead of offering a retry.
Scope of the three user routes. second-factor/reset, password-reset-link and signin-unlock need the same permission and tenant access as POST /admin/v1/users/{id}/disable (USERS_MANAGE). One scope rule applies to all three: a target outside the caller's tenant, or a sys:admin holder targeted by anyone who is not a platform admin, answers 404. Order for second-factor/reset: 401 session, flags (404 identical to an unknown route), 403 permission_required, audited 404 (target outside scope, unknown, deleted, or a Myra admin targeted by anyone who is not a platform admin), 403 cannot_reset_own_account, audited 404 (the target's organisation is not on password_mfa), 403 target_outranks_caller (an organisation admin on a peer organisation admin), 400 body, 403 step_up_required, then the write. So a malformed body is 400 before any step-up answer, and your own account with a malformed body is 403 cannot_reset_own_account, not 400. Order for password-reset-link: 401 session, flags (404), 403 permission_required, 404 scope, 403 target_outranks_caller, 400 body, 403 step_up_required, 409 no_password_signin, 429 otp_request_cap, then the write. There is no own-account refusal: an admin may send themselves a link. A malformed body is 400 before any step-up answer. Order for signin-unlock: 401 session, flags (404), 403 permission_required, 404 scope, 403 target_outranks_caller, 400 body, 503 (the lock state cannot be read; no step-up token consumed), 409 not_locked, 403 step_up_required, then the write. There is no own-account refusal and no policy 404. The 429 of the reset link shares its counter with the forgot-password request for the same address, so repeated forgot requests can deny the admin link for one window on that node; the cap is per node and can be bypassed across nodes, as for forgot. An SSO-enforced member still receives the link; refusing it belongs to MAP-4093 (sso_required on reset/complete).
Sign-in unlock. It ends the password lock of the member (the lock set by too many wrong passwords) together with its wrong-password count, and nothing else: the second-factor counter, sessions, factors, recovery codes, pending sign-ins, reset links and the password are untouched, and no mail is sent. The next wrong password starts a new count at 1. The 409 not_locked is decided before step-up, so a refused request consumes no step-up token, and it is visible only after the scope and rank checks. A lock that expires between the check and the write still answers 200; the audit row then says lock_ended: false. A damaged lock record answers 503 and needs a database fix. The audit row user.signin_unlocked carries after.lock_ended and, when a live lock was ended, before.locked_until. An admin may unlock their own account. GET /admin/v1/users/{id} shows the lock as signin_locked_until.
Second-factor reset. It refuses your own account with 403 cannot_reset_own_account. An organisation admin on a Myra admin or another organisation's user gets 404. The member's next sign-in is password, then an email code, then factor setup (First setup).
What the reset does exactly. The body is empty or an object whose only key is step_up_token; any other key is 400 invalid_request and is not echoed. Self means the user in the path or the person behind the session (under impersonation the signed-in actor, so an impersonating admin cannot reset their own account through the viewed user either). A disabled target is reset; a deleted one is 404. If the target's role or organisation changed between the permission check and the write, nothing is written and the answer is the audited 404. The reset also cancels the member's open pending rows (E37: a token from before the reset is 400 signin_expired), ends device and MCP OAuth families at once (not after the access-token lifetime) and unbinds push tokens. Mailed password reset links stay valid and the sign-in attempt counters are not touched. The audit row carries counts only, never a factor name, id or token. Two resets at the same moment both succeed and are both audited. The mail is best effort and sent after the commit (E83: the next sign-in is password, then an email code, then factor setup).
Concurrent enrolment (E101). The reset reads the user row with a shared lock, so a role or organisation move and a recovery-code use wait for it, and a factor being enrolled at the same moment either commits first and is then removed, or fails with 400 signin_expired; it is never left behind and never a 5xx. The later session-floor stamp upgrades the lock, so two resets at the same moment can deadlock on the upgrade; the transaction is retried and a reset is idempotent. Accepted residual, identical to the disable path: a device token refresh running at the same moment as the reset can lose with a database deadlock (1213) and answers 503; the refresh then succeeds or is refused on retry.
Password-reset link. It shares the forgot-password cap of the address; over it, 429 { "code": "otp_request_cap" }. A target that is not on password_mfa, has no password or is disabled gets 409 no_password_signin and nothing is sent.
The backend writes exactly the three audit action names listed above; see Audit log.
How the web app reads it. The Members list first sends {}. Only when the server answers 403 step_up_required does it ask for the admin's own step-up and send the action once more with { "step_up_token": … }; it never sends a third time. So an admin whose sign-in needs no step-up (for example single sign-on) is never asked for one. If the step-up cannot be done from this session, the action is not sent again and the admin is told to sign in with a second factor. The list treats only { "ok": true } as success. Any other 200 body is an error, never success: the list is reloaded and the admin is told to check the member's state before trying again. A 503 and every other 4xx answer (400, 401, 403, 410, 422, 429, and the coded 409s no_second_factor and no_password_signin) is a definite refusal: the admin sees a specific message, nothing was changed, and the list is not reloaded (a 401 goes to sign-in instead). A 404, an unrecognised 409 and 409 not_locked (someone else already unlocked) also reload the list, because the member may have changed. A 500, 502, 504 or any other 5xx, a lost connection and a timeout are shown as "could not confirm", and the list is reloaded.
An admin who loses the role mid-flow gets 403, as on every admin route.
Security emails
Ten notice emails tell a person that their sign-in security changed: password changed, password reset by email link, second factor added, second factor removed, new recovery codes created, authenticator app moved to a new device, second factors reset by an administrator, sign-in locked after too many incorrect passwords, the organisation switching to password and second factor ("Your sign-in is changing", see Member notice on the switch), and a single sign-on identity linked to the account (sso_identity_linked, sent when an identity is first linked to an existing account, see First sign-in; it is not rate-capped, and its delivery is counted by the aig_security_mail_total metric, see Troubleshooting). Each exists in English and German. The "new recovery codes" mail is sent by POST /admin/v1/me/recovery-codes; setup/password sends the "password reset by email link" mail after a reset commit (a first password sends none); PUT /admin/v1/me/password sends the "password changed" mail after a commit (never after a refusal, a lock or a fault); POST /admin/v1/me/factors/totp/confirm sends factor_added (an add) or app_moved (a move) after the commit; POST /admin/v1/me/factors/webauthn sends factor_added (with the kind and the name) after the commit; the other mails are not sent yet (the sender and the texts are in place, and the routes that trigger them follow). Internally the sender accepts exactly these ten kinds of mail (password_changed, password_reset, factor_added, factor_removed, recovery_codes_regenerated, app_moved, admin_reset, sign_in_locked, signin_policy_switched, sso_identity_linked).
What a mail contains. It names the account's product (the organisation's own brand name, or "Myra AI Workspace" when it has none), says what happened and when (a date and time in UTC), and has a "Wasn't you?" part with what to do. The two password mails also say that all other sessions were ended. The two factor mails name the kind of factor (authenticator app, passkey or security key; a generic wording when the kind is not known) and, when one was given, the name the factor carries. That name is chosen by whoever added the factor, so it is cut to a bounded length, stripped of control characters and escaped in the HTML part. The recovery-codes mail says that new recovery codes were created and that the earlier ones no longer work; it never contains a code. The app mail says that the authenticator app was moved to a new device and that the app on the old device no longer works; it names no device. The admin-reset mail says that an administrator reset the second factors and that the next sign-in asks for the password, a code sent by email and the set-up of a new second factor; it does not say that the password was reset or that a new factor already exists. The lock mail says that sign-in was locked for a while after too many incorrect passwords; it states no expiry, no number of attempts, no permanent lock and no way to unlock it from the mail. These four mails take no details from the caller: a factor object, a count, a lock id, a code, a token or a link handed to the sender is ignored, so only the product name and the time of the action reach the text. The mails carry no token, no code, no secret and no address of the reader.
Where the button goes. The password mails link to the sign-in page (/login), where the person chooses "Forgot password?" ("Passwort vergessen?" in German); the forgot form has no address of its own. The factor mails, the recovery-codes mail and the app mail link to the security settings (/profile/security), described as "Account > Security" ("Konto > Sicherheit"). The admin-reset mail and the lock mail link to the sign-in page (/login) with the button "Open sign-in" ("Anmeldung öffnen"); their "Wasn't you?" part is the same Forgot-password text as in the password mails. Each mail has exactly one button. The button link is a fixed path on the application's own address; the other links are fixed constants; nothing in a mail's link comes from a request.
Language. The mail uses the person's own language; without one, the organisation's default; without that, English.
Best effort. A security mail never changes the outcome of the action it reports. It is sent outside the request, so it does not delay the answer. If the person has no usable address, the storage lookup fails, or the mail cannot be sent, the action stays done and only a log line is written. The log line holds the user id and the kind of mail and, on a storage or timer failure, the error text, never the address or a factor name. A call without a valid user id or with an unknown kind of mail sends nothing and logs an error that repeats neither value. One call is one mail attempt, with no retry; sending the lock mail only once per lock is the job of the sign-in code that calls the sender, not of the sender.
Inputs and what is rejected
Every value in this section is untrusted: the three tokens (body only, shape-checked, looked up by hash, bound to a step), email, passwords, the factor object (CBOR and clientDataJSON are size-bounded), code, kind, name, credential, confirm, remember_me, signin_policy, enforced, the reset token and break_glass. Absent and malformed values are distinct (missing_field and invalid_field), except where this section states a shared restrictive answer on purpose: the reset token (invalid_or_expired, as for the magic link), the step_up_token (step_up_required), remember_me (the 8-hour default) and signin_policy / enforced (400 invalid_request, as on sso-enforcement). A malformed value never degrades to the permissive outcome.
In the web app. Enrolment start answers must carry an enrollment_token of exactly 43 base64url characters ([A-Za-z0-9_-]); absent, non-string, wrong-length or illegal-character tokens are malformed, never usable enrolments. The client deliberately leaves canonical last-character validation to the server. /me/factors/totp/confirm must return a factor of kind app; /me/factors/webauthn must return the requested kind. A mismatch never reports success. After a failed app-code or recovery-code step-up verify, Retry clears and focuses the code field and sends nothing; only submitting a fresh code verifies again with the existing token.
The app treats the answers it gets back, and the output of the browser's WebAuthn call, as untrusted too. The answers of setup/email-code and setup/password are accepted only as a purpose: setup, next: "choose_factor" body carrying the same pending token; anything else is shown as a failed request. A step-up answer is accepted only with a 43-character base64url step_up_token, a factors list (unknown factor names are ignored; a non-string entry rejects the whole answer), a positive expires_at and, when present, well-formed passkey options (a canonical base64url challenge, a string rpId, a required allowCredentials list of at most 64 entries, a known userVerification and a required timeout). A request that gets no answer within 30 seconds is shown as a failure with Retry; when the first options request takes longer than 400 ms the dialog opens in a loading view with Cancel. A missing or null webauthn object means no passkey button. A malformed one is shown as a failure, never as a passkey that can be tried. The step-up dialog uses the same shared WebAuthn check as sign-in: inside the Android app without webauthn: true the browser counts as "cannot do WebAuthn", the passkey button is disabled with a notice that this device cannot use passkeys here, and the app code and recovery code stay usable. The sign-in answer is read the same way: a passkey or security-key factor without webauthn, or with a malformed one, rejects the whole answer, and a passkey is never offered as something that can be tried on bad options. After a rejection or a security failure the passkey is not offered again in this sign-in, and Back to sign-in gives a fresh challenge. A verify answer counts as a confirmed step-up only with ok: true and a positive expires_at. Anything else is shown as a failure and never returned to the calling action as confirmed. The passkey set-up options of POST /admin/v1/me/factors/webauthn/options (publicKey) are checked the same way: a canonical base64url challenge, an rp.name, a user.id of 1 to 64 bytes, 1 to 16 pubKeyCredParams and only known values for attestation and authenticatorSelection; anything else counts as a malformed answer. The creation options of setup/webauthn/options are checked by the same rule as the profile options, and the setup/webauthn answer must carry a factor whose kind is the one asked for; anything else is a malformed answer and no credential is created or sent on it. The TOTP secret of setup/totp (and of the /me enrolment) must be base32 of 16 to 128 characters with an otpauth://totp/ URI of at most 2048 printable ASCII characters carrying the same secret once, and no digits, period or algorithm other than 6, 30 and SHA1 (and none of them twice); the setup/finish answer must carry a user object and ten well-formed recovery codes. A mismatch is a malformed answer: no QR code, no key and no codes are shown.
CBOR in the factor object. The gateway reads only a strict subset of CBOR: one item, no trailing bytes, at most 16 KiB, nested at most 8 levels and at most 256 items. Integers must be within ±(2^53−1) and in their shortest encoding. Strings, arrays and maps have a definite length, text is valid UTF-8, and map keys are integers or text, each used once (the order of keys is not checked). Tags, floats, simple values such as null and true, and indefinite lengths are refused. Whatever the reason, the answer is the same 400 invalid_field; the reason is not returned.
COSE public-key utility (ES256 and RS256). The standalone key reader accepts exactly one encoded CBOR map under the bounds above. EC2/ES256 requires exactly the numeric labels {1: 2, 3: -7, -1: 1, -2: x, -3: y}, with x and y each a 32-byte CBOR byte string on P-256; compressed (boolean) coordinates, text in place of bytes, points not on P-256 and coordinates of p or more (outside the P-256 field) are refused. RSA/RS256 requires exactly {1: 3, 3: -257, -1: n, -2: e}, with nonempty, minimally encoded unsigned byte strings (no leading zero), an odd modulus of 2048–8192 actual bits, and an odd exponent 3–2^32−1 in 1–4 bytes. These RSA strength/resource limits are a deliberate supported subset. No optional metadata, private-key labels, numeric-looking text labels, missing algorithm, alternative curve, unknown label or other algorithm/key-type combination is accepted. Native import must produce a public-only key whose public parameters match the supplied bytes exactly. The utility returns that native key or nil plus a bounded constant refusal code (decoder refusals are prefixed cbor_); absent and malformed inputs both refuse without defaults, never silently select an algorithm or bypass verification. This is only the key-conversion utility: it does not add WebAuthn routes or assertion, origin, challenge, RP-ID or counter verification, and does not itself map errors to HTTP.
WebAuthn assertion check (passkey and security key). The gateway checks a WebAuthn sign-in proof (an assertion, WebAuthn Level 3 §7.2) in two steps. POST /admin/v1/me/step-up with a webauthn factor uses it through the second-factor registry; POST /admin/auth/signin/finish will use the same provider when it ships (MAP-4085). The first step reads the credential object of the webauthn factor above and refuses anything malformed before any cryptography runs. The second step compares the proof with what the server expects. The routes answer each outcome by its class: malformed is 400 invalid_field on factor and does not count as a failed attempt; refused is 401 wrong_second_factor and counts; a fault on the server side (a stored key or expectation that is not valid, or a deployment without a usable app origin) is 503 and is never an accept.
Accepted shape (malformed otherwise). credential is a JSON object with no members other than id, rawId, type, response, authenticatorAttachment and clientExtensionResults. type is exactly "public-key". id and rawId are equal and are canonical unpadded base64url (only A-Z a-z 0-9 - _, no padding, no whitespace, the one spelling of the value; a spelling with unused bits set is refused) of 1 to 1023 bytes. response is an object with no members other than clientDataJSON (1 to 2048 bytes), authenticatorData (37 to 1024 bytes), signature (1 to 1024 bytes) and userHandle (1 to 64 bytes), all canonical base64url; the size limits are checked on the encoded text before anything is decoded. userHandle absent, null or "" means no handle. "" is accepted as absent on purpose: the password step has already fixed the person, and refusing it would lock out older authenticators. A handle of any other type, or one that is not canonical base64url, is malformed and never read as "no handle". The decoded clientDataJSON is valid UTF-8 without a byte-order mark and one JSON object (no NaN, Infinity or hex numbers). type, challenge and origin are required non-empty strings of at most 1024 bytes, and challenge is canonical base64url of 16 to 64 bytes. crossOrigin may be absent (meaning false) or a boolean; null or any other type is malformed. topOrigin may be absent or a string. tokenBinding may be absent or an object whose status is present, supported or not-supported. Other members are ignored, as the specification requires. When a member appears twice, the last value counts: the authenticator signs the exact bytes the browser built, and those same bytes are checked. The decoded authenticatorData is the 32-byte RP ID hash, one flags byte and a 4-byte unsigned big-endian counter. The attested-credential flag (AT) is refused (an assertion never carries one). Backed-up (BS) without backup-eligible (BE) is refused. With the extensions flag (ED) the rest must be exactly one CBOR map under the CBOR rules above (its content is ignored, since no extensions are requested). Without ED, any byte after the 37 is refused. The reserved flag bits are ignored.
Checked against the expectation (refused otherwise), first failure answers, in this order. The presented credential id equals the credential the server looked up; clientDataJSON.type is webauthn.get (a registration proof is refused); the challenge equals the one the server issued, byte for byte; the origin equals the app origin exactly (no case folding, no prefix, no default port, catalogue E33); crossOrigin is not true and there is no topOrigin (the app is never embedded); tokenBinding.status is not present (token binding is not supported); the RP ID hash equals SHA-256 of the app's RP ID (E33); user presence (UP) is set; user verification (UV) is set when the caller requires it (sign-in and step-up pass "not required", matching userVerification: "preferred" in the options); BE equals the backup eligibility stored when the key was registered (see WebAuthn registration check and credential store below); the signature verifies with the stored key (ES256 with a DER signature, a raw 64-byte r||s or a non-minimal DER encoding is refused; RS256 PKCS#1 v1.5) over authenticatorData || SHA-256(clientDataJSON); and then the signature counter. Counter rule (E32). A key that reports 0 when 0 is stored has no counter (many synced passkeys) and passes. Otherwise the new count must be greater than the stored one; an equal or smaller count is refused as sign_count_regressed, a sign of a cloned key. The counter is checked only after the signature, so an unsigned forgery can never trigger it. The route writes an auth.webauthn_sign_count_regressed audit row for it (see below). On success the caller gets the new count to store, the flags (UV, BE, BS), the credential id and the user handle. When a user handle is present, the route refuses the proof (401 wrong_second_factor) unless it is the handle of the account being signed in, compared byte for byte on the raw bytes (WebAuthn Level 3 §7.2 step 6).
WebAuthn challenge, credential lookup and single use (MAP-4105). The options call of a flow (POST /admin/v1/me/step-up/options and POST /admin/auth/password/reset today, signin/password when it ships; each only when it offers a passkey or security key) mints 32 random bytes for each pending row it creates and keeps them only in that row. They are bound three ways: to that row (a proof signed over another row's challenge is refused), to the row's purpose (a step-up row never accepts a sign-in challenge; a stored challenge of another purpose is a server fault, 503) and to the person of the row. webauthn lists the person's stored credential ids in allowCredentials, oldest first, without transports; a person with more than 64 stored keys gets 503 and never a shortened list. A webauthn factor sent for a row that has no challenge (no key was stored when the row was made) is 401 wrong_second_factor and counts. A stored challenge the server could not have written is a fault (503), never an accept and never "no challenge". The credential is looked up by its id within the account: an id that is unknown and an id of another account give the same 401 wrong_second_factor, write nothing and do not reveal which it was. A refused proof does not spend the challenge: the person may retry on the same token within its caps (five wrong factors per token, twenty per hour per account), the same counters as an app code. An accepted proof records its step and clears the challenge in one conditional update of the pending row, so the same assertion sent again is refused (403 step_up_required once the step-up token is verified). After the signature check the counter and the time of use are written in one conditional update on the counter that was read: when another submit used the key in the meantime, the update matches nothing and the proof is refused (401 wrong_second_factor, never retried). For a key without a counter (0 stored, 0 reported) that update adds nothing; the pending row's update is what makes a proof single-use. Counter regression audit (E32). An equal or smaller counter writes one auth.webauthn_sign_count_regressed audit row (the person, the factor id, status 401, no counter value, no key) and answers 401 wrong_second_factor; for a member of an organisation the row also goes to the organisation's SIEM stream. A duplicate submit can record a benign E32: when one assertion of a key with a counter is sent twice at once (a double click), the second submit can read the counter the first one already stored and is refused with that audit row although no key was cloned. The amr of an accepted proof comes from the stored kind (swk for a passkey, hwk for a security key), never from authenticatorAttachment. The factors list names passkey / security_key after totp, the most recently used kind of key first (from last_used_at; a kind never used comes after a used one; on a tie passkey comes first).
Rules for every route that records a WebAuthn step (MAP-4085 signin/finish, the MAP-4092 reset path). (a) The verify gets the stored challenge from the same pending-row read that its recording update compares against. (b) A verified WebAuthn step is recorded with the update that also clears the challenge, or by consuming the row, never with an update that leaves the challenge in place. (c) If that update fails after the counter was recorded, the challenge stays live and only the holder of the bound token can retry; this is accepted.
RP ID and origin per environment. Both come from the one app origin of the deployment (AIG_FRONTEND_URL, then AIG_ADMIN_CORS_ORIGIN, then https://ai.myra.eu). The RP ID is the exact app host, never the parent domain, so a passkey registered on one environment never works on another: ai.myra.eu (prod), ai-int.myra.eu (INT), ai-beta.myra.eu (beta) and localhost (local development, origin http://localhost:<port>). The origin is scheme, host and any non-default port, lowercased, without path, query or fragment. Only the web origin is accepted (the Android app runs WebAuthn inside its WebView on the web origin). An app origin that is not https (except http on localhost), whose host is an IP address or ends in a dot, or that carries port 0, a port above 65535, a port with a leading zero or the default port spelled out, is a server fault: no WebAuthn proof is accepted until it is fixed.
WebAuthn registration check and credential store (passkey and security key). The gateway checks a new passkey or security key (a registration, WebAuthn Level 3 §7.1) in two steps, the same way as the assertion above, and then stores it. POST /admin/auth/setup/webauthn (with setup/webauthn/options, MAP-4106) and POST /admin/v1/me/factors/webauthn (with its options call, MAP-4107) use it. The answer classes are the same: malformed is 400 invalid_field on credential, refused is 401 wrong_second_factor, and a fault on the server side is 503 and never stores anything. An absent credential is the route's 400 missing_field, answered before the check runs.
Accepted shape (malformed otherwise). credential has the same envelope as the assertion credential (id, rawId, type, response, and the optional authenticatorAttachment and clientExtensionResults, with the same rules), but response has exactly two members: clientDataJSON (1 to 2048 bytes, the same rules as above) and attestationObject (1 to 4096 bytes, checked on the encoded text first). Any other member of response, such as the transports, publicKey or authenticatorData that some browsers add, is malformed. The decoded attestationObject is one CBOR item under the CBOR rules above: a map with exactly the text keys fmt (text of 1 to 32 bytes), attStmt (a map) and authData (bytes). Its authData is 56 to 4096 bytes: the 32-byte RP ID hash, the flags, the 4-byte counter, then the attested credential data, which must be present (the AT flag). That data is a 16-byte AAGUID (read and discarded), a 2-byte big-endian credential id length of 1 to 1023, the credential id, which must equal rawId byte for byte, and the credential public key. The key is exactly one CBOR item, read under the COSE rules above (ES256 or RS256 only, the two algorithms the options offer). With the extensions flag (ED) exactly one CBOR map must follow the key; without ED nothing may follow it. BS without BE is refused. For fmt none the statement must be the empty map. For fmt packed it must have exactly alg (an integer) and sig (1 to 1024 bytes), or those and x5c (an array). clientExtensionResults and the authenticator's extension outputs are ignored and never stored.
Checked against the expectation (refused otherwise), first failure answers, in this order. clientDataJSON.type is webauthn.create (an assertion is refused). Then come the same challenge, origin (E33), crossOrigin / topOrigin, token-binding, RP ID hash (E33), UP and UV steps as for the assertion; the setup routes pass "UV not required", matching userVerification: "preferred". Then the attestation: none is accepted, because the options ask for no attestation. packed self attestation is accepted only when its alg is the key's algorithm and sig verifies with the new key over authData || SHA-256(clientDataJSON); otherwise it is attestation_signature. packed with a certificate chain (x5c) and every other format (fido-u2f, tpm, android-key, android-safetynet, apple, anything else; the name is compared exactly) is refused as attestation_unsupported. The gateway keeps no attestation trust anchors and does not judge authenticator makes, so it never parses a certificate from the request. A browser that follows the options always sends none; a client that sends another format cannot add that authenticator. A refusal makes the web app drop the credential and ask for new options, so nothing is ever stored half-way.
Creation options. challenge is the pending challenge and rp is the deployment's RP ID (see below) with its display name. user.id is the canonical base64url of the account id's raw bytes: the account id has 1 to 36 bytes, so user.id has at most 48 characters. It is pseudonymous and never the email. user.name and user.displayName are at most 256 bytes. pubKeyCredParams lists ES256 (-7) and then RS256 (-257), timeout is 120000 ms and attestation is none. excludeCredentials lists the person's stored credential ids (an empty list is []) without transports, since none are stored. authenticatorSelection is platform with residentKey: "preferred" for a passkey and cross-platform with residentKey: "discouraged" for a security key, with userVerification: "preferred" for both. When a sign-in later presents a user handle, it must equal the account id's raw bytes exactly; there is no second handle.
What is stored. One row per credential in user_mfa_factor holds:
- the kind (
passkeyorsecurity_key, as the person chose; with attestationnonenothing about the authenticator is trustworthy, so the kind is not checked against the flags); - the name;
- the credential id, byte-exact;
- the COSE key bytes exactly as the authenticator sent them;
- the counter;
- the backup eligibility (
BE), which the sign-in compares because it never changes for a credential.
No transports, no AAGUID, no backed-up flag and no attestation are stored. A stored row that the only writer could not have produced (a missing backup-eligibility flag, a key that no longer reads, a counter out of range) is a server fault (503) for that one credential, never "no key" and never "not eligible". After a verified sign-in, the counter and the time of use are written in one conditional update on the counter that was read. When another submit used the key in the meantime, the update matches nothing and the route refuses the proof (401 wrong_second_factor). The store enforces a combined limit of 64 passkeys and security keys per person. The web app accepts at most 64 listed credentials, so the list of a person's stored credential ids is a server fault (503) when there are more than 64, never a shortened list; the routes that add a key keep a person within that bound. Both options calls answer 503 at 64 stored keys (MAP-4106, MAP-4107; which 4xx and text to show instead is an open product question). The store's insert counts the person's keys in its own transaction and refuses the 65th (503). The signed-in route locks the person's user row first, so two parallel adds cannot both pass that count.
Duplicates (E48). A credential id that is already registered, for this account or any other account, is refused with 409 factor_already_registered and nothing is stored. The database's unique key decides this in the same write, so two parallel tries cannot both succeed. The comparison is byte-exact: ids that differ only in letter case or a trailing zero byte are different credentials. Because the client chooses the id, this answer tells a caller that the id exists on some account. The routes that return it (MAP-4106, MAP-4107) are reached only with a valid setup or enrollment token, and each try is counted before it is checked (5 per token, 20 per account per hour); whether they should answer more generically is an open product question. Unlike the authenticator app's 409, this one keeps its count: with attestation none a caller can claim any credential id, so the answer is a guess.
First-factor setup routes (MAP-4106). POST /admin/auth/setup/webauthn/options (body pending_token, kind: passkey or security_key) and POST /admin/auth/setup/webauthn (body pending_token, name, credential) add the first passkey or security key during sign-in. Both answer Cache-Control: no-store and refuse any query string (400 pii_in_query). Order of the checks: query, body fields (missing_field for an absent field or a name that is empty after trimming; invalid_field for a wrong type or shape, including null and a kind of ""; the field is named), the pending token (400 signin_expired for an unknown, expired, consumed or other-purpose token; on the register call a token burned by 5 wrong factors answers 429 factor_attempt_cap), the step-open check (400 signin_expired for a row whose password step, or for a password row the email code step, is not done), the person and policy re-check (400 signin_expired when the account was disabled or blocked, or the sign-in option is no longer password and second factor), the factor-failure cap (429 factor_failure_cap), then the challenge and the registration check. A register call on a row without a challenge whose passkey or security key step is already recorded (a resubmit after a success) answers 400 signin_expired and is not counted. options answers 200 {publicKey} and stores the challenge in the row (replacing an earlier one). The register call answers 200 {factor: {id, type, kind, name, created_at, last_used_at}}. A challenge mismatch or a refused attestation is a counted 401 wrong_second_factor and keeps the challenge, so the same ceremony can be retried; the key insert and the single use of the challenge are one transaction. Since MAP-4107 each registration is counted before it is checked: once on the account (at most 20 per hour), then once on the token (at most 5). Parallel registrations on one token therefore cannot go past either cap. This includes a row without a challenge, which answers a counted 401. A success gives both counts back. A refusal, a duplicate (409 factor_already_registered), a lost race (400 signin_expired) and a fault after the count keep it. Before MAP-4107 a refusal was counted after the check, so requests in flight on one token could go past the cap by their number. The name is trimmed, 1 to 64 code points, without control characters. The audit row is auth.second_factor_added; the key's kind is recoverable through entity_id (the factor id) in user_mfa_factor.kind, because the audit record has no detail field.
Residuals. A fault after the key insert committed but before the answer leaves a stored factor the person does not know about; the next sign-in then asks for it (catalogue E92). The 409 for a credential id of another account is as specific as the one for the own account (catalogue E93): the oracle is reachable only with a valid pending token and is bounded per account by the factor caps, and it reveals nothing useful about real keys because authenticators choose credential ids of 16 or more random bytes. A person who stores a key and then leaves before setup/finish has that key as a second factor from the moment it is stored: the next sign-in asks for the password and then that key (purpose signin), never the setup again, and the person has no recovery codes until they create them under My account > Security (catalogue E94).
Account routes, passkey and security key (MAP-4107). POST /admin/v1/me/factors/webauthn/options takes kind (exactly passkey or security_key; absent missing_field, anything else, null, "" and "Passkey" included, invalid_field) and step_up_token (the step-up rule: every problem is 403 step_up_required). POST /admin/v1/me/factors/webauthn takes enrollment_token (43 base64url characters with a canonical last character; absent missing_field, anything else invalid_field), name (the factor name rule above) and credential (the registration check above). Unknown members are ignored on both. Any query string is 400 pii_in_query. A body that is not a JSON object is 400 malformed_body, and a repeated key is 400 duplicate_key. The token is looked up by its hash and only as an enroll token of the calling session. A token of the right shape that is not one is 400 signin_expired, never counted. The row must belong to the caller and must have been opened by a signed-in session. The stored challenge decides what is checked: a key challenge of this purpose is checked as a registration; an authenticator-app challenge, or none, is a counted 401; anything else is a server fault (503, logged). Residuals. The 409 for another account's key is the E93 oracle above. A lost connection at the commit may leave a stored key (as E92). The 64-key answer is a 503 until the product decides (catalogue E121).
First-factor setup routes, authenticator app (MAP-4098). POST /admin/auth/setup/totp (body pending_token) and POST /admin/auth/setup/totp/confirm (body pending_token, code) add the first authenticator app during sign-in. Both answer Cache-Control: no-store and refuse any query string (400 pii_in_query). Order of the checks on setup/totp: the pending token (400 signin_expired for an unknown, expired, consumed, burned or other-purpose token), the step-open check and the person and policy re-check (as for setup/webauthn), then one app per person (409 totp_already_set_up when the row has the app step or the person has a stored app), then the cap of 10 secrets per pending token (429 rate_limited, the token stays usable). The secret is 20 random bytes. It is stored sealed with the master key in the pending row, never in a factor row, until a code confirms it; a new call replaces it, and it goes away with the row. The secret appears only in this one answer: it is never logged, never in an audit row and never returned by any later call. The otpauth_uri label is <issuer>:<email> and its issuer is the product name. Tenant branding of the issuer is an open product question.
Order of the checks on setup/totp/confirm: the body (code absent: missing_field; not 6 ASCII digits after trimming: invalid_field; nothing is read before this), the pending token (a token burned by 5 wrong factors answers 429 factor_attempt_cap), the step-open check, the person and policy re-check, the factor-failure cap (429 factor_failure_cap with Retry-After), a row that already has the app step (400 signin_expired, not counted), then the stored challenge. No challenge, or a well-formed passkey or security-key challenge, is a counted 401 wrong_second_factor. A stored value that cannot be read, or that belongs to another purpose, is a server fault (503, logged as an error). Each guess is counted before the code is checked: once on the token (at most 5) and once on the account (at most 20 per hour). Parallel guesses therefore cannot go past either cap. A right code gives both counts back. A wrong code keeps them, and the 6th guess on a token answers 429 factor_attempt_cap and burns the token (catalogue E74). If giving the account count back fails, the account stays one count higher. That is logged and never lets a guess through. The code is checked against the current 30-second step and one step on either side. Its step is stored as the app's last used step, so the same code cannot sign in later. The app insert and the single use of the stored secret are one transaction: either both are written or neither is. The app is named Authenticator app. The answer is 200 {factor: {id, type: "totp", kind: "app", name, created_at, last_used_at: null}}. A second app for the person (stored meanwhile through another token) answers 409 totp_already_set_up. The code was right, so the account count is given back, but the token keeps its count. The audit row is auth.second_factor_added, as for setup/webauthn.
Residuals. A fault after the insert committed but before the answer leaves an app the person does not know about. The next sign-in then asks for it, as for a key (catalogue E92). A setup abandoned after setup/totp leaves only the sealed secret in the pending row until the row expires (catalogue E97). A row in which the person switches between the app and a key keeps only the last challenge. Confirming the other one is then a counted 401 wrong_second_factor, never a 503 (catalogue E98). An app stored before setup/finish is a second factor from that moment on, as for a key (catalogue E94).
The new codes are listed in Error codes.
Single sign-on (OIDC)
A tenant can enable generic OpenID Connect sign-in (e.g. Microsoft Entra ID / ADFS) beside email-OTP. SSO authenticates existing accounts — it does not create users unless the tenant has jit_provisioning on (see Tenants and gateways). Per-tenant configuration lives under the tenant admin API (see Tenants and gateways); the runtime endpoints are:
| Method | Path | Auth | Description |
|---|---|---|---|
POST |
/admin/auth/sso/lookup |
Public | SSO discovery for the login page. Body: {"email": "…"} (JSON, Content-Type: application/json) — the address travels in the body, never in the URL, because the web server writes request lines into its error log; the former GET /admin/auth/sso/lookup?email=… still answers identically until 11 January 2027 and is marked Deprecation / Sunset (see Search and lookup values travel in the request body). Returns { "sso": true, "tenant": "…", "protocol": "oidc" \| "saml" } if the email's domain has an enabled SSO config, else { "sso": false }. The login button initiates the returned protocol for that tenant. When a domain is configured for both OIDC and SAML, OIDC takes precedence (the primary path). SAML is surfaced only when the gateway-wide SAML validator token is provisioned; an enabled-but-unprovisioned SAML config returns { "sso": false } (falls back to the e-mail code flow rather than a dead-end button) and is logged as a gateway misconfiguration. A domain allow-listed by enabled configurations of two organisations is never resolved to one: the answer is { "sso": false } (logged on the server). Accepted input: email is canonicalised exactly like POST /admin/auth/otp/request (surrounding whitespace trimmed, ASCII lower-cased; printable ASCII, no inner whitespace, exactly one @, raw length ≤ 254). Rejected: an absent, empty or whitespace-only email (no body, {}) → 400 { "error": "email required" }; a non-string email (number, null, object, array), one longer than 1024 characters, a repeated ?email= on the deprecated GET, or a malformed address → 400 { "error": "invalid email", "code": "invalid_email" } — a malformed address is never answered as "no SSO"; a body that is not a JSON object → 400 malformed_body; a non-JSON Content-Type → 400; a POST that also carries ?email= → 400 pii_in_query. A lookup fault is not "no SSO": if the SSO configuration cannot be read (database unavailable), the answer is 503 { "error": "single sign-on settings unavailable, try again", "code": "sso_lookup_unavailable" } with Retry-After: 5 — never { "sso": false }. The login page uses this endpoint only to show the single sign-on button while the user types; POST /admin/auth/otp/request re-runs the same discovery and answers its own 503 sso_lookup_unavailable on the same fault, so a failed lookup here never results in a code being sent past an unreadable configuration. Reveals only the domain→tenant SSO mapping + protocol — never a secret, and nothing about whether the address exists. Rate-limited per IP (30 / 60 s → 429; one window for both the POST and the deprecated GET). |
GET |
/admin/auth/oidc/{tenant}/start |
Public | Begin the OIDC flow for a tenant: stores an opaque state + nonce + the canonical redirect_uri server-side in the database (single-use, 10-min TTL), sets a Lax CSRF cookie, and redirects to the IdP's authorization endpoint. {tenant} must be a UUID (case-insensitive, canonicalised to lowercase before it is stored in the correlation row); a malformed one ends at /login?error=sso_failed (see {tenant} shape). The correlation is DB-backed (not an in-process per-node cache) so an active-active deployment where /start and /callback land on different sites still completes. Accepted query: remember (1/true → the callback mints the 30-day session; anything else — absent, repeated, value-less, other text — the 8-hour default). Rate-limited per IP+tenant (sso_flood_cap_per_min, default 1000 per 60 s, its own bucket, keyed on the canonical lowercase tenant id so case variants share it; a locked client bucket is refused the same way, see SSO refusal lockout): past the cap the answer is 302 /login?error=sso_rate_limited (the 429 slug mapping), decided before any storage read, IdP discovery fetch or state-row write, so a request past the cap creates no pending row and triggers no outbound request. The IdP discovery document is cached per worker (5 min; a failed fetch is remembered for 15 s) and saving the SSO settings always validates against the live IdP, never the cache. Pending state rows expire after 10 min and are reaped in bounded batches. The bound is per claimed client IP: a client that can forge X-Forwarded-For, or that obtains a fresh IPv6 /64, escapes the cap (rotating addresses within one /64 shares one budget), and there is deliberately no per-tenant aggregate cap (a shared counter would let an anonymous caller lock a tenant out of SSO). |
GET |
/admin/auth/oidc/callback |
Public | The IdP redirect target. Verifies the CSRF cookie, atomically consumes the single-use state (a replay/expired/unknown state → 400), verifies the id_token, resolves the user, and on success sets the aig_admin session cookie. |
The callback redirect_uri is canonical and fixed per deployment, sourced from trusted deploy config (not the request Host): in production it is https://ai-api-admin.myra.eu/admin/auth/oidc/callback (on the integration environment, https://ai-api-admin-int.myra.eu/admin/auth/oidc/callback) — a single, non-tenant-keyed URI (the tenant is recovered from the signed state, never the URL). A spoofed Host cannot change it (deriving it from a client-controlled header would be an auth-code-exfiltration vector). It is overridable by a deployment setting. Register this exact URI as the redirect/reply URL in the IdP application. The exact value emitted at /start is persisted with the state and re-sent byte-for-byte at token exchange, so the IdP's exact-match check always agrees. This mirrors the MCP OAuth-callback posture.
First sign-in (account linking). The first time an identity signs in, the gateway links it to the existing account of the same tenant. The link is refused with 403 (sso_denied slug, or sso_email_unverified for an unverified e-mail) when: (1) the e-mail is not verified: the email claim is the only identity used (outside Entra mode preferred_username/upn are never used), and the link needs email_verified to be the JSON boolean true. An absent claim is accepted only in Entra mode or when the tenant set idp_emails_trusted; false (and, with a malformed shape, the string "true", null, a number, an object or an empty string) is always refused. An unverified e-mail redirects to /login?error=sso_email_unverified and a malformed claim is refused as before; both are audited as login_denied and are returned before any account lookup or creation. (2) the account is matched by e-mail but already has a link to a different subject at the same provider and issuer: a changed e-mail address at the IdP never re-binds an already-linked account; audit action link_conflict. In Microsoft Entra mode with subject_claim = oid, the account whose SCIM external_id equals the oid is the authoritative match and takes precedence over the e-mail claim (the conflict check then does not apply); a disabled account is never matched. (3) Entra mode with subject_claim = oid only: no account has the presented oid as its external_id, and the account matched by e-mail already carries a different SCIM external_id (for example a mailbox or UPN reassigned to a new employee before the old account was deprovisioned): the e-mail never re-binds an account SCIM tied to another directory identity; audit action link_conflict. The email_verified check runs before just-in-time provisioning, so an unverified e-mail never creates an account; an account that just-in-time provisioning finds already existing (a concurrent first sign-in) is subject to the same link-conflict checks. A database fault while checking is 503 and is not audited. Realistic lockout trigger: Entra's sub is pairwise per application (client_id), so re-registering the app while subject_claim = sub changes every user's sub under the same issuer, and every already-linked user then hits link_conflict. SAML IdPs that issue per-SP persistent NameIDs behave the same way. To recover, an administrator with USERS_MANAGE unlinks the stale link (the SSO links card on the member's page, or DELETE /admin/v1/users/{id}/sso-links, see SSO links); the user's next sign-in links the new subject. Operators can list existing links created under the old rule with read-only SQL on oauth_link (provider oidc, tenants without an entra_tenant_id); oauth_link has no creation time, so rows whose stored e-mail is NULL or differs from the user's e-mail are the ones to review first. A disabled account that already holds a link is refused with 403 before any side effect (audited sso.account_disabled.login_denied); a link to a deleted account never creates a new account (audited sso.account_deleted.login_denied). Concurrent first sign-ins of one identity all resolve to the same account, exactly as a single sign-in would: a request that finds the link another request has just created for an active account in the same tenant signs in as a normal linked login and is never audited as account_disabled, while a disabled or wrong-tenant account is still refused. Notice of the link. When the identity is linked to an existing account (not when just-in-time provisioning creates the account), the gateway writes one sso.identity_linked audit row (201) and sends the person the security mail "New sign-in method linked to your account" (see Security emails): it names the protocol ("OpenID Connect") and, when the issuer is a URL, only its host name (a value that is not a URL with a plain host name is not shown), never the e-mail or the subject. The signal is the link's creation, decided under the database row lock, so it fires once per link: a second sign-in, or a concurrent sign-in that loses the race, sends nothing. The mail is best effort and is not rate-capped (a cap would let an attacker suppress the notice); a failed or refused attempt never fails the sign-in.
When the IdP redirects back to the callback with an ?error= (for example a Conditional Access denial, a cancelled sign-in, or consent_required when admin consent is missing), the callback 302-redirects the browser to /login?error=<slug> (see SSO failure redirect below) — access_denied maps to sso_denied, the consent_required/interaction_required/login_required family to sso_retry, any other provider error to sso_failed. The IdP's error_description is never reflected. The refusal is audited like a SAML IdP refusal when it can be attributed: if the callback's state matches the aig_oauth_state cookie (the same double-submit check as a code return), the pending state row is consumed (the sign-in is over; a new attempt starts at /start) and gives the tenant, and the callback writes sso.login_denied (403) for access_denied or sso.login_failed (401) for any other provider error, with the tenant in entity_id and the configured issuer in idp_entity_id. The row carries no provider text (neither error nor error_description); both go only to the gateway warning line, with the tenant, control characters flattened and cut to 64 and 300 characters. The ?error= redirect carries no IdP signature, so the row records that a browser holding this sign-in's state and cookie presented an IdP error, not a verified IdP decision. For the same reason every audited refusal (the 403 included) counts toward the SSO refusal lockout of the tenant and client IP bucket, and while that bucket is locked the callback answers sso_rate_limited and writes no row. No audit row is written, and the redirect is the same, when the state is absent, repeated or empty, does not match the cookie (the pending row is then left untouched), is unknown, expired or already used (a replayed error URL writes no second row), when the tenant's SSO is disabled meanwhile, or when the database read fails (logged at error level). An IdP error that is not audited never counts toward the lockout. Grant admin consent and review Conditional Access policy at the IdP to resolve these. Step-by-step provider setup (Microsoft Entra ID, and generic OIDC/SAML providers) lives under Administration → Security → Single sign-on.
Require single sign-on (enforcement)
When a tenant enforces SSO (see PUT /tenants/{id}/sso-enforcement in Tenants and gateways), e-mail sign-in is refused for every address on the tenant's SSO domains:
POST /admin/auth/sso/lookupadditionally answerssso_required: true(a strict boolean; the login page honours nothing else). It is answered from the domain alone, so it reveals nothing about whether an account exists.POST /admin/auth/otp/requestanswers403 { "error": "single sign-on required", "code": "sso_required", "sso": … }— no code is created and no e-mail is sent. Sign-up for such an address is refused with the samesso_requiredcode. Read thecodefield, not theerrorprose.- Break-glass. The tenant names up to 10 break-glass administrators.
otp/requestaccepts an optional booleanbreak_glass(any other type gives400 invalid_request). For a member of the list a code is issued; for every other address the answer is the same generic "sent" body with no code. This also holds while an enforced tenant's SAML validator is unconfigured: requests withoutbreak_glassget503 sso_lookup_unavailable, break-glass members still get a code, and every otherbreak_glassrequest gets the generic body (membership is never revealed). Verifying that code (or a magic link or static OTP minted before enforcement) is re-checked at redemption: non-members get403 sso_required, a settings fault gets503 sso_lookup_unavailable. The exception is a person whose resolved policy ispassword_mfa(including a Myra platform admin while admin MFA is enforced) and who has a password, or who has a fixed code: no code is sent, and the answer is the same generic body; see Changed existing routes, which also states the timing. Break-glass logins are audited assso_break_glass_login; denials asauth.login_denied. - Google / Microsoft quick sign-in has no break-glass: a browser navigation is redirected (
302) to the tenant's IdP start, an app/JSON client gets403 sso_required. - Enabling enforcement revokes sessions of existing users on the enforced domains, except the break-glass users.
SSO failure redirect
Every OIDC/SAML browser-navigation endpoint — /oidc/{tenant}/start, /oidc/callback, /saml/{tenant}/start, and /saml/{tenant}/acs — is reached by a top-level browser navigation (the IdP redirects or auto-POSTs the browser to it, and the login page sets window.location for /start). On any failure these endpoints therefore 302-redirect to /login?error=<slug> rather than emitting a JSON body (a JSON body would render to the browser as raw text). <slug> is drawn from a closed, server-controlled set:
| slug | meaning | mapped from |
|---|---|---|
sso_failed |
generic sign-in failure (also the fallback for any failure status not listed below) | 401 auth failures, 400 malformed callback (bad/missing/expired code/state, CSRF mismatch), 404 SSO-not-enabled, 413 oversize, 500 config, unrecognised IdP error |
sso_denied |
authorization denied | 403 (tenant gate, no email in assertion/token, IdP access_denied; not a JIT seat-limit refusal) |
sso_seat_limit |
just-in-time sign-in refused, no free seat | 403 from JIT provisioning (tenant.jit_provisioning on) |
sso_mfa_required |
the IdP did not assert the tenant's required authentication context (MFA) | 403 when the tenant's required_authn_context is not met by the OIDC acr/amr claims or the SAML AuthnContextClassRef; no session or account is created |
admin_mfa_required |
a Myra platform admin (sys:admin) while admin_mfa_enforced is on: platform admins sign in with password and a second factor |
403 from the admin MFA check after the organisation check; never counted toward the refusal lockout |
sso_retry |
retry with interaction | IdP consent_required/interaction_required/login_required |
sso_rate_limited |
too many sign-in requests, or the refusal lockout is active | 429 from the per-IP+tenant request cap or the SSO refusal lockout on /start and /acs |
sso_unavailable |
transient / provider unavailable | 502/503 (discovery, token endpoint, DB fault, provider not configured, SAML validator unreachable, an ACS request body the server received but could not read back) |
Diagnosing sso_unavailable. Every redirect to /login?error=sso_unavailable writes exactly one error-level line to the gateway log, sso_unavailable: status=<502|503|401> cause=[<what failed>] request_id=<id> ip=<ip:NB>. The cause names the exit that failed (for example saml acs: validator unreachable tenant=… err=connect: timeout, or a database fault in the user lookup, with credentials and values redacted) and is cut at 300 bytes; a bounce with no recorded cause reads cause=[unspecified]. The client address appears as its length only. Other slugs write no such line.
SAML validator capacity. The validator accepts connections with a listen backlog of 1024 (the operating system caps it at net.core.somaxconn), so a burst of simultaneous sign-ins queues instead of being dropped at the TCP layer; earlier builds used the Python default of 5, which under a burst turned into the gateway's 500 ms connect timeout and sso_unavailable. The validator runs one validation at a time per node, by design: the XML libraries it uses (libxml2) are not safe under concurrent threads, and concurrent validations corrupted their shared state and failed otherwise valid sign-ins. One node validated about 225 assertions per second in a measurement on a development machine; from that, about 1,000 simultaneous ACS requests per node should complete within the 5 s read timeout (estimate from about 225 validations per second times the 5 s read timeout, roughly 1,100, rounded down). That last figure is an estimate, not a guarantee; size and test for your own hardware and IdP.
SSO refusal lockout
The SSO start and ACS routes are protected by two limits per client IP and tenant (IPv6: per /64). Both answer
302 /login?error=sso_rate_limited (HTTP status 429 internally) and neither reveals which one applied.
- Flood cap. At most
sso_flood_cap_per_minrequests per route per 60 s window (default1000, range500-100000, see Settings). Takes effect on the next read on the node that served the write and within about 5 s on other nodes (settings cache). Every gateway node counts on its own, so a deployment of N nodes admits up to N times the cap. - Refusal lockout. Only a genuine sign-in refusal counts: a
401from the SAML ACS or the OIDC callback (SAML: a bad signature, wrong audience, replayed or unmatched assertion; OIDC: an ID token that fails verification: signature, issuer, audience, expired ID token, nonce; an unknown or expired login state is a400and does not count), and an audited OIDC IdP?error=refusal (403or401, see Single sign-on (OIDC)) — it is unsigned, so anyone who opens a sign-in can produce one. Outages (sso_unavailable), other denials (403), malformed requests (400), unconfigured SSO (404), oversize bodies (413), rate-limit answers and server errors never count. Once 500 refusals land in any 60 s span (counted over the current and previous minute, so up to 2 minutes), the scope is locked for 30 minutes:/startand/acs(SAML) or/startand/callback(OIDC) of that tenant answersso_rate_limitedfor that IP bucket only. Other IPs and other tenants are unaffected. - Release. The lock is tied to the stored configuration version. Saving the SSO configuration of that protocol (or a SAML metadata refresh that changes the IdP fields) ends the lock at once. The scope is per protocol: an OIDC save that also writes a group mapping ends a SAML lock, a SAML save does not end an OIDC lock.
- Logging. The first lock logs a WARN
sso lockout start; the counteraig_sso_throttled_total{tenant_id,route,reason}(reasonisfloodorlocked) counts every throttled request.
The real HTTP status is logged server-side and audited (for an OIDC IdP ?error=, only when it can be attributed to a pending sign-in) and any provider error_description is logged only (never written to an audit row) — neither is ever placed in the URL. The login page renders a translated, human message from the slug (both en and de); an absent or empty ?error= shows the ordinary sign-in screen (no banner), and an unknown or malformed value falls back to a single generic message. The ?error= value is treated as untrusted (principle 11): the login page looks it up in a fixed slug→message map (own-property lookup, so __proto__/toString/constructor resolve to the generic message) and never reflects the raw query value into the page — there is no reflected-XSS surface. The /metadata, /logout, and /sls endpoints are not part of this redirect behaviour.
OIDC discovery input limits. The issuer's
/.well-known/openid-configurationdocument is untrusted input: its body is capped at 256 KiB, andjwks_uri,authorization_endpointandtoken_endpointmust each be anhttp(s)URL without whitespace or control characters and at most 2048 bytes — otherwise discovery fails and the SSO configuration is not saved.
id_token verification (BSI Schutzbedarf HOCH)
The id_token is verified in-process against the tenant's configured issuer, fail-closed at every step:
- RS256 only.
alg:none, anyHS*(RS/HS confusion), and an embeddedjwk/jku/x5uor acritheader are rejected. Keys come only from the configuredjwks_uri. - Key by
kid, fetched from JWKS and cached per(jwks_uri, kid); the RSA key must be ≥ 2048-bit with a sane exponent. - Signature is checked before any claim is read.
- Claims:
issexact-match;audmust contain the client id (azpchecked when present, and required for a multi-audience token per OIDC §3.1.3.7);exprequired andiat/nbfchecked when present, each a finite number within ±120 s skew (anexpis accepted only beforeexp+ 120 s; a non-numeric or non-finiteiatornbf, including JSONnullandNaN, is rejected); the login-timenoncemust match. - Microsoft Entra multi-tenant. When a tenant's SSO config carries its Entra directory tenant GUID (
expected_tid), the verifier switches to Entra mode (a config without it stays exact-issgeneric-OIDC, byte-for-byte as before — Keycloak/ADFS are unaffected). In Entra mode, additionally: theisshost must be on the trusted Microsoft authority allowlist (login.microsoftonline.com,sts.windows.net) — any other host, a userinfo/@splice, or a non-httpsscheme is rejected (iss_untrusted_authority); the token'stidmust be a non-empty string equal toexpected_tid— enforced always, even single-tenant, so a validly-signed token from another Entra directory that merely lists us inaudis rejected (tid_missingwhen absent/blank/non-string,tid_mismatchwhen present-but-wrong); a templated configured issuer containing the literal{tenantid}(returned by Entra common/organizations discovery) has that placeholder filled with the pinnedtidand is then exact-matched (iss_mismatchotherwise). Both v1 (https://sts.windows.net/<tid>/) and v2 (https://login.microsoftonline.com/<tid>/v2.0) issuer forms are accepted, and the audience may be either the bare client id orapi://<client_id>(Entra mode only — generic-OIDC still requires the bare client id). A malformedexpected_tid(a non-string, non-empty config value) fails closed (bad_config) rather than silently degrading to generic mode.
Identity resolution and the tenant boundary
Identity subject is matched byte-exact. The IdP subject (SAML NameID, OIDC sub or the configured subject_claim, OAuth sub) keys the stored identity link and is compared exactly: case, accents, width and trailing spaces all distinguish identities (Alice and alice are two different subjects). A subject that could not round-trip exactly is rejected, never trimmed or normalised: not a string, empty or blank, leading or trailing whitespace, a control or invisible/format character, invalid UTF-8, or longer than 255 characters. SAML answers 401 (sso_failed); OIDC answers missing_subject. An existing link is never re-pointed to another live account or tenant: the first link answers 403 (audited link_conflict), and a requester that vanished mid-login, or was soft-deleted or disabled meanwhile, answers a retryable 503 and nothing is linked.
A tenant's IdP is the identity authority for that tenant only. After verification the user is resolved by the configured subject_claim (sub by default; set oid for the Entra directory object id — a mutable claim such as email is rejected), and:
- a resolved account whose tenant differs from the flow's tenant is rejected (
403); - a first-time login links by IdP-verified email/UPN within the tenant's configured allowed e-mail domains (a configured allowlist, not a proof of domain ownership), tenant-scoped;
- an unknown identity returns
403— no account is created.
Every SSO sign-in, denial, and failure is written to the audit log (the tenant in entity_id, the IdP entityID / issuer in idp_entity_id, never any secret).
Single sign-on (SAML 2.0)
A tenant can alternatively enable SAML 2.0 SP-initiated SSO (e.g. Microsoft Entra ID / ADFS). Like OIDC, SAML authenticates existing accounts — it does not create users unless the tenant has jit_provisioning on. The gateway never parses SAML XML itself: an in-container, loopback-only validator performs all XML-DSig verification, and the gateway consumes only the signed scalar claims it returns. Per-tenant configuration lives under the tenant admin API (see Tenants and gateways).
First sign-in (account linking). The same link-conflict gate applies to SAML: an e-mail-matched account that already has a link at this provider and issuer under a different NameID is refused (403, sso_denied, audit action saml.link_conflict) rather than re-bound. SAML has no email_verified claim and is not affected by idp_emails_trusted; the tenant's allowed-domain list and the signed assertion are the controls. Recovery is the same administrator unlink as for OIDC (SSO links). A disabled account with an existing link is refused with 403 before any side effect (audited saml.account_disabled.login_denied); a link to a deleted account never creates a new account (audited saml.account_deleted.login_denied). Concurrent first sign-ins of one identity all resolve to the same account, as for OIDC. Notice of the link. The same applies to SAML: one saml.identity_linked audit row (201) and the mail "New sign-in method linked to your account" naming "SAML" and, when the IdP entity id is a URL, only its host name (a value that is not a URL with a plain host name, such as a urn: entity id, is not shown), once per link, never for a just-in-time created account.
These SP endpoints are served on the admin-API host over HTTPS (for example
https://ai-api-admin.myra.eu/admin/auth/saml/<tenant>/metadataand…/acs) — the direct admin-API host, reachable without relying on the same-origin/adminproxy, not theai.myra.euapplication host. The SP entity ID and ACS URL registered at the identity provider must use that host and thehttpsscheme; the emitted metadata, theAuthnRequestIssuer, and the tenant admin panel all reflect it (the scheme is taken fromX-Forwarded-Proto, so the edge's TLS termination is honoured). Register the values exactly as the SP/metadatadocument / the admin panel display them.
| Method | Path | Auth | Description |
|---|---|---|---|
GET |
/admin/auth/saml/{tenant}/metadata |
Public | The SP metadata XML (entityID, ACS, NameID format). The AuthnRequestsSigned flag is always present and is true only when the tenant enables signed requests; the signing KeyDescriptor appears when signed requests are enabled; the SingleLogoutService location appears when the tenant sets an IdP Single Logout URL (idp_slo_url) — independent of signing. Upload/point your IdP at this. Every host- and config-derived value interpolated into the document is XML-escaped, so a request Host cannot inject markup into the served metadata. Here {tenant} is the tenant id (UUID), not the slug. {tenant} must be well-formed (see {tenant} shape). |
GET |
/admin/auth/saml/{tenant}/start |
Public | Begin the flow: builds an AuthnRequest, stores a single-use correlation row, redirects to the IdP. Rate-limited per IP+tenant (flood cap, then the refusal lockout; both end at /login?error=sso_rate_limited). {tenant} must be well-formed (see {tenant} shape). Accepted query: remember (1/true → the ACS mints the 30-day session; anything else — absent, repeated, value-less, other text — the 8-hour default). The choice is stored on the correlation row and read back by the ACS when it consumes that row; nothing the IdP posts can change it (should that read-back fail, the sign-in still completes with the 8-hour default). Browser binding: /start also sets the short-lived cookie __Host-aig_saml_req (the AuthnRequest id; HttpOnly; Secure; SameSite=None; Path=/, no Domain, 10 minutes — the __Host- prefix means no other subdomain can plant it). Only the most recent sign-in started in a browser can complete: a second /start replaces the binding. The ACS accepts an assertion only when that cookie equals the assertion's signed InResponseTo — an assertion posted from a browser that did not start this sign-in (a login-CSRF attempt), or with the cookie missing or repeated, ends at /login?error=sso_failed without consuming the request. |
POST |
/admin/auth/saml/{tenant}/acs |
Public | Rate-limited per IP+tenant (flood cap, then the refusal lockout; both end at /login?error=sso_rate_limited), before the signature parse, so an unauthenticated POST flood cannot pin the validator. {tenant} must be well-formed (see {tenant} shape). Assertion Consumer Service. The IdP POSTs the SAMLResponse; the form must carry exactly one SAMLResponse (and at most one RelayState, 16 fields in all, see accepted inputs); the validator verifies signature/XSW/conditions and returns the signed scalars. The gateway then does single-use InResponseTo consume, one-time assertion replay defence, the tenant gate, and sets the aig_admin session cookie. Like the OIDC callback, this is a top-level browser navigation, so any failure 302-redirects to /login?error=<slug> (SSO failure redirect) rather than emitting JSON — a validation/replay failure — and an assertion posted from a browser that did not start the sign-in (no or a different __Host-aig_saml_req binding; nothing is consumed) — maps to sso_failed, a tenant/no-email denial to sso_denied, and a validator-unreachable or provider-unconfigured condition to sso_unavailable. |
GET |
/admin/auth/saml/{tenant}/logout |
Public | SP-initiated Single Logout. For a well-formed {tenant}, reads any session cookie opportunistically and never rejects (like POST /admin/auth/logout). Clears the local session cookie immediately, then — if the login was via SAML and the tenant configured an IdP SLO URL — redirects to the IdP with a LogoutRequest. Otherwise a plain local logout. The session cookie is matched by exact name (x_aig_admin is never read as aig_admin) and empty values are ignored; when aig_admin appears more than once (or the Cookie header is malformed) the session is ambiguous and the request is a plain local logout — no LogoutRequest is sent to the IdP. Rate-limited per IP and tenant (30 per 60 s): a rate-limited logout answers 429 { "error": "rate limited" } after clearing the session (both session cookies), so the limiter only stops the IdP redirect work and never keeps a session alive. {tenant} must be well-formed (see {tenant} shape). A malformed {tenant} still ends the local session (both session cookies are cleared) and answers 400 bad tenant. |
GET |
/admin/auth/saml/{tenant}/sls |
Public | Rate-limited per IP+tenant. {tenant} must be well-formed (see {tenant} shape). SP SingleLogoutService. Handles an IdP-initiated LogoutRequest (verifies its signature, returns a signed LogoutResponse to the IdP) or our own SP-initiated LogoutResponse coming back. Like /logout, it clears the local session (both session cookies) first and unconditionally — before the signature check, and also on a malformed {tenant} (400 bad tenant) or a rate-limited request (429); the limiter only bounds the validator round-trip. |
On a successful ACS login the gateway also syncs the user's Department when the tenant configured a department_attribute (see SAML configuration): a single string value names the Department, an absent attribute changes nothing, and a multi-valued or otherwise malformed value (including one with nothing visible) is ignored without failing the login (an empty <AttributeValue/> counts as malformed: it is logged as a warning and, like an absent attribute, changes nothing). If the tenant's group mapping holds department targets, that mapping alone decides the Department at sign-in and department_attribute is not applied (see SAML configuration). Changes are audited as saml.user_department_changed.
Accepted inputs and what is rejected (trust boundary)
{tenant}(all SAML routes and OIDC start) — a UUID (8-4-4-4-12 hex), matched case-insensitively and canonicalised to lowercase, which is the rate-limit bucket key (per IP + canonical tenant, so case variants share one bucket). Anything else:400 {"error":"bad tenant"}on metadata/logout/sls, and anerror=sso_failedredirect on SAML start/acs and OIDC start. Checked before the rate limit, storage and validator; on logout and sls both session cookies (aig_admin,aig_imp) are still cleared.SAMLResponse(ACS) — base64 string, pre-capped at 700 KB, in an HTTP-POST body of at most 1 MB (a large assertion is accepted however the server buffers it; the form may carry at most 16&-separated fields — every&-separated segment counts, including empty ones,=valueones and a leading or trailing&(16 fields plus a trailing&is refused) — and a body with more is refused rather than truncated). A repeated or value-lessSAMLResponseorRelayState, and an absent or emptySAMLResponse, are each refused before the assertion is processed:302to/login?error=sso_failed, nothing consumed, so the same valid assertion posted cleanly afterwards still completes the sign-in.RelayStateis not used — the landing page is always/. The validator rejects: unsigned assertions, signature-wrapping (XSW), deprecated algorithms (RSA-SHA1/SHA-1), wrong signing cert, anIssuer(on the Response or the assertion) other than the configured IdP entity ID, expired/not-yet-valid/wrong-audience/wrong-recipient/wrong-destination conditions, a missingInResponseTo(IdP-initiated is not accepted at the ACS, and there is no per-tenant setting to allow it), an encrypted assertion (EncryptedAssertion— encryption is not supported, whatever key it is encrypted to; there is no "require encryption" setting, so a plaintext signed assertion is the only accepted form), a missing NameID, and a non-identity NameID format —transient(per-session, re-minted each login) and entity/encrypted are rejected with a precise, format-naming error, since the NameID is the identity key.unspecifiedis accepted (it is Microsoft Entra's common default and carries a stable objectId), as is an omittedFormat(which defaults to unspecified per SAML core);persistentandemailAddressare accepted as before. Assertion timestamps (both theConditionswindow and the bearerSubjectConfirmationDataNotOnOrAfter/NotBefore) are validated with ±120 s clock-skew tolerance (matching the OIDC±120 sabove), so a small IdP clock drift or in-transit delay does not reject an otherwise-valid login; an assertion expired beyond that tolerance is still rejected. An assertion that repeats an attributeName(for example a default Keycloak client emitting one<saml:Attribute Name="Role">per role) is accepted, and the repeated values are merged into one multi-valued attribute. This affects attribute parsing only: every signature, XSW, algorithm, condition, and NameID check above still applies unchanged, and the identity is always the signed NameID, never an attribute. The response must contain exactly one assertion, and an assertion anywhere in the document counts toward that rule, including one nested insamlp:Extensions,ds:Signature/ds:ObjectorAdvice: such a response is refused with/login?error=sso_failed, not just a second assertion beside the signed one.- IdP signing-key rotation (ACS). The ACS verifies every assertion against the signing certificate stored for the tenant. When the IdP rotates its key without the gateway learning of it, the old certificate no longer matches and every sign-in is refused (
302to/login?error=sso_failed, auditsaml.login_failed, no session, no account or link change) until the stored certificate is replaced. A tenant that configured an IdP metadata URL recovers by itself at the next daily metadata refresh (the stored certificate is replaced and the change is audited with fingerprints only); a tenant with a pinned certificate recovers when an administrator re-imports the IdP metadata. An assertion signed with a SHA-1 algorithm is refused outright, never accepted with a warning. - NameID containing an XML comment (ACS). The identity is the complete signed NameID text. An XML comment inside it is not a boundary:
user@example.com<!---->.evil.testis the identityuser@example.com.evil.test, never the truncateduser@example.com, so it is checked against the tenant's allowed domains as a whole and is refused with302to/login?error=sso_denied(auditsaml.login_denied,403) when that domain is not allowed. SAMLRequest/SAMLResponse(SLS) — redirect-binding params, pre-capped at 100 KB. The SLO message must carry a valid query-string signature verified against the tenant's IdP signing certificate; an unsigned or forgedLogoutRequestis rejected (the force-logout defence). A repeated or value-less query parameter is rejected rather than coerced.idp_slo_url(config) must behttps://or empty;sign_authn_requestsis a boolean.
Single Logout and the stateless-session limitation
Admin sessions are stateless JWTs. There is no per-session revocation list — an individual stolen cookie cannot be revoked on its own — but each account carries a per-user revocation floor (sessions_valid_after): disabling or deleting the account records the current instant, and every session whose issue time (iat) is at or before it is refused. Single Logout therefore:
- ends the local session (clears the
aig_adminandaig_impcookies) immediately and unconditionally — a validator or IdP error, a malformed{tenant}(which then answers400) or a rate-limited request (which then answers429), never leaves the user signed in; and - propagates the logout to/from the IdP over the SAML protocol so the IdP session also ends.
After an ordinary "sign out" a JWT still held in another browser or device remains valid until it expires — sign-out clears only the calling browser's cookie and writes no revocation floor. This is inherent to stateless JWT sessions. A disable or delete is different: it stamps the revocation floor, so every session on every device is refused on its next request and cannot be revived (see below).
What outlives a change is only the session's existence, not its authorization. For the aig_admin admin session the token identifies the account; role, custom-role grants, disabled and deleted state are read live from the database on every admin request (the token's own role claim is never consulted), so a role downgrade, a custom-role change, a disable or a delete applies to every open admin session on its next request — a downgraded session stays signed in with the reduced permission set; a disabled or deleted account's session gets 401 (and GET/PATCH /admin/auth/me clear the cookie). Disabling or deleting a user permanently ends every session on every device by stamping the per-user revocation floor: an older cookie is refused even after the account is re-enabled or restored (the floor is never cleared — a returning user signs in afresh). The user's /v1 API tokens are revoked in the same step and likewise do not return on a re-enable; the caller mints new ones. Only exp, a sign-out, or another disable applies to a session issued after the last floor — and sliding renewal extends exp only while the session is still valid and un-revoked, so it can never revive a session the floor has already killed (a renewal re-runs the identical live-account check and refuses a revoked one).
Signed requests
When a tenant enables sign_authn_requests, the gateway signs the AuthnRequest/LogoutRequest with a gateway-wide SP key provisioned by your operator; the private key is never per-tenant and never stored in the database. If signing is enabled but no SP key is provisioned, the request path fails closed (no silent unsigned request) and the SP metadata still advertises AuthnRequestsSigned="true" so the mismatch is visible to the IdP. Note that with signing enabled and no key provisioned, inbound Single Logout messages are also rejected (the same settings build fails closed) — provision the SP key before enabling signing if SLO is in use.
Every SAML sign-in, logout, denial, and failure is written to the audit log (the tenant in entity_id, the IdP entityID in idp_entity_id, never any secret).
Inference API authentication
Inference endpoints (/v1/{tenant}/{gateway}/{provider}/...) use an opaque bearer token issued by the admin API.
Token acceptance order
The gateway checks request headers in this order; the first matching header wins:
| Priority | Header | Example |
|---|---|---|
| 1 | x-aig-token |
x-aig-token: myra_xxxx |
| 2 | Authorization: Bearer |
Authorization: Bearer myra_xxxx |
| 3 | x-api-key |
x-api-key: myra_xxxx |
This ordering lets you drop the gateway in as a replacement for the OpenAI API without modifying existing clients that send Authorization: Bearer or x-api-key.
Token security model
- Tokens are hashed with SHA-256 before storage. The plaintext is never persisted.
- The plaintext token is returned once in the creation response — copy it immediately.
- If a token is lost, delete it and create a new one; there is no recovery path.
- Tokens are scoped to a single gateway. Using a token on a different gateway returns
401 unauthorized. The path is/v1/{tenant}/{gateway}/{provider}/...— the token must belong to the{gateway}segment (a common mistake is reading the{provider}segment, e.g.myra, as the gateway). The401message is specific so you can tell the cases apart:- no token sent → "No API token provided..." (add the
Authorization: Bearer/x-aig-token/x-api-keyheader). - a token that belongs to a different gateway of the same tenant → "This token is recognized
but is scoped to a different gateway in this tenant..." (fix the
{gateway}path segment — do not regenerate the token). - an unknown token, or one from another tenant → "Missing or invalid gateway token for gateway '...'" (the generic case; the two are deliberately indistinguishable so the response never confirms a token's existence in a tenant you have not named).
- The wrong-gateway hint is tenant-scoped: it only ever tells a caller who already holds the token that it belongs to another gateway of the tenant they named in the URL. It never names the other gateway and never reveals whether a token exists in a different tenant.
- an explicitly revoked token →
401 token_revoked, "This gateway token was revoked on<date>. Mint a new token and update the caller." Revoking (DELETE …/tokens/{id},DELETE /admin/v1/me/tokens/{id}, a chat-bridge teardown) deletes the token row and writes a revocation tombstone (auth_token_revoked: the token's hash, its gateway, the time) in the same transaction, so the two can never disagree. The tombstone is read only for the gateway named in the URL: a token revoked elsewhere is the generic case above. A token that vanished with its agent, user or gateway (a cascade, not a revocation) is also the generic case.
- no token sent → "No API token provided..." (add the
- Unknown-token cache. A token that is unknown, revoked or scoped to a different gateway is
remembered as such for 60 seconds, per node and per gateway, so a client that keeps retrying
the same wrong value does not cost a database lookup each time. The answer is normally identical
to the uncached one (same
401, same message, same revocation date). The message, never the refusal, may lag by up to 60 seconds after a sibling token is revoked or a revocation record is purged; after an organisation is restored, a refusal of its tokens may persist for up to 60 seconds. The cache can only refuse: it never makes a token valid, and a token that is valid is never stored in it. A new token is valid at once, because only refusals are remembered and a token that was never presented has no entry. A failed lookup (database fault) is never remembered. Bounds: a token created within 60 seconds after the same value was refused on a node is still refused there until the entry expires, so never create a token with a secret that was already presented. Only repeats of the same value are absorbed; a client that sends a new random value each time is not helped. Refusals that come from the cache are still counted by the per-client rejection throttle described above. - What "immediate" means for a revocation. On the site that processed the revocation the cached authorization is dropped right after the transaction commits, so the very next request there is refused. Two bounded exceptions, both at most one authorization-cache TTL (5 minutes): a request that read the live row just before the commit and cached it just after the drop, and — production being active-active across sites with a per-site cache — the other site, which keeps serving its cached entry until that TTL lapses. There is no cross-site invalidation today.
- A decommissioned (soft-deleted) tenant fails closed. Once a tenant is soft-deleted
(
deleted_atset — see Deleting a tenant), every authentication and routing resolver rejects it in SQL: its tokens no longer authenticate, its gateways no longer route, and its users can no longer sign in (session, email OTP, OIDC/SAML, SCIM). This is what lets the contract-end purge erase the tenant with no new rows written mid-flight. - A token's bound user is scoped to the gateway's tenant. If a token carries a
user_id(for By-User attribution/budget), that user must belong to the same tenant as the gateway. A request whose bound user is in another tenant is refused403"This token is not valid on this gateway." — checked at the/v1sink before any routing, inference or tool call, so a cross-tenant token can never read another tenant's project knowledge (viaread_file/search_knowledge/code_interpreter) or spend another tenant's budget. The detail is generic and never names the bound user or their tenant. This holds independently of the mint check — even a token minted before the fix, or by any path, is refused here. The one exception is a platform admin (a tenant-less operator account,role: admin,tenant_idNULL), who is cross-tenant by design — this is what lets the operator Playground / chat drive any gateway; a tenant-resident admin is not exempt and stays confined to its own tenant.
Token capability scopes
A gateway token carries an optional scopes array (set at creation — see Creating a
token) that limits which capabilities the token may exercise. Enforcement is
opt-in and least-privilege:
- Recognized capabilities:
inference,tools,admin,growth_stats,growth_stats_domains,admin_read,mcp_proxy.mcp_proxyis strict: it admits a per-agent token to the MCP proxy endpoint only when declared explicitly (no scopes does not mean unrestricted there), and it is refused on inference routes. - A token that declares one or more recognized capabilities is held to them, fail-closed:
a capability the token did not grant is denied. In particular, a token whose scopes exclude
inference(for example["admin"]) is refused at the inference endpoint with403 forbidden— "This gateway token is not authorized for inference (its scopes exclude 'inference')." - A token that declares no recognized capability — an empty
scopes, or only legacy/unknown strings such as["playground"]or["read","write"]— is treated as unrestricted (the historical default). Unrecognized scope strings therefore do not restrict; to enforce least-privilege, use the recognized capability names above (matched case-insensitively). A token minted with noscopesremains unrestricted. - Mint-time shape:
scopesmust be a JSON array of at most 50 strings, each 1–64 characters fromA-Z a-z 0-9 . _ : / -, stored verbatim (the read side matches case-insensitively and trims, but a string with whitespace —"inference "— is refused at mint rather than silently normalized). A string, number, boolean, or object-with-keys value, an out-of-alphabet element, or more than 50 elements is rejected with400on every mint route (gateway, user, and personal tokens) — see Users & tokens → Token fields. - Enforcement applies to gateways with authentication required. On a gateway with
auth_required: falsethe token is optional, so a mis-scoped token is not rejected there (it is no stricter than sending no token at all). - Today the
inferencecapability is enforced at the request boundary;tools/adminare part of the vocabulary for forward compatibility (the admin API authenticates with a separate session credential, not a gateway token).
Growth-statistics scopes (growth_stats, growth_stats_domains)
The admin API accepts a gateway token on the growth route GET /admin/v1/stats/growth (growth_stats scopes) and on the read-only report routes under admin_read. The growth route accepts it
sent as Authorization: Bearer <token> (machine access for the operators' morning report). On every
other admin route a bearer header is ignored and the session cookie is required as before
(401 without one) — except the read-only report routes listed under admin_read. The rule for that route is strict — unlike the opt-in rule above, an
unrestricted token never qualifies:
- the token's recognized scopes must be a non-empty subset of
growth_statsandgrowth_stats_domainsand must containgrowth_stats— so["growth_stats"]and["growth_stats", "growth_stats_domains"]are accepted; a legacy / unrestricted token ([],["playground"],["read","write"]), a token that also carries any other recognized capability (["growth_stats", "inference"]), and["growth_stats_domains"]alone are refused403. Becausegrowth_statsis a recognized capability, such a token is in turn denied inference like any other restricted token — a stats token can do nothing else; growth_stats_domainsadditionally allowsinclude_domains=1(the per-bucket list of business e-mail domains); without it that parameter answers403;- the token must be bound to a user (
user_id), not bound to an agent, not expired, its scopes readable, and its owner a live (not disabled / deleted, not a demo) account that holds the platform permissionGROWTH_STATS_VIEW— the same authorization a browser session needs. The owner is resolved on every call, so demoting or disabling the owner ends the token's access at once.
Minting the stats token (ops convention): the platform account mints a personal token with
POST /admin/v1/me/tokens — gateway_id = a gateway of a Myra-internal tenant
that has no tenant admins (a tenant admin of that tenant could otherwise revoke it), scopes:
["growth_stats"] (plus "growth_stats_domains" only where the domain list is needed) and an
expires_at. A tenant admin cannot extend or un-expire such a token: editing a token owned by a user
the editor could not manage (a platform admin, or a user of another tenant) is refused — see
Editing a token.
Admin read-only reports scope (admin_read)
A myra_ token whose recognized scopes are exactly ["admin_read"], sent as
Authorization: Bearer <token>, may call this fixed allow-list of read-only GET report routes:
/stats/analytics,/stats/usage-series/cogs/per-model,/cogs/per-service,/cogs/per-tenant,/cogs/per-agent,/cogs/per-token/compliance/report,/compliance/reports,/compliance/reports/:id
Everything else (all writes, every other route including /cogs/per-user) stays session-only: the
bearer header is ignored there and the session cookie is required.
- Strict grant: a legacy / unrestricted token (
[],["playground"]), a token with any other recognized capability (["admin_read","inference"],["growth_stats","admin_read"]), or a token withoutadmin_readis refused403. A token scoped exactly["admin_read"]is in turn denied inference. - The owner is the actor. The token's owner (a live, non-demo user) becomes the acting user, so the
normal permission gate and tenant scope apply unchanged: a tenant admin's token reads only their
tenant (
?tenant_idstays pinned), a platform admin's token reads globally. The owner is resolved on every call; disabling or demoting them ends access at once. A service user occupies a seat. A demouser owner is refused403. Denials are audited under the owner. - No unmasked PII:
anonymize=0/falseon/stats/analyticswith a bearer is refused403; the default anonymized response is returned. -
Missing (bearer header present but empty) / malformed / unknown / revoked / expired tokens answer
401; a token with no owner, an owner that is gone / disabled / demo, unreadable scopes, an agent-bound token, or a failed scope check answers403; a database fault answers503. -
Other mint paths: besides
me/tokens,POST /admin/v1/users/:id/tokens(needsUSERS_MANAGEand a higher rank than the target) andPOST /admin/v1/gateways/:id/tokens(needsGATEWAY_TOKENS_MANAGE) can mint anadmin_readtoken. - Gateway state is not consulted. The token's authority is its owner. An archived or disabled gateway does not stop admin reads; deleting the gateway deletes its tokens, so the token dies with it.
/stats/growth: a growth token that also carriesadmin_read(["growth_stats","admin_read"]) is refused403there. Use a separateadmin_readtoken (one machine token, one purpose)./compliance/reportPDF render answers503when the renderer is at capacity; clients back off and retry.
Mint it with POST /admin/v1/me/tokens with scopes: ["admin_read"] and an expires_at.
Recommended: a tenant-bound service owner with a mandatory expires_at. A token owned by a platform
admin reads globally, exactly like that owner's session, so a leak has a platform-wide blast radius.
Logging out everywhere ends sessions, not tokens: the bearer path does not check sessions_valid_after (by design). Delete the token to revoke it.
Disabling authentication
For development or fully-internal networks, authentication can be disabled per gateway:
curl -X PATCH https://<your-gateway-host>/admin/v1/gateways/{id} \
-H "Content-Type: application/json" \
-d '{"config": {"auth_required": false}}'
⚠️ Caution: Never set
auth_required: falsein production. Any caller with network access to the gateway endpoint can make inference requests and incur provider costs.
Creating a token
Before you begin, ensure the following conditions are met:
- ☑ You have admin access to the gateway.
- ☑ You have the gateway ID available.
Proceed as follows to create a token:
- Send a
POSTrequest to/admin/v1/gateways/{gateway_id}/tokenswith the token configuration in the request body.- The API creates the token and returns the plaintext value once.
curl -X POST https://<your-gateway-host>/admin/v1/gateways/{gateway_id}/tokens \
-H "Content-Type: application/json" \
-d '{
"label": "my-service",
"scopes": ["inference"],
"expires_at": 1798761600,
"rate_limit": {"requests": 100, "window_sec": 60},
"budget_usd": 50.00
}'
Response:
{
"id": "tok_abc123",
"token": "myra_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"gateway_id": "gw_xyz789"
}
⚠️ Caution: The
tokenfield in this response is the only time the plaintext value is available. Store it in your secrets manager immediately.
-> The new token is ready for use in inference requests.
Using the token
Proceed as follows to authenticate an inference request:
- Include one of the supported authentication headers in the request.
- The gateway validates the token against the stored hash.
# x-aig-token header (preferred)
curl -X POST "https://<your-gateway-host>/v1/myapp/production/openai/chat/completions" \
-H "x-aig-token: myra_xxxx" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'
# Authorization: Bearer (OpenAI SDK compatible)
curl -X POST "https://<your-gateway-host>/v1/myapp/production/openai/chat/completions" \
-H "Authorization: Bearer myra_xxxx" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'
# x-api-key (Anthropic SDK compatible)
curl -X POST "https://<your-gateway-host>/v1/myapp/production/anthropic/chat/completions" \
-H "x-api-key: myra_xxxx" \
-H "Content-Type: application/json" \
-d '{"model":"claude-opus-4-6","messages":[{"role":"user","content":"Hello"}]}'
-> The API returns the requested inference response.
Role-based access control
Tokens are linked to a user record via user_id. The role of the user determines what the token can do:
| Role | Inference | Admin API |
|---|---|---|
admin |
All gateways | Full access |
member |
Assigned gateways only | Self-service only — own profile (GET /admin/auth/me), own tokens, commands, and connectors. No tenant administration. |
viewer |
403 on all requests |
Read-only own profile (GET /admin/auth/me); cannot create tokens or manage resources. |
💡 Note: The
viewerrole is intended for operators who need read access to the admin UI dashboard only. Any inference request from a viewer-role token is rejected with403 forbidden.💡 Note: This table shows the three baseline roles. The platform also ships the roles
tenant_admin,ki_manager,finance, anddemouser, and supports tenant-defined custom roles. See Roles for the full role model and per-permission grants, and Users & tokens for how roles are assigned.