Struct BasicAuthBuilder

Source
pub struct BasicAuthBuilder { /* private fields */ }
Expand description

Builder for BasicAuth, provides extra convenience methods

Implementations§

Source§

impl BasicAuthBuilder

Source

pub fn new() -> Self

Create a new BasicAuthBuilder instance

Source

pub fn user<U: Into<String>, P: Into<String>>( self, username: U, password: P, ) -> Self

Add a single user

Source

pub fn users(self, users: HashMap<String, String>) -> Self

Add multiple users from HashMap

Source

pub fn users_from_iter<I, U, P>(self, users: I) -> Self
where I: IntoIterator<Item = (U, P)>, U: Into<String>, P: Into<String>,

Add users from iterator

Source

pub fn users_from_file<P: AsRef<Path>>(self, path: P) -> AuthResult<Self>

Load users from file (format: username:password, one per line)

Source

pub fn validator(self, validator: Arc<dyn UserValidator>) -> Self

Set custom validator

Source

pub fn realm<R: Into<String>>(self, realm: R) -> Self

Set authentication realm

Source

pub fn case_sensitive(self, sensitive: bool) -> Self

Set username case sensitivity

Source

pub fn with_cache(self, config: CacheConfig) -> Self

Enable authentication cache

Source

pub fn disable_cache(self) -> Self

Disable authentication cache

Source

pub fn cache_ttl_seconds(self, seconds: u64) -> Self

Set cache TTL (seconds)

Source

pub fn cache_ttl_minutes(self, minutes: u64) -> Self

Set cache TTL (minutes, convenience)

Source

pub fn cache_ttl_hours(self, hours: u64) -> Self

Set cache TTL (hours, convenience)

Source

pub fn cache_size_limit(self, limit: usize) -> Self

Set cache size limit

Source

pub fn path_filter(self, filter: PathFilter) -> Self

Set path filter

Source

pub fn configure_paths<F>(self, configure: F) -> Self

Configure path filter (builder pattern)

Source

pub fn skip_paths<I, P>(self, paths: I) -> Self
where I: IntoIterator<Item = P>, P: Into<String>,

Add skip paths (convenience)

Source

pub fn max_header_size(self, size: usize) -> Self

Set request header size limit

Source

pub fn log_failures(self, enabled: bool) -> Self

Enable authentication failure logging

Source

pub fn max_concurrent_validations(self, max: usize) -> Self

Set maximum concurrent validations

Source

pub fn validation_timeout(self, timeout: Duration) -> Self

Set validation timeout

Source

pub fn rate_limit_per_ip(self, max_requests: usize, window: Duration) -> Self

Set rate limiting per IP

Source

pub fn enable_metrics(self, enabled: bool) -> Self

Enable or disable metrics collection

Source

pub fn log_usernames_in_production(self, enabled: bool) -> Self

Enable or disable logging usernames in production (security risk)

Source

pub fn build(self) -> AuthResult<BasicAuth>

Build BasicAuth instance

Source

pub fn try_build(self) -> AuthResult<BasicAuth>

Build and wrap error handling

Trait Implementations§

Source§

impl Default for BasicAuthBuilder

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> 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, 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<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