Configuration Guide
Relevant source files
The following files were used as context for generating this wiki page:
The FLEXT Auth configuration system provides a robust, type-safe framework for managing enterprise authentication and authorization settings. It utilizes Pydantic-based models to enforce validation rules, ensure security constraints, and provide a single source of truth for the authentication service. The configuration layer integrates deeply with flext-core to maintain consistency across the platform.
Sources: src/flext_auth/history.json, pyproject.toml:13-20, tests/unit/test_config.py:22-30
Configuration Architecture
The configuration system is centered around FlextAuthSettings, which manages global and instance-specific parameters for JWT generation, password hashing, and session management. It is designed to be loaded via environment variables or explicitly passed during the initialization of the FlextAuth facade.
The diagram above illustrates the flow of configuration data from the environment and domain constants into the settings object, which then drives the primary authentication services.
Sources: src/flext_auth/history.json, examples/basic_usage_flows.py:20-30, tests/unit/test_config.py:22-35
Key Configuration Parameters
Configuration is categorized into logical namespaces, primarily managed through FlextAuthConstants. These constants define the defaults and validation limits for the entire system.
Authentication & Token Settings
These parameters control the lifecycle and security of JSON Web Tokens (JWT).
| Parameter | Type | Default Value | Description |
|---|---|---|---|
DEFAULT_JWT_ALGORITHM | str | "HS256" | Hashing algorithm for token signatures |
DEFAULT_JWT_EXPIRY_MINUTES | int | 1440 | Expiration time for access tokens |
ISSUER_CLAIM | str | "flext-auth" | The 'iss' claim for generated tokens |
MIN_SECRET_KEY_LENGTH | int | 32 | Minimum length for the JWT secret key |
Sources: src/flext_auth/history.json
Security & Password Constraints
FLEXT Auth enforces strict validation on credentials and security events to mitigate brute-force attacks.
| Option | Type | Default | Description |
|---|---|---|---|
HASH_ROUNDS_DEFAULT | int | 12 | Default bcrypt rounds for password hashing |
MAX_LOGIN_ATTEMPTS | int | 5 | Attempts before account lockout |
LOCKOUT_DURATION_MINUTES | int | 15 | Duration of an automated account lockout |
MIN_PASSWORD_LENGTH | int | 8 | Minimum characters required for passwords |
Sources: src/flext_auth/history.json
Implementation Patterns
Global Settings Management
The system supports a singleton-like pattern for fetching global settings while allowing for model cloning to support environment-specific overrides.
# Fetching the global instance
settings = FlextAuthSettings.fetch_global()
# Creating a customized clone for specific test or environment cases
custom_settings = settings.clone(
expiry_minutes=60,
hash_rounds=14
)
Sources: tests/unit/test_config.py:35-50
Configuration Validation Flow
When initializing the service, the configuration is validated against FlextAuthConstants to ensure the runtime environment meets security requirements.
The sequence diagram demonstrates the validation handshake between the settings model and the domain constants.
Sources: src/flext_auth/history.json, tests/unit/test_config.py:52-58
Integration with Facade Classes
The FlextAuth class acts as the primary consumer of these configurations. If no settings are provided during instantiation, it defaults to the global settings derived from environment variables prefixed with the project standard.
# Basic initialization using default settings
auth = FlextAuth()
# Advanced initialization with custom settings
custom_settings = FlextAuthSettings(expiry_minutes=30)
auth = FlextAuth(settings=custom_settings)
Sources: examples/advanced_features_02.py:27-30, tests/unit/test_config.py:65-70
Conclusion
The FLEXT Auth configuration system ensures that enterprise security standards are enforced at the code level. By centralizing validation limits and defaults in FlextAuthConstants and providing a type-safe interface through FlextAuthSettings, the project maintains a zero-debt baseline for security parameters while remaining flexible for various deployment environments.