aeat.application.auth._certificate_secret_backend module¶
Certificate-secret backend abstraction for named certificate sources.
Before this module, the certificate auth provider’s passphrase came from
exactly one place: the env-only, never-persisted
aeat_certificate_password_secret. That is a single
global secret shared by whichever certificate happens to be active — it cannot
express “the personal certificate uses passphrase A, the apoderado-acme
certificate uses passphrase B” once
_certificate_sources lets an operator register
several named PKCS#12 sources with potentially different passphrases.
CertificateSecretBackend is the typed seam a
per-source secret is read and written through. Two backends are provided:
SecureStorageCertificateSecretBackend(the default) persists the secret through the profile’s own encryptedSecretStore, atSECRETsensitivity (ciphertext at rest, persensitive-financial-data-secure-storage-only). It requires no optional dependency and is scoped by the natural key to the active bucket, so two profiles never see each other’s secrets.KeyringCertificateSecretBackendpersists the secret in the OS keychain via the sameKeyringClientseamKeyringMasterKeyProvideralready uses, so a keychain-preferring operator keeps the certificate passphrase off the encrypted-file substrate entirely.keyringis already a project dependency (seepyproject.toml); this backend is therefore available today, not a scoped follow-up.
Never store a resolved secret in AuthState or
any other persisted workflow-state record — the secret lives ONLY inside
the backend; workflow state at most records which named sources exist,
never their passphrases (sensitive-financial-data-secure-storage-only).
See also
_certificate_sourcesNamed certificate-source registry (path only, no secret) this module’s backend complements.
SecretStoreEncrypted substrate the default backend persists through.
SensitivityClassStorage classification policy used by the secure-storage backend for certificate passphrases.
KeyringClientInjection seam for the OS-keychain operations the keyring backend depends on; mirrored here rather than imported directly so this module does not reach into the master-key package’s internals.
- class CertificateSecretBackendKind(*values)[source]¶
Bases:
StrEnumClosed set of certificate-secret backends a named source may use.
- SECURE_STORAGE¶
- KEYRING¶
- exception CertificateSecretNotFoundError[source]¶
Bases:
ExceptionRaised when no secret is registered for a certificate source.
Bases:
ExceptionRaised when the selected backend cannot currently store or retrieve a secret.
- class CertificateSecretBackend(*args, **kwargs)[source]¶
Bases:
ProtocolTyped seam for reading, writing, and removing a named certificate secret.
Every method is keyed by the certificate source’s registered
name(seename), scoping the secret to that one source. Implementations MUST scope storage to the active profile bucket so two profiles never share a namespace.
- class SecureStorageCertificateSecretBackend(*, bucket_id, store=None)[source]¶
Bases:
objectDefault
CertificateSecretBackendbacked by storage.Persists each certificate passphrase as a
SecretRecordatSECRETsensitivity, scoped tobucket_idvia the natural key. Requires no optional dependency; this is the backend every profile gets without further configuration.- Parameters:
bucket_id (str)
store (SecretStore | None)
- class KeyringCertificateSecretBackend(*, bucket_id)[source]¶
Bases:
objectCertificateSecretBackendbacked bykeyring.Mirrors
KeyringMasterKeyProvider: the active backend is probed before any read or write so the no-opfail.Keyring/null.Keyringplaceholders raiseCertificateSecretBackendUnavailableErrorrather than silently dropping the secret. Every account isf"{bucket_id}:{name}"under one service string, so profiles and sources never collide in the OS keychain namespace.- Parameters:
bucket_id (str)
- certificate_secret_backend(*, bucket_id, kind=CertificateSecretBackendKind.SECURE_STORAGE)[source]¶
Return the
CertificateSecretBackendforkind.SECURE_STORAGEis the default and requires no optional dependency;KEYRINGrequires a usable OS keychain backend and raisesCertificateSecretBackendUnavailableError(via the backend’s own probe) when none is available. The returned backend is scoped tobucket_id.- Return type:
- Parameters:
bucket_id (str)
kind (CertificateSecretBackendKind)