Summary: the tables that auth-chad keeps, the types that carry a request through the code, and how a row becomes a write. Key terms: row, table, version, Stored, Write, Decision, Authenticated, Ctx, hash at rest, prefix, feature. Related:Flows · Interfaces · spec 10
auth-chad stores its data in ordinary tables in your database, prefixed with auth_. Each row has a version that
increases with every change, and every write names the version it expects. Tokens, invites and codes are stored as
hashes, and keys are stored as public keys. A copy of the database is therefore not enough to log in.
The current time, the tenant, the config and keys, the caller’s address and device
The adapter, once per request
Stored<T>
A row and its version
The store, on a read
Write
A change with its condition
A flow, or your code
Decision<T>
out and writes
A flow
Authenticated
Who, tenant, level, binding, session, device, last passkey use, scopes
The library only
Refused
A refusal code, sent as {"error": "<code>"}
Extractors and routes
use auth_chad::core::rows::Session;
use auth_chad::core::row::Field;
use auth_chad::core::StoreError;
use auth_chad::{Reader, UserId};
async fn count_sessions<R: Reader>(db: &R, user: UserId) -> Result<usize, StoreError> {
let rows = db.find_by::<Session>("user", user.store()).await?;
Ok(rows.len()) // each item is a Stored<Session>: the row and its version
}
Each table is declared once, with the table! macro in rust/formats/core/src/rows.rs. The SQL for SQLite and
PostgreSQL is generated from that declaration.
User, tenant, session and device IDs are 16 bytes. Your application maps its own IDs to them.
Every tenant-scoped read takes the tenant as an argument. There is no form without it.
The prefix (auth_ by default) is set when the store opens. The SQL text is built once.
Optional tables exist only when the database was migrated with their feature. check_tables refuses to start a
server that needs a feature that the database lacks.
Your own data about people (name, picture, role names) lives in your tables, with the user ID as a plain value.