yera.creds.auth
Credential group resolution, authorisation, and TOFU for tool credentials.
Symbols
append_resolved_root_if_missing
append_resolved_root_if_missing(
project_root: Path,
authorised_roots: list[str],
) → boolAppend the resolved project root if it is not already authorised canonically.
Returns
True when a new entry was appended (caller should persist the store).
authorised_credential_group_credentials
authorised_credential_group_credentials(
store: CredentialStore,
group_name: str,
get_project_root: Callable[[], Path | None] = resolve_project_root,
) → tuple[CredentialStore, dict[str, dict[str, Any]]]Return (store, credentials) for group_name after TOFU / authorisation.
canonical_authorised_root_key
canonical_authorised_root_key(
path: Path | str,
) → strReturn a normalised path string for comparing authorised roots.
Resolves . / .., trailing separators, and symlinks so the same
directory stored under different spellings matches.
ensure_authorised_credential_store
ensure_authorised_credential_store(
store: CredentialStore,
group_name: str,
get_project_root: Callable[[], Path | None] = resolve_project_root,
) → CredentialStoreReturn store after ensuring group_name exists and the project root is authorised.
ensure_credential_group_exists_and_authorised
ensure_credential_group_exists_and_authorised(
store: CredentialStore,
group_name: str,
get_project_root: Callable[[], Path | None],
) → tuple[CredentialStore, bool]Ensure group_name exists in store and the current root is authorised.
TOFU (Trust On First Use):
- Group absent → create it, auto-add current project root to
authorised_roots, return(store, True). - Group present, root authorised → return
(store, False). - Group present, root NOT authorised → raise
CredentialGroupNotAuthorisedErrorwith the spec's recovery messaging.
Returns
(store, was_created) — store is mutated in-place when a new group is created.
is_authorised
is_authorised(
get_project_root: Callable[[], Path | None],
authorised_roots: list[str],
) → boolReturn True when the calling project root is authorised.
The "*" sentinel is checked unconditionally first.
get_project_root is only called when "*" is absent, so
resolve_project_root() is never invoked in a deployed / CI context
where the credential store carries ["*"].
project_root_authorised_in_roots
project_root_authorised_in_roots(
project_root: Path | None,
authorised_roots: list[str],
) → boolReturn True when project_root is authorised (including '*' wildcard).
require_resolved_credential_group
require_resolved_credential_group(
resolved: ResolvedCredentialGroup | None,
) → ResolvedCredentialGroupReturn resolved or raise if no credential group is configured.
resolve_active_credential_group
resolve_active_credential_group() → ResolvedCredentialGroup | NoneResolve the active credential group name from pyproject.toml.
Reads non-empty cred-group under [tool.yera.overrides]. Whitespace-only
values are treated as absent. When no pyproject.toml is found or no value
is set → None.
ResolvedCredentialGroup
Active credential group name from [tool.yera.overrides] cred-group.