Secrets¶
rn_forge.commons.integration.secrets
¶
Secret-access protocols: fail fast on a missing secret, never on a silent default.
Missing keys raise :class:SecretNotFound; they never return None and risk
silently substituting an insecure default.
AsyncSecretStore
¶
EnvSecretStore(*, prefix='')
¶
Reads secrets from the process environment. The local/dev default.
get_secret("db-password") reads DB_PASSWORD — the key is
upper-cased, - is replaced with _, and prefix (upper-cased, with
a trailing _ if not already present) is prepended.
Initialize :class:EnvSecretStore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prefix
|
str
|
Prepended to every environment variable name looked up,
e.g. |
''
|
get_secret(key)
¶
Return the environment variable value mapped from key.
Raises:
| Type | Description |
|---|---|
SecretNotFound
|
The mapped environment variable is unset or blank. |
SecretNotFound(message, *message_args, error_code=-1, **error_data)
¶
Bases: AppException
The named secret does not exist in the backing store.
check(value, message, *message_args, **kwargs)
classmethod
¶
Raise this exception if value is falsy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to test. |
required |
message
|
str
|
Exception message (supports positional format args). |
required |
*message_args
|
Any
|
Forwarded to |
()
|
**kwargs
|
Any
|
Forwarded as |
{}
|
Example::
AppException.check(path.exists(), "Missing file: {}", path, error_code=404)