pub struct BasicAuthBuilder { /* private fields */ }
Expand description
Builder for BasicAuth, provides extra convenience methods
Implementations§
Source§impl BasicAuthBuilder
impl BasicAuthBuilder
Sourcepub fn user<U: Into<String>, P: Into<String>>(
self,
username: U,
password: P,
) -> Self
pub fn user<U: Into<String>, P: Into<String>>( self, username: U, password: P, ) -> Self
Add a single user
Sourcepub fn users_from_iter<I, U, P>(self, users: I) -> Self
pub fn users_from_iter<I, U, P>(self, users: I) -> Self
Add users from iterator
Sourcepub fn users_from_file<P: AsRef<Path>>(self, path: P) -> AuthResult<Self>
pub fn users_from_file<P: AsRef<Path>>(self, path: P) -> AuthResult<Self>
Load users from file (format: username:password, one per line)
Sourcepub fn validator(self, validator: Arc<dyn UserValidator>) -> Self
pub fn validator(self, validator: Arc<dyn UserValidator>) -> Self
Set custom validator
Sourcepub fn case_sensitive(self, sensitive: bool) -> Self
pub fn case_sensitive(self, sensitive: bool) -> Self
Set username case sensitivity
Sourcepub fn with_cache(self, config: CacheConfig) -> Self
pub fn with_cache(self, config: CacheConfig) -> Self
Enable authentication cache
Sourcepub fn disable_cache(self) -> Self
pub fn disable_cache(self) -> Self
Disable authentication cache
Sourcepub fn cache_ttl_seconds(self, seconds: u64) -> Self
pub fn cache_ttl_seconds(self, seconds: u64) -> Self
Set cache TTL (seconds)
Sourcepub fn cache_ttl_minutes(self, minutes: u64) -> Self
pub fn cache_ttl_minutes(self, minutes: u64) -> Self
Set cache TTL (minutes, convenience)
Sourcepub fn cache_ttl_hours(self, hours: u64) -> Self
pub fn cache_ttl_hours(self, hours: u64) -> Self
Set cache TTL (hours, convenience)
Sourcepub fn cache_size_limit(self, limit: usize) -> Self
pub fn cache_size_limit(self, limit: usize) -> Self
Set cache size limit
Sourcepub fn path_filter(self, filter: PathFilter) -> Self
pub fn path_filter(self, filter: PathFilter) -> Self
Set path filter
Sourcepub fn configure_paths<F>(self, configure: F) -> Self
pub fn configure_paths<F>(self, configure: F) -> Self
Configure path filter (builder pattern)
Sourcepub fn skip_paths<I, P>(self, paths: I) -> Self
pub fn skip_paths<I, P>(self, paths: I) -> Self
Add skip paths (convenience)
Sourcepub fn max_header_size(self, size: usize) -> Self
pub fn max_header_size(self, size: usize) -> Self
Set request header size limit
Sourcepub fn log_failures(self, enabled: bool) -> Self
pub fn log_failures(self, enabled: bool) -> Self
Enable authentication failure logging
Sourcepub fn max_concurrent_validations(self, max: usize) -> Self
pub fn max_concurrent_validations(self, max: usize) -> Self
Set maximum concurrent validations
Sourcepub fn validation_timeout(self, timeout: Duration) -> Self
pub fn validation_timeout(self, timeout: Duration) -> Self
Set validation timeout
Sourcepub fn rate_limit_per_ip(self, max_requests: usize, window: Duration) -> Self
pub fn rate_limit_per_ip(self, max_requests: usize, window: Duration) -> Self
Set rate limiting per IP
Sourcepub fn enable_metrics(self, enabled: bool) -> Self
pub fn enable_metrics(self, enabled: bool) -> Self
Enable or disable metrics collection
Sourcepub fn log_usernames_in_production(self, enabled: bool) -> Self
pub fn log_usernames_in_production(self, enabled: bool) -> Self
Enable or disable logging usernames in production (security risk)
Sourcepub fn build(self) -> AuthResult<BasicAuth>
pub fn build(self) -> AuthResult<BasicAuth>
Build BasicAuth instance
Sourcepub fn try_build(self) -> AuthResult<BasicAuth>
pub fn try_build(self) -> AuthResult<BasicAuth>
Build and wrap error handling