pub struct BetterAuth<DB: DatabaseAdapter> { /* private fields */ }Expand description
The main BetterAuth instance, generic over the database adapter.
Implementations§
Source§impl<DB: DatabaseAdapter> BetterAuth<DB>
impl<DB: DatabaseAdapter> BetterAuth<DB>
Sourcepub fn new(config: AuthConfig) -> AuthBuilder
pub fn new(config: AuthConfig) -> AuthBuilder
Create a new BetterAuth builder.
Sourcepub async fn handle_request(&self, req: AuthRequest) -> AuthResult<AuthResponse>
pub async fn handle_request(&self, req: AuthRequest) -> AuthResult<AuthResponse>
Handle an authentication request.
Errors from plugins and core handlers are automatically converted
into standardized JSON responses via AuthError::into_response,
producing { "message": "..." } with the appropriate HTTP status code.
Sourcepub fn config(&self) -> &AuthConfig
pub fn config(&self) -> &AuthConfig
Get the configuration.
Sourcepub fn session_manager(&self) -> &SessionManager<DB>
pub fn session_manager(&self) -> &SessionManager<DB>
Get the session manager.
Sourcepub fn routes(&self) -> Vec<(String, &dyn AuthPlugin<DB>)>
pub fn routes(&self) -> Vec<(String, &dyn AuthPlugin<DB>)>
Get all routes from plugins.
Sourcepub fn plugins(&self) -> &[Box<dyn AuthPlugin<DB>>]
pub fn plugins(&self) -> &[Box<dyn AuthPlugin<DB>>]
Get all plugins.
Sourcepub fn get_plugin(&self, name: &str) -> Option<&dyn AuthPlugin<DB>>
pub fn get_plugin(&self, name: &str) -> Option<&dyn AuthPlugin<DB>>
Get plugin by name.
Sourcepub fn plugin_names(&self) -> Vec<&'static str>
pub fn plugin_names(&self) -> Vec<&'static str>
List all plugin names.
Sourcepub fn openapi_spec(&self) -> OpenApiSpec
pub fn openapi_spec(&self) -> OpenApiSpec
Generate the OpenAPI spec for all registered routes.
Auto Trait Implementations§
impl<DB> Freeze for BetterAuth<DB>
impl<DB> !RefUnwindSafe for BetterAuth<DB>
impl<DB> Send for BetterAuth<DB>
impl<DB> Sync for BetterAuth<DB>
impl<DB> Unpin for BetterAuth<DB>
impl<DB> UnsafeUnpin for BetterAuth<DB>
impl<DB> !UnwindSafe for BetterAuth<DB>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more