Skip to main content

Module plugin_prelude

Module plugin_prelude 

Source
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’.
AuthError
The one error type every endpoint, hook and extractor returns. It leaves the server as { "code": "...", "message": "..." } with status.
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.
ColumnDef
One column. Built with const fns so Fields and Model impls can return &'static [ColumnDef].
Ctx
The per-request context. Cheap to clone; hooks and event handlers get their own copy.
DecodeError
Empty
An empty input or output: {}.
Fresh
Like Authenticated, plus 403 SESSION_NOT_FRESH when the session is older than fresh_age.
Hash
SHA-256 digest. Stored instead of tokens.
HeaderMap
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 from ctx.new_id().
Json
A JSON column holding T.
Limit
MaybeAuthenticated
ctx.session() returns Option<&SessionView>.
Method
The Request Method (VERB)
NewAccount
An account to create with a user or link to one.
NewUser
A user to create.
OffsetDateTime
A PlainDateTime with a UtcOffset.
PluginBuilder
What Plugin::init (and Builder::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.
SchemaBuilder
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.
SessionView
A session as endpoints and plugins see it.
SignInAttempt
The sign-in a gate is judging.
StatusCode
An HTTP status code (status-code in RFC 9110 et al.).
User
The core columns of user. Plugin and app columns live on the same row; read them from AuthUser (typed) or UserView::fields (inside plugins).
UserView
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. identifier says 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.
ColumnType
DefaultValue
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.
SignInResult
Value
A single database value as it crosses the adapter boundary.

Traits§

Adapter
AuthInstance
What integrations and plugin extension traits need from an auth instance, without naming its type parameters.
ColumnValue
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.
ErrorCodes
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 (user or session). The app’s .user_fields::<U>() and each plugin’s UserFields/SessionFields implement it. #[derive(Fields)] writes this.
HasPlugin
For plugin extension traits: methods bounded by Self: HasPlugin<MyPlugin, I> only compile on an Auth that 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; Fields point at the table they extend, so TwoFactorUser::TWO_FACTOR_ENABLED can filter find::<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.
SessionResolver
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 SignedDuration under its original name.
HookCtx
The context hooks, gates and event handlers get.

Derive Macros§

AuthError
Implements From<E> for AuthError and ErrorCodes for an enum of plugin errors.
Deserialize
Fields
Implements Fields and OnTable for a struct of columns added to an existing table, plus a typed Col constant per field (two_factor_enabled becomes TWO_FACTOR_ENABLED).
Model
Implements Model and OnTable<Table = Self> for a table, plus a typed Col constant per field.
Serialize