pub struct AuthBuilder { /* private fields */ }Expand description
Main builder for constructing an AuthFramework instance.
Start with AuthFramework::builder() and chain sub-builders for
JWT, storage, security, rate limiting, and audit configuration.
§Example
use auth_framework::prelude::*;
let auth = AuthFramework::builder()
.with_jwt().secret("my-secret-key-that-is-long-enough!!").issuer("myapp").done()
.with_storage().memory().done()
.security_preset(SecurityPreset::Balanced)
.build().await?;Implementations§
Source§impl AuthBuilder
impl AuthBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new builder with default configuration.
§Example
use auth_framework::builders::AuthBuilder;
let builder = AuthBuilder::new();Sourcepub fn security_preset(self, preset: SecurityPreset) -> Self
pub fn security_preset(self, preset: SecurityPreset) -> Self
Apply a security preset.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.security_preset(SecurityPreset::HighSecurity);Sourcepub fn performance_preset(self, preset: PerformancePreset) -> Self
pub fn performance_preset(self, preset: PerformancePreset) -> Self
Apply a performance preset.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.performance_preset(PerformancePreset::LowLatency);Sourcepub fn use_case_preset(self, preset: UseCasePreset) -> Self
pub fn use_case_preset(self, preset: UseCasePreset) -> Self
Apply a use case preset.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.use_case_preset(UseCasePreset::WebApp);Sourcepub fn with_jwt(self) -> JwtBuilder
pub fn with_jwt(self) -> JwtBuilder
Configure JWT authentication.
Returns a JwtBuilder sub-builder. Call .done() to return.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.with_jwt().secret("my-long-secret-key-32-chars-min!!").done();Sourcepub fn with_oauth2(self) -> OAuth2Builder
pub fn with_oauth2(self) -> OAuth2Builder
Configure OAuth2 authentication.
Returns an OAuth2Builder sub-builder. Call .done() to return.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.with_oauth2().client_id("id").client_secret("secret").done();Sourcepub fn with_storage(self) -> StorageBuilder
pub fn with_storage(self) -> StorageBuilder
Configure storage backend.
Returns a StorageBuilder sub-builder. Call .done() to return.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.with_storage().memory().done();Sourcepub fn with_rate_limiting(self) -> RateLimitBuilder
pub fn with_rate_limiting(self) -> RateLimitBuilder
Configure rate limiting.
Returns a RateLimitBuilder sub-builder. Call .done() to return.
§Example
use auth_framework::prelude::*;
use std::time::Duration;
let builder = AuthFramework::builder()
.with_rate_limiting().per_ip((200, Duration::from_secs(60))).done();Sourcepub fn with_security(self) -> SecurityBuilder
pub fn with_security(self) -> SecurityBuilder
Configure security settings.
Returns a SecurityBuilder sub-builder. Call .done() to return.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.with_security().min_password_length(12).secure_cookies(true).done();Sourcepub fn with_audit(self) -> AuditBuilder
pub fn with_audit(self) -> AuditBuilder
Configure audit logging.
Returns an AuditBuilder sub-builder. Call .done() to return.
§Example
use auth_framework::prelude::*;
let builder = AuthFramework::builder()
.with_audit().enabled(true).log_success(true).done();Sourcepub fn customize<F>(self, f: F) -> Self
pub fn customize<F>(self, f: F) -> Self
Customize configuration with a closure.
§Example
use auth_framework::prelude::*;
use std::time::Duration;
let builder = AuthFramework::builder()
.customize(|config| {
config.token_lifetime = Duration::from_secs(7200);
config
});Sourcepub async fn build(self) -> Result<AuthFramework, AuthError>
pub async fn build(self) -> Result<AuthFramework, AuthError>
Build the authentication framework.
Applies presets, validates configuration, initializes storage,
and returns a ready-to-use AuthFramework instance.
§Example
use auth_framework::prelude::*;
let auth = AuthFramework::builder()
.with_jwt().secret("my-long-secret-key-32-chars-min!!").done()
.with_storage().memory().done()
.build().await?;Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuthBuilder
impl !RefUnwindSafe for AuthBuilder
impl Send for AuthBuilder
impl Sync for AuthBuilder
impl Unpin for AuthBuilder
impl UnsafeUnpin for AuthBuilder
impl !UnwindSafe for AuthBuilder
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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