pub struct RustAuthOptions {Show 26 fields
pub app_name: Option<String>,
pub base_url: Option<String>,
pub base_path: Option<String>,
pub secret: Option<String>,
pub secrets: Vec<SecretEntry>,
pub trusted_origins: TrustedOriginOptions,
pub disabled_paths: Vec<String>,
pub session: SessionOptions,
pub user: UserOptions,
pub email_password: EmailPasswordOptions,
pub email_verification: EmailVerificationOptions,
pub password: PasswordOptions,
pub account: AccountOptions,
pub verification: VerificationOptions,
pub hooks: GlobalHooksOptions,
pub on_api_error: OnApiErrorOptions,
pub init_database_hooks: InitDatabaseHooksOptions,
pub database_hooks: Vec<PluginDatabaseHook>,
pub logger: LoggerOptions,
pub advanced: AdvancedOptions,
pub rate_limit: RateLimitOptions,
pub secondary_storage: Option<Arc<dyn SecondaryStorage>>,
pub plugins: Vec<AuthPlugin>,
pub mode: DeploymentMode,
pub telemetry: TelemetryOptions,
pub experimental: ExperimentalOptions,
}Expand description
Top-level RustAuth configuration.
Database hooks can be registered in two ways:
Self::init_database_hooks— structured, init-time hooks for core models (user,session,account,verification) viaInitDatabaseHooksOptions. Prefer this for parity with Better AuthdatabaseHooksand typed create/update callbacks on built-in models.Self::database_hook— append a low-levelPluginDatabaseHookdirectly. Use this for custom models, plugin-owned tables, or hooks that do not fit the init-time schema.
Both paths are merged at runtime; they are not mutually exclusive.
§Deployment mode
Use Self::deployment_mode or the convenience setters Self::production /
Self::development to control whether development-oriented security defaults
are allowed. See DeploymentMode for the full precedence matrix.
Fields§
§app_name: Option<String>§base_url: Option<String>§base_path: Option<String>§secret: Option<String>§secrets: Vec<SecretEntry>§trusted_origins: TrustedOriginOptions§disabled_paths: Vec<String>§session: SessionOptions§user: UserOptions§email_password: EmailPasswordOptions§email_verification: EmailVerificationOptions§password: PasswordOptions§account: AccountOptions§verification: VerificationOptions§hooks: GlobalHooksOptions§on_api_error: OnApiErrorOptions§init_database_hooks: InitDatabaseHooksOptions§database_hooks: Vec<PluginDatabaseHook>§logger: LoggerOptions§advanced: AdvancedOptions§rate_limit: RateLimitOptions§secondary_storage: Option<Arc<dyn SecondaryStorage>>§plugins: Vec<AuthPlugin>§mode: DeploymentMode§telemetry: TelemetryOptions§experimental: ExperimentalOptionsImplementations§
Source§impl RustAuthOptions
impl RustAuthOptions
pub fn new() -> Self
pub fn app_name(self, app_name: impl Into<String>) -> Self
pub fn base_url(self, base_url: impl Into<String>) -> Self
pub fn base_path(self, base_path: impl Into<String>) -> Self
pub fn secret(self, secret: impl Into<String>) -> Self
pub fn secrets(self, secrets: Vec<SecretEntry>) -> Self
pub fn trusted_origins(self, trusted_origins: TrustedOriginOptions) -> Self
Sourcepub fn disabled_path(self, path: impl Into<String>) -> Self
pub fn disabled_path(self, path: impl Into<String>) -> Self
Append one disabled route path.
Sourcepub fn push_disabled_path(self, path: impl Into<String>) -> Self
pub fn push_disabled_path(self, path: impl Into<String>) -> Self
Append one disabled route path (alias for Self::disabled_path).
Sourcepub fn disabled_paths<I, S>(self, paths: I) -> Self
pub fn disabled_paths<I, S>(self, paths: I) -> Self
Replace the full disabled-path list.
Sourcepub fn set_disabled_paths<I, S>(self, paths: I) -> Self
pub fn set_disabled_paths<I, S>(self, paths: I) -> Self
Replace the full disabled-path list (alias for Self::disabled_paths).
pub fn session(self, session: SessionOptions) -> Self
pub fn user(self, user: UserOptions) -> Self
pub fn email_password(self, email_password: EmailPasswordOptions) -> Self
pub fn email_verification( self, email_verification: EmailVerificationOptions, ) -> Self
pub fn password(self, password: PasswordOptions) -> Self
pub fn account(self, account: AccountOptions) -> Self
pub fn verification(self, verification: VerificationOptions) -> Self
pub fn advanced(self, advanced: AdvancedOptions) -> Self
pub fn rate_limit(self, rate_limit: RateLimitOptions) -> Self
pub fn hooks(self, hooks: GlobalHooksOptions) -> Self
pub fn on_api_error(self, on_api_error: OnApiErrorOptions) -> Self
Sourcepub fn init_database_hooks(self, hooks: InitDatabaseHooksOptions) -> Self
pub fn init_database_hooks(self, hooks: InitDatabaseHooksOptions) -> Self
Structured init-time hooks for core models. See RustAuthOptions for when
to prefer this over Self::database_hook.
Sourcepub fn database_hook(self, hook: PluginDatabaseHook) -> Self
pub fn database_hook(self, hook: PluginDatabaseHook) -> Self
Append a low-level database hook (custom models or plugin tables). See
RustAuthOptions for when to prefer Self::init_database_hooks.
pub fn logger(self, logger: LoggerOptions) -> Self
Sourcepub fn secondary_storage(self, storage: Arc<dyn SecondaryStorage>) -> Self
pub fn secondary_storage(self, storage: Arc<dyn SecondaryStorage>) -> Self
Attach secondary storage. The value is already wrapped in Arc.
Sourcepub fn secondary_storage_arc(self, storage: Arc<dyn SecondaryStorage>) -> Self
pub fn secondary_storage_arc(self, storage: Arc<dyn SecondaryStorage>) -> Self
Attach secondary storage (alias for Self::secondary_storage).
Sourcepub fn plugin(self, plugin: AuthPlugin) -> Self
pub fn plugin(self, plugin: AuthPlugin) -> Self
Append one plugin to the options list.
Sourcepub fn push_plugin(self, plugin: AuthPlugin) -> Self
pub fn push_plugin(self, plugin: AuthPlugin) -> Self
Append one plugin (alias for Self::plugin).
Sourcepub fn plugins(self, plugins: Vec<AuthPlugin>) -> Self
pub fn plugins(self, plugins: Vec<AuthPlugin>) -> Self
Append multiple plugins to the options list.
Like chaining .plugin repeatedly. To replace the full
list, use .set_plugins.
Sourcepub fn extend_plugins(self, plugins: Vec<AuthPlugin>) -> Self
pub fn extend_plugins(self, plugins: Vec<AuthPlugin>) -> Self
Append multiple plugins (alias for Self::plugins).
Sourcepub fn set_plugins(self, plugins: Vec<AuthPlugin>) -> Self
pub fn set_plugins(self, plugins: Vec<AuthPlugin>) -> Self
Replace the full plugin list.
Sourcepub fn deployment_mode(self, mode: DeploymentMode) -> Self
pub fn deployment_mode(self, mode: DeploymentMode) -> Self
Set deployment posture explicitly.
Sourcepub fn production(self, production: bool) -> Self
pub fn production(self, production: bool) -> Self
Enable or disable explicit production posture.
Sourcepub fn development(self, development: bool) -> Self
pub fn development(self, development: bool) -> Self
Enable or disable explicit development posture.
Sourcepub fn explicit_production(&self) -> bool
pub fn explicit_production(&self) -> bool
Returns true when options request explicit production API error sanitization.
Sourcepub fn production_error_posture(&self) -> bool
pub fn production_error_posture(&self) -> bool
Returns true when options request explicit production API error sanitization,
or when DeploymentMode::Auto and RUST_ENV=production.
pub fn telemetry(self, telemetry: TelemetryOptions) -> Self
pub fn experimental(self, experimental: ExperimentalOptions) -> Self
Trait Implementations§
Source§impl Clone for RustAuthOptions
impl Clone for RustAuthOptions
Source§fn clone(&self) -> RustAuthOptions
fn clone(&self) -> RustAuthOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more