Skip to main content

AuthxConfig

Struct AuthxConfig 

Source
pub struct AuthxConfig {
Show 21 fields pub bind: String, pub database_url: Option<String>, pub secure_cookies: bool, pub session_ttl_secs: i64, pub trusted_origins: Vec<String>, pub rate_limit_max: u32, pub rate_limit_window: Duration, pub lockout_max_failures: u32, pub lockout_window: Duration, pub encryption_key_hex: Option<String>, pub oidc_issuer: Option<String>, pub oidc_access_token_ttl_secs: i64, pub oidc_id_token_ttl_secs: i64, pub oidc_refresh_token_ttl_secs: i64, pub oidc_auth_code_ttl_secs: i64, pub oidc_device_code_ttl_secs: i64, pub oidc_device_code_interval_secs: u32, pub oidc_verification_uri: Option<String>, pub webauthn_rp_id: String, pub webauthn_rp_origin: String, pub webauthn_challenge_ttl_secs: u64,
}
Expand description

Central configuration for authx-rs services.

All fields carry sensible defaults. Use AuthxConfig::from_env to override any field via environment variables (prefix AUTHX_), or construct directly.

Fields§

§bind: String

Bind address (e.g. 0.0.0.0:3000).

§database_url: Option<String>

Database URL. None ⇒ in-memory store.

§secure_cookies: bool

Enable HTTPS-only cookies.

§session_ttl_secs: i64

Session TTL in seconds (default: 30 days).

§trusted_origins: Vec<String>

Trusted origins for CSRF validation (comma-separated in env).

§rate_limit_max: u32

Max requests per rate-limit window on auth routes.

§rate_limit_window: Duration

Rate-limit window duration.

§lockout_max_failures: u32

Number of failures before lockout.

§lockout_window: Duration

Lockout window duration.

§encryption_key_hex: Option<String>

32-byte hex-encoded encryption key for OAuth/federation tokens. None ⇒ random key generated at startup (tokens won’t survive restart).

§oidc_issuer: Option<String>

Issuer URL for the built-in OIDC provider.

§oidc_access_token_ttl_secs: i64

Access token TTL in seconds.

§oidc_id_token_ttl_secs: i64

ID token TTL in seconds.

§oidc_refresh_token_ttl_secs: i64

Refresh token TTL in seconds.

§oidc_auth_code_ttl_secs: i64

Authorization code TTL in seconds.

§oidc_device_code_ttl_secs: i64

Device code TTL in seconds.

§oidc_device_code_interval_secs: u32

Device code poll interval in seconds.

§oidc_verification_uri: Option<String>

Verification URI for device flow.

§webauthn_rp_id: String

Relying party ID (RP ID), usually the effective domain.

§webauthn_rp_origin: String

Allowed origin for WebAuthn ceremonies.

§webauthn_challenge_ttl_secs: u64

Challenge TTL in seconds for begin/finish ceremony pairing.

Implementations§

Source§

impl AuthxConfig

Source

pub fn from_env() -> Self

Load configuration from environment variables with AUTHX_ prefix.

Every field falls back to Default when its env var is absent.

FieldEnv var
bindAUTHX_BIND
database_urlDATABASE_URL
secure_cookiesAUTHX_SECURE_COOKIES
session_ttl_secsAUTHX_SESSION_TTL
trusted_originsAUTHX_TRUSTED_ORIGINS (comma)
rate_limit_maxAUTHX_RATE_LIMIT
rate_limit_windowAUTHX_RATE_LIMIT_WINDOW_SECS
lockout_max_failuresAUTHX_LOCKOUT_FAILURES
lockout_windowAUTHX_LOCKOUT_MINUTES
encryption_key_hexAUTHX_ENCRYPTION_KEY
oidc_issuerAUTHX_OIDC_ISSUER
oidc_*_ttl_secsAUTHX_OIDC_ACCESS_TOKEN_TTL etc.
webauthn_rp_idAUTHX_WEBAUTHN_RP_ID
webauthn_rp_originAUTHX_WEBAUTHN_RP_ORIGIN
webauthn_challenge_ttl_secsAUTHX_WEBAUTHN_CHALLENGE_TTL
Source

pub fn encryption_key(&self) -> [u8; 32]

Parse the 32-byte encryption key from hex, or generate a random one.

Trait Implementations§

Source§

impl Clone for AuthxConfig

Source§

fn clone(&self) -> AuthxConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AuthxConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AuthxConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more