config
mlflow_secrets_auth.config
¶
Configuration utilities for MLflow secrets auth providers.
This module centralizes environment-driven configuration and safe redaction helpers.
Key env vars
- MLFLOW_SECRETS_ALLOWED_HOSTS: Comma-separated host allowlist.
- MLFLOW_AUTH_HEADER_NAME: Custom header for auth (defaults to "Authorization").
- MLFLOW_SECRETS_LOG_LEVEL: Logging level (defaults to "INFO").
- MLFLOW_SECRETS_AUTH_ENABLE: Comma-separated list of enabled providers.
- MLFLOW_SECRETS_AUTH_ENABLE_
: Per-provider boolean toggle (e.g., AWS_SECRETS_MANAGER).
get_allowed_hosts()
¶
Return the host allowlist from MLFLOW_SECRETS_ALLOWED_HOSTS.
Supports both exact hostnames and wildcard patterns using shell-style globbing.
Examples:
MLFLOW_SECRETS_ALLOWED_HOSTS="mlflow.example.com,.corp.example.com" MLFLOW_SECRETS_ALLOWED_HOSTS="api.prod.com,.staging.com,localhost"
Wildcard patterns
- "*.corp.example.com" matches any subdomain of corp.example.com
- "mlflow.*.com" matches mlflow with any middle component
- "api-*" matches hostnames starting with "api-"
Returns:
Type | Description |
---|---|
list[str] | None
|
A list of hostname patterns, or None if not configured. |
Source code in src/mlflow_secrets_auth/config.py
get_auth_header_name()
¶
Return the configured auth header name.
Defaults to "Authorization" when MLFLOW_AUTH_HEADER_NAME is unset.
Returns:
Type | Description |
---|---|
str
|
Header name as a string. |
Source code in src/mlflow_secrets_auth/config.py
get_env_bool(name, default=False)
¶
Return an environment variable parsed as a boolean.
Recognized truthy values (case-insensitive): {"1", "true", "yes", "on"}.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
bool
|
Fallback when the variable is unset. |
False
|
Returns:
Type | Description |
---|---|
bool
|
Parsed boolean value. |
Source code in src/mlflow_secrets_auth/config.py
get_env_int(name, default)
¶
Return an environment variable parsed as int.
On parsing error or if unset, returns default
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
int
|
Fallback value. |
required |
Returns:
Type | Description |
---|---|
int
|
Parsed integer or |
Source code in src/mlflow_secrets_auth/config.py
get_env_var(name, default=None)
¶
Return an environment variable or a default.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Environment variable name. |
required |
default
|
str | None
|
Value to return if not set. |
None
|
Returns:
Type | Description |
---|---|
str | None
|
The environment value as a string, or |
Source code in src/mlflow_secrets_auth/config.py
get_log_level()
¶
Return the configured log level for secrets auth.
Defaults to "INFO" and uppercases the value for consistency.
Returns:
Type | Description |
---|---|
str
|
Uppercased logging level string (e.g., "INFO", "DEBUG"). |
Source code in src/mlflow_secrets_auth/config.py
is_provider_enabled(provider_name)
¶
Return whether a specific provider is enabled.
Two mechanisms
1) Global list: MLFLOW_SECRETS_AUTH_ENABLE="vault,aws-secrets-manager,azure-key-vault"
2) Per-provider boolean: MLFLOW_SECRETS_AUTH_ENABLE_
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provider_name
|
str
|
Provider slug (case-insensitive), e.g. "vault". |
required |
Returns:
Type | Description |
---|---|
bool
|
True if enabled via either mechanism, False otherwise. |
Source code in src/mlflow_secrets_auth/config.py
mask_secret(value, mask_char=DEFAULT_MASK_CHAR, show_chars=DEFAULT_SHOW_CHARS)
¶
Mask a secret value for safe logging.
Examples:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
Secret value to mask. |
required |
mask_char
|
str
|
Masking character (default '*'). |
DEFAULT_MASK_CHAR
|
show_chars
|
int
|
Number of leading and trailing chars to keep (default 4). |
DEFAULT_SHOW_CHARS
|
Returns:
Type | Description |
---|---|
str
|
Masked representation with the center portion obfuscated. |
Source code in src/mlflow_secrets_auth/config.py
redact_sensitive_data(text)
¶
Redact common credential patterns from text.
Safely handles patterns with different group counts. Intended for logs and messages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
Input string possibly containing sensitive material. |
required |
Returns:
Type | Description |
---|---|
str
|
Redacted string with secrets masked. |