gmuse.credentials#
Secure credential storage and resolution helpers for gmuse.
Module Contents#
Classes#
Represents the effective value of a credential variable. |
|
Represents the current keyring backend status. |
Functions#
Treat empty and whitespace-only values as missing. |
|
Mask a credential value for safe display. |
|
Run a keyring operation without leaking backend stderr to the user. |
|
Return a normalized view of the active keyring backend. |
|
Validate that the active backend is both available and secure. |
|
Read a keyring value, optionally bounding the lookup time. |
|
Read the managed-variable index from keyring. |
|
Persist the managed-variable index to keyring. |
|
Add a variable to the managed index. |
|
Remove a variable from the managed index. |
|
Store a credential in the secure keyring. |
|
Delete a stored credential and update the managed index. |
|
Return whether a credential exists in the secure keyring. |
|
Return the credential variables typically associated with a provider. |
|
Resolve a single credential from env vars or keyring. |
|
Resolve the credential for a provider-backed LLM provider. |
|
Detect a provider from env vars or keyring-backed credentials. |
|
Build the standard missing-credential guidance. |
|
Convert backend status into a user-facing error message. |
Data#
API#
- gmuse.credentials.SERVICE_NAME: Final[str] = 'gmuse'#
- gmuse.credentials.INDEX_USERNAME: Final[str] = '__gmuse_index__'#
- gmuse.credentials.COMPLETION_LOOKUP_TIMEOUT_SECONDS: Final[float] = 0.2#
- gmuse.credentials._KEYRING_STDERR_LOCK = 'Lock(...)'#
- gmuse.credentials._T = 'TypeVar(...)'#
- gmuse.credentials.CredentialSource = None#
- gmuse.credentials._PROVIDER_CREDENTIAL_VARIABLES: Final[dict[str, tuple[str, ...]]] = None#
- class gmuse.credentials.CredentialResolution#
Represents the effective value of a credential variable.
- variable_name: str = None#
- source: gmuse.credentials.CredentialSource = None#
- raw_value: str | None = None#
- masked_value: str | None = None#
- is_managed: bool = None#
- class gmuse.credentials.BackendStatus#
Represents the current keyring backend status.
- backend_name: str = None#
- backend_module: str = None#
- is_available: bool = None#
- is_secure: bool = None#
- failure_reason: str | None = None#
- gmuse.credentials.normalize_env_value(value: str | None) str | None#
Treat empty and whitespace-only values as missing.
- gmuse.credentials.mask_secret(value: str | None) str | None#
Mask a credential value for safe display.
- gmuse.credentials._call_keyring(operation: Callable[[], gmuse.credentials._T]) gmuse.credentials._T#
Run a keyring operation without leaking backend stderr to the user.
- gmuse.credentials.get_backend_status() gmuse.credentials.BackendStatus#
Return a normalized view of the active keyring backend.
- gmuse.credentials.ensure_secure_backend() gmuse.credentials.BackendStatus#
Validate that the active backend is both available and secure.
- gmuse.credentials._read_keyring_value(variable_name: str, *, timeout: float | None = None) str | None#
Read a keyring value, optionally bounding the lookup time.
- gmuse.credentials.get_managed_variables(*, timeout: float | None = None) set[str]#
Read the managed-variable index from keyring.
- gmuse.credentials.write_managed_variables(variables: set[str]) None#
Persist the managed-variable index to keyring.
- gmuse.credentials.add_managed_variable(variable_name: str) None#
Add a variable to the managed index.
- gmuse.credentials.remove_managed_variable(variable_name: str) None#
Remove a variable from the managed index.
- gmuse.credentials.store_credential(variable_name: str, secret: str) None#
Store a credential in the secure keyring.
- gmuse.credentials.delete_credential(variable_name: str) bool#
Delete a stored credential and update the managed index.
- gmuse.credentials.credential_exists(variable_name: str) bool#
Return whether a credential exists in the secure keyring.
- gmuse.credentials.get_provider_credential_variables(provider: str) tuple[str, ...]#
Return the credential variables typically associated with a provider.
- gmuse.credentials.resolve_credential(variable_name: str, *, completion_timeout: float | None = None, managed_index: set[str] | None = None) gmuse.credentials.CredentialResolution#
Resolve a single credential from env vars or keyring.
- gmuse.credentials.resolve_provider_credential(provider: str, *, completion_timeout: float | None = None) gmuse.credentials.CredentialResolution | None#
Resolve the credential for a provider-backed LLM provider.
- gmuse.credentials.detect_provider_from_credentials(*, completion_timeout: float | None = None) str | None#
Detect a provider from env vars or keyring-backed credentials.
- gmuse.credentials.build_missing_credential_error(variable_name: str | None = None) str#
Build the standard missing-credential guidance.
- gmuse.credentials.build_backend_error_message(status: gmuse.credentials.BackendStatus) str#
Convert backend status into a user-facing error message.