yera.creds.auth

Credential group resolution, authorisation, and TOFU for tool credentials.

Symbols

def canonical_authorised_root_key — Return a canonical path string for comparing authorised roots.
def project_root_authorised_in_roots — Report whether a project root is included in the authorised roots.
def require_resolved_credential_group — Return a resolved credential group, requiring one to be configured.
def resolve_active_credential_group — Resolve the active credential group from ``pyproject.toml``.
class ResolvedCredentialGroup — Active credential group selected by the project configuration.

canonical_authorised_root_key

canonical_authorised_root_key(
    path: Path | str,
) → str

Return a canonical path string for comparing authorised roots.

Relative components, user-home markers, trailing separators, and symlinks are resolved so equivalent directory spellings produce the same key.

Parameters

path
type: Path | str

Filesystem path to canonicalise.

Returns

type: str

The expanded and resolved absolute path as a string.

Raises

TypeError

If path is neither a string nor a Path.

project_root_authorised_in_roots

project_root_authorised_in_roots(
    project_root: Path | None,
    authorised_roots: list[str],
) → bool

Report whether a project root is included in the authorised roots.

The "*" entry authorises every project. Other entries are compared using their canonical filesystem paths.

Parameters

project_root
type: Path | None

Project root to check, or None when no project root is available.

authorised_roots
type: list[str]

Stored root paths, optionally including the "*" wildcard.

Returns

type: bool

Whether the project is authorised by a wildcard or matching root.

require_resolved_credential_group

require_resolved_credential_group(
    resolved: ResolvedCredentialGroup | None,
) → ResolvedCredentialGroup

Return a resolved credential group, requiring one to be configured.

Parameters

resolved
type: ResolvedCredentialGroup | None

Previously resolved credential group, or None.

Returns

type: ResolvedCredentialGroup

The supplied resolved credential group.

Raises

CredentialGroupNotSpecifiedError

If no credential group is configured.

resolve_active_credential_group

resolve_active_credential_group() → ResolvedCredentialGroup | None

Resolve the active credential group from pyproject.toml.

Reads a non-empty cred-group value from [tool.yera.overrides]. Missing files, missing values, and whitespace-only values are treated as having no active credential group.

Returns

type: ResolvedCredentialGroup | None

The resolved credential group, or None when none is configured.

ResolvedCredentialGroup

Active credential group selected by the project configuration.

Fields

name
type: str (required)

Credential group selected by [tool.yera.overrides] cred-group.

Methods


ResolvedCredentialGroup.__init__

__init__(
    name: str,
) → None