Identity
Who a person is to the control plane: the Better Auth-compatible user, credential, session and verification tables.
Tables in this group: account, custodian, nonce, passkey, rotation, session, totp, user, verification.
account
One sign-in credential per user and provider: the local password account (credential) or a linked GitHub/Google identity; unique on provider plus subject.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
updated_at | timestamp(3) with time zone | yes | Last write time; the ORM sets it to now() on every update. |
user_id | uuid | yes | Parent user row (on delete cascade). |
provider_id | text | yes | credential for the local password account, or the OAuth provider id github or google for a linked identity. |
provider_user_id | text | yes | Provider-side subject: the user's own uuid on credential rows, else the GitHub/Google account id; unique together with provider_id. |
password | text | no | Argon2id PHC-format hash ($argon2id$v=19$m=N,t=N,p=N$salt$digest) on credential rows, set at sign-up, install and password reset; null on OAuth rows. |
custodian
A sign-in passkey a superadmin marked to approve control plane key changes, with the frozen key servers pin; kept as history once unmarked.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
passkey_id | uuid | no | The marked sign-in passkey; ON DELETE RESTRICT so it cannot be deleted while marked, and cleared when the passkey is unmarked. |
pkid | text | yes | Rotation passkey id servers pin: base64url SHA-256 of the raw credential id; unique among marked rows. |
alg | text | yes | Signature algorithm of the pinned key, ES256 or EdDSA. |
public_key_raw | text | yes | Base64url raw public key servers verify approvals with: a 65-byte P-256 point or a 32-byte Ed25519 key, copied when marked. |
rp_id | text | yes | WebAuthn relying party id the passkey belongs to: the primary hostname when the first passkey was marked. |
label | text | no | Passkey name and owner when marked, for mail and the audit trail. |
marked_keyset | integer | yes | Key set number of the statement that marked it. |
unmarked_keyset | integer | no | Key set number of the statement that unmarked it; NULL while marked. |
unmarked_at | timestamp(3) with time zone | no | When it was unmarked; NULL while it still approves key changes. |
nonce
Daemon challenge ids and request nonces already used, kept until expires_at so a replay inside the window is refused; pruned by the sweep.
| Column | Type | Required | Description |
|---|---|---|---|
value | text | yes | The used value: the nonce of a sign-in challenge or of a signed daemon request. |
kind | text | yes | What the value protected: challenge (enroll or session sign-in) or request (a signed daemon request). |
expires_at | timestamp(3) with time zone | yes | When the challenge or request stops being valid; the row is deleted after this. |
passkey
One WebAuthn credential registered by a user (several per user allowed), unique by credential_id; inserted at registration, updated on each passkey sign-in.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
user_id | uuid | yes | Parent user row (on delete cascade). |
name | text | no | User-chosen label given at registration (the device or authenticator it lives on); shown in the Security screen, never used for matching. |
aaguid | text | no | Authenticator model AAGUID decoded from the attestation as a dashed lowercase UUID string; identifies the make, not the individual key. |
public_key | text | yes | Credential public key as a JSON-serialised JWK (ES256, EdDSA or RS256) converted from the attestation's COSE key; verifies sign-in assertions. |
credential_id | text | yes | Base64url credential id from the attestation; unique across the instance and the lookup key for passkey sign-in. |
counter | bigint | yes | Authenticator signature counter from the last accepted assertion; a lower value rejects the sign-in (clone detection) and updates are compare-and-swap. |
device_type | varchar(32) | yes | multiDevice when the attestation flags the credential backup-eligible, else singleDevice; derived once at registration. |
transports | text | no | JSON array string of WebAuthn transports reported at registration (for example internal, usb, hybrid), or null when none were reported. |
is_backed_up | boolean | yes | Backup-state flag from the attestation (credential synced by its provider); with device_type it drives the Synced / Multi-device / This device label. |
rotation
One approved key-set statement of the control plane: the chain every server follows to a new key or passkey set, kept forever in keyset order.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
approved_by_user_id | uuid | no | Superadmin who approved it; ON DELETE SET NULL so the chain outlives the account. |
kind | text | yes | What it changes: rotate or revoke the key, or passkeys (mark or unmark rotation passkeys). |
keyset | integer | yes | Key set number the statement moves servers to; unique and one above the previous statement. |
state | text | yes | live when served to servers; awaiting_key while a High Availability secret does not hold the new key yet. |
prev_kid | text | yes | Fingerprint of the key the statement replaces or keeps; servers apply it only when this is their pinned key. |
current_kid | text | yes | Fingerprint of the key servers pin after the statement. |
body | text | yes | Exact statement bytes as base64url; the passkey challenge is SHA-256 of these bytes, so they are never rebuilt. |
approvals | text | yes | JSON array of the WebAuthn assertions that approved the statement, served to servers as written. |
prev_key | text | no | Base64url raw public key of prev_kid, served with the signature; NULL for a revoke. |
prev_key_signature | text | no | Base64url Ed25519 signature by the replaced key over tp-keyset, a newline and the statement bytes; NULL for a revoke, which two passkeys approve. |
live_at | timestamp(3) with time zone | no | When the statement started being served; NULL while awaiting_key. |
session
One row per signed-in session keyed by the opaque cookie token; rows are deleted (never extended) on sign-out or security changes and ignored once expired.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
updated_at | timestamp(3) with time zone | yes | Last write time; the ORM sets it to now() on every update. |
user_id | uuid | yes | Parent user row (on delete cascade). |
expires_at | timestamp(3) with time zone | yes | Fixed at creation to now + 7 days (SESSION_EXPIRES_IN_MS); never extended, and lookups treat rows past it as absent. |
token | text | yes | Opaque server-generated value, 32 random bytes base64url-encoded; unique, carried by the session cookie and matched verbatim. |
ip_address | varchar(45) | no | Client address captured at sign-in as IPv4 or IPv6 text (hence 45 chars); informational only, null when unknown. |
user_agent | text | no | Browser UA request header captured at sign-in; informational only, null when unknown. |
totp
TOTP enrolment for a user, at most one row per user (uniq_totp_user_id); inserted or reset on enable, verified once, and deleted when two-factor is disabled.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
updated_at | timestamp(3) with time zone | yes | Last write time; the ORM sets it to now() on every update. |
user_id | uuid | yes | Enrolled user; unique, so re-enabling resets the existing row instead of adding one, and disable deletes it. |
secret | text | yes | TOTP shared secret sealed as a tpsecret envelope with the data-encryption key; never plaintext and never returned after enrolment. |
backup_codes | text | yes | JSON array of HMAC verifier envelopes (tpotp.vN.hex) for the ten one-time backup codes, [] until verified; a used code is removed from the array. |
is_verified | boolean | yes | False until the user proves the first six-digit code; only a verified row turns on user.is_2fa_enabled and receives backup codes. |
user
One row per person who can sign in to the instance, keyed by unique email; created by password sign-up, OTP sign-in, OAuth sign-up or the install wizard.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
updated_at | timestamp(3) with time zone | yes | Last write time; the ORM sets it to now() on every update. |
name | varchar(255) | no | Optional display name copied at creation from the OAuth profile or the OTP sign-in form (1-255 chars); absent on password sign-up and never edited later. |
email | varchar(255) | yes | Unique sign-in address, trimmed at write; the identity that accounts, sessions, OTP flows and invitation accepts are matched against. |
role | text | yes | Instance role user, admin or superadmin; sign-ups get user, the install wizard mints the one superadmin, and admins bypass org grants. |
time_zone | varchar(64) | no | IANA zone (from the supported list) in which quiet hours on the personal channels of this user are read; NULL means UTC. |
is_email_verified | boolean | yes | True once the address is proven: set at creation by OTP or OAuth sign-up and the install wizard, or later by the verify-email link and OTP routes. |
is_2fa_enabled | boolean | yes | Derived flag kept in step with the totp row: set true when TOTP enrolment is verified and false when two-factor is disabled. |
is_disabled | boolean | yes | Sign-in gate read by every authn path (password, OTP, passkey, OAuth) and refused with account_disabled; no control-plane route writes it today. |
is_all_organizations_notified | boolean | yes | An administrator chose to hear every organization, not only those they belong to; their own preferences still decide what arrives. |
verification
Short-lived email verification tokens and OTP verifiers keyed by unique identifier; rows are upserted per purpose and deleted or left to expire on use.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
updated_at | timestamp(3) with time zone | yes | Last write time; the ORM sets it to now() on every update. |
expires_at | timestamp(3) with time zone | yes | Hard expiry compared at read: 24 h for verify-email links, 300 s for OTPs and their attempt counters; expired rows are ignored and replaced. |
identifier | varchar(255) | yes | Lookup key: the bare email for verify-email links, otp:TYPE:sha256(email) for an OTP and otp-attempts:TYPE:sha256(email) for its attempt counter. |
value | text | yes | Never the raw secret: SHA-256 hex of the link token, a keyed HMAC envelope tpotp.vN.hex for an OTP, or the decimal failed-attempt count. |
Last updated on