Expand description
Credential sources and precedence (REQ-21 to REQ-24, REQ-31, D-3).
| Service | 1. Environment | 2. Config file | 3. Signed in | 4. CLI |
|---|---|---|---|---|
| GitHub | GH_TOKEN, GITHUB_TOKEN | github.token | Sign in with GitHub, per account | gh 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 onDEVICE_URLor 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.jsonbeside the state file, and each account’s token in the build’svault: the system keychain under<data directory>.github, or in a debug build the owner-onlygithub-tokens.jsonbeside the state file. Logins are not secret; a token never leaves its vault except to authorize a request.
Structs§
- Credential
- Credential
Error - 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.
- GitHub
Accounts - The github.com accounts:
loginsholds each login once, compared without case, with the signed-in accounts first in GitHub’s spelling.activeis gh’s active account. - Process
Environment - System
Runner
Enums§
- Account
Source - 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_shortcodeallowed). - saved_
account - The account saved under
GITHUB_ACCOUNT_KEYin the state file.