API Reference
Protocols
Section titled “Protocols”AsyncSecretStoreProtocol
Section titled “AsyncSecretStoreProtocol”Async persistent store for sensitive named secret values.
Typical usage
store = await container.resolve(AsyncSecretStoreProtocol)token = await store.get("stripe_api_key")store = await container.resolve(AsyncSecretStoreProtocol)token = await store.get("stripe_api_key")Return the secret value for name, or None if absent.
| Parameter | Type | Description |
|---|---|---|
| `name` | str | Unique secret identifier. |
Return a mapping of name → value for all requested secrets.
| Parameter | Type | Description |
|---|---|---|
| `names` | str | One or more secret names. |
| Type | Description |
|---|---|
| dict[str, str] | Dict containing only the names that were found. |
Write or overwrite a secret value.
| Parameter | Type | Description |
|---|---|---|
| `name` | str | Unique secret identifier. |
| `value` | str | Plaintext secret value. |
Remove a secret. No-op if absent.
| Parameter | Type | Description |
|---|---|---|
| `name` | str | Unique secret identifier. |
RotatableSecretStoreProtocol
Section titled “RotatableSecretStoreProtocol”An ``AsyncSecretStoreProtocol`` that also supports credential rotation and versioned history.
Generate a new value for key, store it as the next version,
and return the resulting VersionedSecret.
Return the value of a specific version, or None if absent.
Return metadata for every known version of key, newest first.
Return the full VersionedSecret for the current (latest) version.
Raises KeyError if key does not exist.
Classes
Section titled “Classes”RotationDecorator
Section titled “RotationDecorator”Wraps a ``RotatableSecretStoreProtocol`` with age-checked automatic rotation.
On get_rotated the decorator checks the current version’s age against
schedule.max_age_seconds. If exceeded it calls rotate on the underlying
store automatically.
After rotation the old version is still served via get_current_version
until the grace period (grace_period_seconds) elapses. The
VersionedSecret returned after rotation has its expires_at field
populated.
Return (value, was_rotated).
If the current version of key is older than max_age_seconds a new
version is generated first. The old version is preserved in a grace
buffer so that callers still see it until the grace period expires.
Return the current version, respecting the grace period.
If key was recently rotated and the grace period has not yet elapsed the old version is returned. Once the grace period expires the new version from the underlying store is served.
Return a warning message if key is approaching its rotation deadline,
or None if no warning is needed.
RotationSchedule
Section titled “RotationSchedule”Policy for automatic rotation of credentials.
SecretAccessedEvent
Section titled “SecretAccessedEvent”A secret value was read.
SecretAccessedHook
Section titled “SecretAccessedHook”Payload fired when a secret value is read.
Attributes: key: The secret key that was accessed.
SecretAuditDecorator
Section titled “SecretAuditDecorator”Wraps a ``RotatableSecretStoreProtocol``, logging all operations via an ``AuditLoggerProtocol``.
Every read, write, delete, and rotation produces an AuditEntry
with the action, the secret name, and a timestamp.
SecretCreatedEvent
Section titled “SecretCreatedEvent”A new secret was stored.
SecretCreatedHook
Section titled “SecretCreatedHook”Payload fired when a new secret is stored.
Attributes: key: The secret key that was created.
SecretDeletedEvent
Section titled “SecretDeletedEvent”A secret was deleted.
SecretDeletedHook
Section titled “SecretDeletedHook”Payload fired when a secret is deleted.
Attributes: key: The secret key that was deleted.
SecretRotatedEvent
Section titled “SecretRotatedEvent”A secret was rotated to a new version.
SecretRotatedHook
Section titled “SecretRotatedHook”Payload fired when a secret is rotated to a new version.
Attributes: key: The secret key that was rotated. new_version: The version number after rotation.
SecretVersion
Section titled “SecretVersion”Lightweight metadata for a single version of a secret.
SecretsConfig
Section titled “SecretsConfig”Top-level configuration for the secrets rotation subsystem.
Attributes:
name: Configuration name.
enabled: Whether the secrets subsystem is enabled.
backend_type: Backend store type ("memory" or "vault").
backend_options: Keyword arguments forwarded to the backend constructor.
max_age_seconds: Maximum age before automatic rotation.
warning_before_seconds: Seconds before expiry to emit rotation warnings.
tenant_id: Optional tenant namespace for multi-tenancy.
audit_actor_id: Actor identifier for audit log entries.
SecretsModule
Section titled “SecretsModule”IoC module for the secrets/credential vault subsystem.
TenantScopedSecretStore
Section titled “TenantScopedSecretStore”Wraps a ``RotatableSecretStoreProtocol``, prefixing all secret names with ``tenant_id/`` to isolate secrets per tenant.
Example
tenant_a_store = TenantScopedSecretStore(store, "tenant_a")await tenant_a_store.set("db_password", "s3cret")# internally stored as "tenant_a/db_password"tenant_a_store = TenantScopedSecretStore(store, "tenant_a")await tenant_a_store.set("db_password", "s3cret")# internally stored as "tenant_a/db_password"VersionedSecret
Section titled “VersionedSecret”A secret value together with its version metadata.
Exceptions
Section titled “Exceptions”SecretAccessError
Section titled “SecretAccessError”Raised when access to a secret is denied.
SecretBackendError
Section titled “SecretBackendError”Raised when the underlying secret backend (e.g. Vault) fails.
SecretConfigError
Section titled “SecretConfigError”Raised when secrets subsystem configuration is invalid.
SecretNotFoundError
Section titled “SecretNotFoundError”Raised when a requested secret does not exist.
SecretRotationError
Section titled “SecretRotationError”Raised when automatic rotation of a secret fails.
SecretsError
Section titled “SecretsError”Base exception for all secrets-domain errors.