pub struct AllowThemBuilder { /* private fields */ }Expand description
Builder for constructing a configured AllowThem handle.
Implementations§
Source§impl AllowThemBuilder
impl AllowThemBuilder
Sourcepub fn new(url: impl Into<String>) -> Self
pub fn new(url: impl Into<String>) -> Self
Start building from a database URL.
At build time, calls Db::connect(url) which creates the pool,
sets pragmas (foreign_keys, WAL, busy_timeout), and runs migrations.
Sourcepub fn with_pool(pool: SqlitePool) -> Self
pub fn with_pool(pool: SqlitePool) -> Self
Start building from an existing pool.
At build time, calls Db::new(pool) which runs migrations.
The caller is responsible for pragma configuration on their pool.
Sourcepub fn session_ttl(self, ttl: Duration) -> Self
pub fn session_ttl(self, ttl: Duration) -> Self
Override session TTL. Default: 24 hours.
Override session cookie name. Default: "allowthem_session".
Set the Secure attribute on session cookies.
Default: true. Set to false for local development over HTTP.
Set the Domain attribute on session cookies.
Default: empty (omitted). When set, the cookie is sent to the domain and all its subdomains.
Sourcepub fn mfa_key(self, key: [u8; 32]) -> Self
pub fn mfa_key(self, key: [u8; 32]) -> Self
Set the AES-256-GCM encryption key for MFA secrets.
When not set, all MFA operations return AuthError::MfaNotConfigured.
This keeps MFA opt-in for embedded integrators who don’t need it.
Sourcepub fn signing_key(self, key: [u8; 32]) -> Self
pub fn signing_key(self, key: [u8; 32]) -> Self
Set the AES-256-GCM encryption key for RS256 signing key storage.
Required for OIDC/standalone mode. When not set, all signing key
operations return AuthError::SigningKeyNotConfigured.
Sourcepub fn base_url(self, url: impl Into<String>) -> Self
pub fn base_url(self, url: impl Into<String>) -> Self
Set the base URL (issuer) for the OIDC provider.
Required for standalone mode. Used as the iss claim in tokens
and for issuer validation on incoming access tokens.
When not set, OIDC operations return AuthError::BaseUrlNotConfigured.
Sourcepub fn csrf_key(self, key: [u8; 32]) -> Self
pub fn csrf_key(self, key: [u8; 32]) -> Self
Set the HMAC key for session-bound CSRF token derivation.
Required for csrf_middleware in crates/server. If not set,
csrf_middleware returns 500. Use 32 random bytes distinct from
mfa_key and signing_key.
Sourcepub fn on_user_active(self, callback: OnUserActive) -> Self
pub fn on_user_active(self, callback: OnUserActive) -> Self
Register a callback invoked after every active authentication event.
“Active” means: successful password login, OAuth callback completion, MFA/TOTP completion, and OIDC access token issuance (authorization code exchange). Session validation, token refresh, and API token checks do not fire the callback.
The callback must not block. Use a channel-send if heavy work is needed.
Panics inside the callback are caught, logged via tracing::error!, and
never propagated to the caller.
Primarily used by the SaaS binary to record MAU into the control plane.
Sourcepub fn email_sender(self, sender: Box<dyn EmailSender>) -> Self
pub fn email_sender(self, sender: Box<dyn EmailSender>) -> Self
Register the email sender used by every email-bearing flow (password reset, email verification, invitations, MFA recovery).
Default is NoopEmailSender, which silently drops messages — call
this method for any production deployment. A tracing::warn! is
emitted at build time if the default is left in place.
Email flows that compose URLs (send_password_reset_email,
send_verification_email) also require base_url to be set.
Sourcepub fn event_sink(self, sink: Box<dyn EventSink>) -> Self
pub fn event_sink(self, sink: Box<dyn EventSink>) -> Self
Register the event sink that fires for every state-changing auth operation.
Default is NoopEventSink (silent). The SaaS binary will register a
sink that writes rows to webhook_deliveries for outbound HTTP delivery
(epic 7xw.2). Embedded integrators that do not need webhook delivery can
leave this unset.
Auto Trait Implementations§
impl Freeze for AllowThemBuilder
impl !RefUnwindSafe for AllowThemBuilder
impl Send for AllowThemBuilder
impl Sync for AllowThemBuilder
impl Unpin for AllowThemBuilder
impl UnsafeUnpin for AllowThemBuilder
impl !UnwindSafe for AllowThemBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more