Plugin and configuration¶
Public plugin facade and configuration dataclasses exported from litestar_auth.plugin, plus shared configuration helpers from litestar_auth.config.
litestar_auth.plugin
¶
Litestar plugin/orchestrator facade for wiring the auth library into an app.
LitestarAuth(config)
¶
Bases: InitPlugin
Main auth orchestrator that wires middleware, controllers, and DI.
Store the plugin configuration and validate the requested setup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
LitestarAuthConfig[UP, ID]
|
Fully specified plugin configuration (session factory, backends, user manager factory, optional OAuth/TOTP settings). |
required |
Source code in litestar_auth/plugin.py
on_app_init(app_config)
¶
Register auth middleware, controllers, and dependencies on the app.
Returns:
| Type | Description |
|---|---|
AppConfig
|
The updated application config. |
Source code in litestar_auth/plugin.py
litestar_auth.config
¶
Central configuration helpers for litestar-auth.
This module contains small, shared primitives used across the library to keep security-relevant validation consistent (e.g. secret length requirements and testing-mode toggles).
is_pytest_runtime()
¶
is_testing()
¶
require_password_length(password, minimum_length=DEFAULT_MINIMUM_PASSWORD_LENGTH, *, maximum_length=MAX_PASSWORD_LENGTH)
¶
Raise when a password falls outside the configured length bounds.
The default minimum_length matches the password-length metadata exposed
for app-owned user schemas via litestar_auth.schemas.UserPasswordField.
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in litestar_auth/config.py
resolve_trusted_proxy_setting(*, trusted_proxy)
¶
Validate and normalize trusted-proxy configuration flags.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
trusted_proxy
|
object
|
Candidate trusted-proxy value from configuration. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
Normalized trusted-proxy boolean. |
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
If |
Source code in litestar_auth/config.py
validate_secret_length(secret, *, label, minimum_length=MINIMUM_SECRET_LENGTH)
¶
Validate the configured secret length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
secret
|
str
|
Secret value to validate. |
required |
label
|
str
|
Human-readable label used in error messages. |
required |
minimum_length
|
int
|
Minimum length in characters. |
MINIMUM_SECRET_LENGTH
|
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
When |
Source code in litestar_auth/config.py
validate_testing_mode_for_startup()
¶
Fail fast when testing mode is enabled outside pytest runtimes.
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
When |