Repository navigation
Hybrid installs sign in with GitHub through CoderHelm's GitHub App - #459
Merged
Merged
Conversation
A hybrid install has no GitHub OAuth client of its own, so #456 hid Continue with GitHub there. People need it to get in, so it now goes through CoderHelm's app, with the install making every decision. - The install makes a state and a PKCE verifier, seals them in a __Host- cookie with its own key, and asks the hosted side (signed v2) to start a flow for its own callback, /auth/github/hybrid-callback. The hosted side accepts only that path on the install's verified CloudFront or CoderHelm address. - GitHub returns to the already registered hosted callback (/auth/github/callback/hybrid, state=hsi_...). The hosted side takes the flow once, checks the install again and forwards the browser with the code; it keeps only the code's hash, for 5 minutes. - The install checks state and flow against its cookie, then asks the hosted side (signed) to exchange the code with the verifier; the hosted side checks the install, the code hash and PKCE, and GitHub checks the verifier too. The token is answered, never stored or logged. - The install reads the GitHub account from GitHub itself and runs the same sign-in as its own client would (github_sign_in_with_token: members, invites, allowed domains, no sign-up, two-factor), links no installations, then has the hosted side revoke the token at GitHub. - /auth/methods says github: true for a registered hybrid install; the github_sign_in check passes there and warns until it is registered. - The Settings card for Sign in with GitHub says what passes through CoderHelm and what stays with the install (new mode: included). - Docs: hybrid.md has the flow and what CoderHelm sees and can do; sign-in.md and check-your-install.md follow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hybrid installs offer Continue with GitHub again, through CoderHelm's GitHub App. The hosted side only carries the trip to GitHub and exchanges a code the install hands it; the install checks the GitHub account with GitHub itself and applies its own sign-in rules. The hosted side can't make a session on an install or choose who signs in. This replaces the "GitHub sign-in off on hybrid" choice from #456.
The flow:
GET /auth/githubon the install (no OAuth client of its own, registered with CoderHelm): a new state and PKCE verifier, sealed in a__Host-cookie with the install's own key; a signedPOST /hybrid/github/sign-in/startwith the install's callback (/auth/github/hybrid-callback), state and S256 challenge. The install checks the answered URL is GitHub's authorize page for that flow and challenge.https://api.coderhelm.com/auth/github/callback/hybridwithstate=hsi_…. The hosted side takes the flow once, checks the install is still verified and the address still its own, keeps the code's hash (5 minutes) and forwards the browser with code, state and flow.POST /hybrid/github/sign-in/exchangewith the verifier. The hosted side checks the flow is this install's, the code hash and PKCE; GitHub checks the verifier too. The token is answered, not stored or logged.github_sign_in_with_token, the same function its own client uses: members, invites, allowed domains, no sign-up, two-factor; no installation linking), thenPOST /hybrid/github/sign-in/revokehas the token revoked at GitHub.No GitHub App setting changes: the hosted callback is the one hybrid linking already uses.
Changes
common/src/hybrid/github_sign_in.rs(new): paths, flow and state shapes, PKCE, redirect check (exact path, install hosts only), authorize URL and its install-side check, sealed cookie, return matching.routes/hybrid.rs:sign_in_start,sign_in_return(dispatched from the existing hosted callback byhsi_state),sign_in_exchange,sign_in_revoke; auditgithub_sign_inandgithub_sign_in_refused.routes/github_hybrid.rs(new): install start and callback.routes/auth.rs: the GitHub callback split at the token;/auth/methodsand/auth/githubroute through CoderHelm when the install has no client and is registered.setup_checks.rs:github_sign_inpasses on a registered hybrid install, warns until it is registered.integrations.rs: the Sign in with GitHub card, new modeincluded, copy says what passes through CoderHelm (no Google mention).hybrid.md(flow, what CoderHelm sees and can do, operators),sign-in.md,check-your-install.md.Verification
cargo fmt --check --all,cargo clippy -p gateway -p common -p worker --tests -- -D warnings,cargo test -p common -p gateway: 2084 passed.github_sign_in_with_token, the hybrid callback checks its cookie before calling CoderHelm and makes no session itself; existing rules and two-factor order tests now cover the shared function.