Expand description
Everything a plugin author needs.
Structs§
- Account
- A way to sign in:
provider_id = "credential"holds the password hash; OAuth providers hold encrypted tokens. - Arc
- A thread-safe reference-counting pointer. ‘Arc’ stands for ‘Atomically Reference Counted’.
- Auth
Error - The one error type every endpoint, hook and extractor returns. It leaves the server as
{ "code": "...", "message": "..." }withstatus. - Authenticated
- 401 without a session;
ctx.session()returns&SessionView. - Col
- A typed column: comparing it with the wrong Rust type, or using it on another table, does not compile.
- Column
Def - One column. Built with const fns so
FieldsandModelimpls can return&'static [ColumnDef]. - Ctx
- The per-request context. Cheap to clone; hooks and event handlers get their own copy.
- Decode
Error - Empty
- An empty input or output:
{}. - Fresh
- Like
Authenticated, plus 403SESSION_NOT_FRESHwhen the session is older thanfresh_age. - Hash
- SHA-256 digest. Stored instead of tokens.
- Header
Map - A specialized multimap for header names and values.
- Id
- A primary or foreign key: an opaque string. fastauth creates ids with the configured
IdStrategy(ULIDs by default); handlers get one fromctx.new_id(). - Json
- A JSON column holding
T. - Limit
- Maybe
Authenticated ctx.session()returnsOption<&SessionView>.- Method
- The Request Method (VERB)
- NewAccount
- An account to create with a user or link to one.
- NewUser
- A user to create.
- Offset
Date Time - A
PlainDateTimewith aUtcOffset. - Plugin
Builder - What
Plugin::init(andBuilder::configure) registers things with. - Public
- No session lookup;
ctx.session()doesn’t exist. - Row
- A row as the adapter returns it: values in the table’s column order.
- Schema
Builder - Collects tables and columns during
.build()and reports clashes with both owners. - Session
- A row of
session. The token itself is never stored, only its SHA-256. - Session
View - A session as endpoints and plugins see it.
- Sign
InAttempt - The sign-in a gate is judging.
- Status
Code - An HTTP status code (
status-codein RFC 9110 et al.). - User
- The core columns of
user. Plugin and app columns live on the same row; read them fromAuthUser(typed) orUserView::fields(inside plugins). - User
View - A user row as plugins see it: core fields typed, everything else in
row. - Verification
- Single-use values: email verification, password reset, OAuth state, OTPs.
identifiersays what the value is for; only the hash of the value is stored. - Where
- A filter on model
M’s table, built from typed columns.
Enums§
- After
- What an after hook decides.
- Before
- What a before hook decides.
- Column
Type - Default
Value - Gate
- What a sign-in gate decides, after credentials check out and before a session exists.
- OnDelete
- Order
- Resolved
- What a session resolver found for a request without a session cookie.
- Sign
InResult - Value
- A single database value as it crosses the adapter boundary.
Traits§
- Adapter
- Auth
Instance - What integrations and plugin extension traits need from an auth instance, without naming its type parameters.
- Column
Value - Rust types that map to one column.
- Deserialize
- A data structure that can be deserialized from any data format supported by Serde.
- Endpoint
- An auth endpoint: a typed function first, an HTTP route second.
- Error
Codes - Lets a plugin register its error codes at build time, so two plugins can’t claim one code.
- Event
- Fields
- A typed view over some columns of an existing table (
userorsession). The app’s.user_fields::<U>()and each plugin’sUserFields/SessionFieldsimplement it.#[derive(Fields)]writes this. - HasPlugin
- For plugin extension traits: methods bounded by
Self: HasPlugin<MyPlugin, I>only compile on anAuththat registered the plugin. - Model
- A table owned by core or a plugin.
#[derive(Model)]writes this. - OnTable
- Which table a typed column lives on. Models point at themselves;
Fieldspoint at the table they extend, soTwoFactorUser::TWO_FACTOR_ENABLEDcan filterfind::<User>. - Plugin
- A fastauth plugin. See
docs/05-plugins.md. - Serialize
- A data structure that can be serialized into any data format supported by Serde.
- Session
Resolver - Turns non-cookie credentials into a session. Tried in registration order.
Functions§
- random_
string - A random string from
alphabet, without modulo bias. - random_
token - 32 random bytes as base64url (43 chars): session tokens, verification values, state.
Type Aliases§
- Duration
- A
SignedDurationunder its original name. - HookCtx
- The context hooks, gates and event handlers get.
Derive Macros§
- Auth
Error - Implements
From<E> for AuthErrorandErrorCodesfor an enum of plugin errors. - Deserialize
- Fields
- Implements
FieldsandOnTablefor a struct of columns added to an existing table, plus a typedColconstant per field (two_factor_enabledbecomesTWO_FACTOR_ENABLED). - Model
- Implements
ModelandOnTable<Table = Self>for a table, plus a typedColconstant per field. - Serialize