Skip to main content

Module credentials

Module credentials 

Source
Expand description

Credential sources and precedence (REQ-21 to REQ-24, REQ-31, D-3).

Service1. Environment2. Config file3. Signed in4. CLI
GitHubGH_TOKEN, GITHUB_TOKENgithub.tokenSign in with GitHub, per accountgh auth token per account

An environment variable that is set but empty counts as unset. The environment is read on each call, so a retry after HTTP 401 (REQ-22) sees a changed variable. A signed-in or gh token is cached in memory until Credentials::invalidate; a rejected signed-in token also marks its account as needing sign-in again.

Re-exports§

pub use signed_in::SignedInAccount;
pub use signed_in::SignedInAccounts;
pub use signed_in::StoreError;

Modules§

gh_sign_in
Signing the active gh account in again with gh auth refresh. Without a terminal, gh prints a one-time code and waits until the user enters it on DEVICE_URL or the code expires. gh refreshes only its active account.
signed_in
GitHub accounts signed in through Subspace (credential step 3): the logins in github-accounts.json beside the state file, and each account’s token in the build’s vault: the system keychain under <data directory>.github, or in a debug build the owner-only github-tokens.json beside the state file. Logins are not secret; a token never leaves its vault except to authorize a request.

Structs§

Credential
CredentialError
No credential for a service, with the guidance that REQ-22 shows. The message never contains a credential or CLI output.
Credentials
The credential sources of every service.
GitHubAccounts
The github.com accounts: logins holds each login once, compared without case, with the signed-in accounts first in GitHub’s spelling. active is gh’s active account.
ProcessEnvironment
SystemRunner

Enums§

AccountSource
Where an account’s token comes from, for display.
Scheme
Source
Where a credential came from.

Constants§

GITHUB_ACCOUNT_KEY
The state key of the account the GitHub dashboard and Copilot chat use.

Traits§

Environment
The process environment, injectable so tests never read the real one.
Runner
Runs a CLI, injectable so tests fake the external process boundary.

Functions§

is_login
A GitHub login: ^[A-Za-z0-9][A-Za-z0-9_-]{0,38}$ (EMU _shortcode allowed).
saved_account
The account saved under GITHUB_ACCOUNT_KEY in the state file.