Module auth_modular

Module auth_modular 

Source
Expand description

Modular authentication framework with component-based architecture.

This module provides a modular approach to authentication and authorization, allowing fine-grained control over individual components while maintaining the same high-level API as the main AuthFramework.

§Architecture

The modular framework separates concerns into distinct managers:

  • MFA Manager: Multi-factor authentication coordination
  • Session Manager: Session lifecycle and security
  • User Manager: User account and profile management
  • Token Manager: JWT token creation and validation
  • Permission Checker: Authorization and access control

§Benefits of Modular Design

  • Composability: Use only the components you need
  • Testability: Test individual components in isolation
  • Extensibility: Replace or extend specific managers
  • Memory Efficiency: Reduced memory footprint for specialized use cases
  • Performance: Optimized component interactions

§Component Independence

Each manager can operate independently while sharing common storage and configuration. This allows for:

  • Microservice deployment patterns
  • Custom authentication flows
  • Progressive feature adoption
  • A/B testing of authentication methods

§Example

use auth_framework::auth_modular::AuthFramework;
use auth_framework::config::AuthConfig;

// Create modular framework
let config = AuthConfig::default();
let auth = AuthFramework::new(config);

// Access individual managers
let mfa_manager = auth.mfa_manager();
let session_manager = auth.session_manager();
let user_manager = auth.user_manager();

§Migration from Monolithic Framework

The modular framework maintains API compatibility with the main framework, making migration straightforward while providing additional flexibility.

Re-exports§

pub use mfa::MfaManager;
pub use session_manager::SessionManager;
pub use user_manager::UserInfo;
pub use user_manager::UserManager;

Modules§

mfa
Multi-Factor Authentication management module.
session_manager
Session management module
user_manager
User management module

Structs§

AuthFramework
Main authentication framework - now focused and modular
AuthStats
Authentication framework statistics

Enums§

AuthResult
Result of an authentication attempt