Skip to main content

Crate subspace_github_auth

Crate subspace_github_auth 

Source
Expand description

Sign in with GitHub through the app’s OAuth App, without GPUI.

The app supplies its OAuth App (OAuthClient); the Framework has none. With the client secret, sign-in uses the browser: an authorization code with PKCE (RFC 7636) and a random state, returned to a one-shot listener on 127.0.0.1 (browser). Without it, sign-in uses the device flow (RFC 8628, device). Either way the token’s owner comes from GET /user. Tokens, codes and the secret are Secrets or stay inside this crate; no log line or error carries one.

Re-exports§

pub use config::Endpoints;
pub use config::OAuthClient;

Modules§

browser
The browser flow: GitHub’s authorize page, then a one-shot listener on 127.0.0.1 for its redirect to /callback. For an OAuth App with a loopback callback GitHub accepts any port, so the listener takes a free one. The listener uses std::net: it reads one request line on loopback, which needs no HTTP server dependency.
config
The OAuth App and the GitHub addresses a sign-in talks to.
device
The device flow (RFC 8628): GitHub gives a code for the user to enter at github.com/login/device, and Subspace polls the token endpoint until the user approves, declines or the code expires. It needs no client secret, so builds without one use it.
pkce
Proof Key for Code Exchange (RFC 7636, S256) and the state value.
token
POST /login/oauth/access_token: its requests and what its answers mean. GitHub answers OAuth errors with status 200 and an error field.

Structs§

Cancel
A sign-in’s cancel switch, shared with the thread that waits.
GitHubOAuth
Sign-in through the app’s GitHub OAuth App.
SignedIn
A finished sign-in: the account and its token.
Started
A started sign-in: what to show, and what to wait for.

Enums§

AuthError
Why a sign-in did not finish. Every message is plain words for the user and carries no token, code or secret.
Prompt
What the user does next.

Constants§

SIGN_IN_TIME_LIMIT
How long a sign-in waits for the browser or the code before giving up.

Traits§

Authenticator
Starts sign-ins and revokes signed-out tokens; injectable for tests.
Pending
The rest of a started sign-in, run off the UI thread.