Skip to main content

Module auth

Module auth 

Source
Expand description

Who speccoder is on GitHub: a token from the environment (CI: GH_TOKEN, GITHUB_TOKEN; an Enterprise host: GH_ENTERPRISE_TOKEN), else the one speccoder auth login kept in the operating system’s credential store (service speccoder, account github:<host>). Never a file; never printed.

Structs§

Pending
A device-flow sign-in waiting for the person: the code to type, where.
Secret
A token: redacted wherever it is printed.

Enums§

Source
Where a token came from.

Constants§

APP_CLIENT_ID
speccoder’s GitHub App: its Client ID (public by design — it names the app, it proves nothing) and its slug. Repository permissions: Contents, Checks, Commit statuses, Metadata read; Issues and Pull requests read and write; user tokens that do not expire; the device flow.
APP_SLUG
https://github.com/apps/speccoder-app.
SCOPES
What a token needs: repo to read issues and open pull requests on a private repository, read:org to see team review requests. A fine-grained token needs Issues (read), Pull requests (read and write), Contents and Metadata (read).
SERVICE
The credential-store service every token is filed under.

Functions§

client_id
The app the device flow signs in with on host: SPECCODER_GITHUB_CLIENT_ID (an Enterprise server’s own app, or another one), else speccoder’s on github.com; none on another host.
forget
Forgets host’s token; Ok(false): there was none.
install_url
Where a repository’s owner installs speccoder’s app.
start
Starts the device flow on oauth (https://github.com).
store
Keeps token for host in the credential store.
token
The token for host, and where it came from.
wait
Waits until the person entered the code (or it expired): the token.