Skip to content

common_auth.contracts.credentials

Credential references and protected material supplied by a consumer.

Construction never resolves a source, reads configuration or opens a connection. Ordinary dumps omit secret fields; they are display/configuration metadata, not secret backups. Consumers access secret values explicitly at their boundary; encryption and durable secret serialization belong to the configured store.

Classes

ApiKeyCredential

Bases: _CredentialValue

An API key, independent of its header/query placement or provider.

Fields and properties declared here; inherited members belong to the bases above.

kind

kind: Literal['api_key'] = 'api_key'

value

value: SecretStr = Field(min_length=1, repr=False, exclude=True)

ClientSecretCredential

Bases: _CredentialValue

OAuth application identity and its supplied client password.

An explicitly empty client secret is preserved, not treated as a missing value or automatically converted to another client authentication method.

Fields and properties declared here; inherited members belong to the bases above.

client_id

client_id: ClientId

client_secret

client_secret: SecretStr = Field(repr=False, exclude=True)

kind

kind: Literal['client_secret'] = 'client_secret'

CredentialRef

Bases: _CredentialValue

An opaque lookup in an explicitly configured credential source.

Source, key and version retain their exact identifiers. A missing version selects the source’s current value; no version ordering is assumed here. This reference carries neither connection settings nor lookup permission.

Fields and properties declared here; inherited members belong to the bases above.

key

key: _IdentityText

source

source: _IdentityText

version

version: _IdentityText | None = None

PasswordCredential

Bases: _CredentialValue

A username and password for a consuming database, SDK or login protocol.

Text stays exact. Both fields are required; explicit empty values remain distinct from missing fields. The consuming protocol decides usability.

Fields and properties declared here; inherited members belong to the bases above.

kind

kind: Literal['password'] = 'password'

password

password: SecretStr = Field(repr=False, exclude=True)

username

username: str

SigningKeyCredential

Bases: _CredentialValue

Signing material in an explicit raw, PEM or DER representation.

Raw material is unencoded key bytes; PEM/DER hold encoded key material. Key parsing, algorithm compatibility and decryption are signer responsibilities. Material accepts bytes/SecretBytes or a tagged base64 object. PEM additionally accepts text/SecretStr encoded as UTF-8, retaining line breaks exactly. Passphrases accept text as UTF-8 or the same binary representations. No file paths are read and no encoding is inferred from the key contents.

Fields and properties declared here; inherited members belong to the bases above.

format

format: Literal['raw', 'pem', 'der']

kind

kind: Literal['signing_key'] = 'signing_key'

material

material: SecretBytes = Field(min_length=1, repr=False, exclude=True)

passphrase

passphrase: SecretBytes | None = Field(default=None, repr=False, exclude=True)

TotpCredential

Bases: _CredentialValue

A protected TOTP seed in the consuming TOTP utility’s text representation.

Seed decoding/validation and algorithm, digits and period belong to that utility and its configuration. This value never generates an OTP.

Fields and properties declared here; inherited members belong to the bases above.

kind

kind: Literal['totp'] = 'totp'

secret

secret: SecretStr = Field(min_length=1, repr=False, exclude=True)