Repository navigation
feat(account): sign in from a PC's own page with GitHub's device flow - #2995
Conversation
|
Caution Review failedThe pull request is closed. Summary
Merge Risk:
|
|
Review findings (omo, and Codex Terra xhigh) and how each was resolved in f1a5604:
Service side: ovis-sh/account#6 is omo CLEAR at 51feebe and live on account.ovis.sh. |
|
omo re-review at 4429602 found no HIGH. Its points, and what happens to each:
This PR has had its one fix round (f1a5604); these stay out of it. |
|
Local merge gate (owner-approved): |
…PC (#3004) Fixes #2996 ## What Settings > Phone & devices showed **Disconnect from all PCs** on the account's other devices to any browser signed in to the account. A browser signed in on a PC's own address (GitHub device flow, #2995) and paired by cookie holds an account key that no row of the PC has, so every PC refused its signed `remove` with `signer_not_member`, and the button could never work. Now the button shows only when this client's account key is a drive member of the account on this PC, which is the condition the PC itself checks (`accountSigner` in `server/devices.ts`). Otherwise the row keeps its own **Revoke**, which works. - `signsAccountRemoves(devices, account, key)` in `DevicesPanel.tsx`: true only when some row has `account === signed-in account`, `account_key === this client's key` and `role === "drive"`. - The panel reads its account key only after the account sign-in is known. - A row holding this client's own key is not offered the removal: that device leaves with Leave the account (`removeFromAccount` refuses it). Design: account removal is offered only where it can take effect, and a plain local Revoke is offered everywhere else. Google Account's device list follows the same rule, offering remote sign-out only where the session is allowed to do it. ## Screenshots Isolated server (mkdtemp state, no herdr), one account member row "Lost phone", and a browser with an account session. Before (main), non-member browser: the button shows. <img src="https://raw.githubusercontent.com/devswha/ovis/bd1541f273bf71d74e380c61b725d30d2afae752/main-nonmember-1280-light.png" width="640"> <img src="https://raw.githubusercontent.com/devswha/ovis/bd1541f273bf71d74e380c61b725d30d2afae752/main-nonmember-390-dark.png" width="200"> After, non-member browser: only Rename and Revoke. <img src="https://raw.githubusercontent.com/devswha/ovis/bd1541f273bf71d74e380c61b725d30d2afae752/fix-nonmember-1280-light.png" width="640"> <img src="https://raw.githubusercontent.com/devswha/ovis/bd1541f273bf71d74e380c61b725d30d2afae752/fix-nonmember-390-light.png" width="200"> <img src="https://raw.githubusercontent.com/devswha/ovis/bd1541f273bf71d74e380c61b725d30d2afae752/fix-nonmember-1280-dark.png" width="640"> <img src="https://raw.githubusercontent.com/devswha/ovis/bd1541f273bf71d74e380c61b725d30d2afae752/fix-nonmember-390-dark.png" width="200"> After, member browser (a row holds its key): the button stays. <img src="https://raw.githubusercontent.com/devswha/ovis/bd1541f273bf71d74e380c61b725d30d2afae752/fix-member-1280-light.png" width="640"> <img src="https://raw.githubusercontent.com/devswha/ovis/bd1541f273bf71d74e380c61b725d30d2afae752/fix-member-390-dark.png" width="200"> ## Validation - `bun test src/components/DevicesPanel.test.ts`: the new tests failed before the change (no such export) and pass after it (7 pass with the own-key case). - `bun run check fast` at the final head, merged with main: pass (typecheck, build, 12154 unit tests). - Browser QA at 1280 and 390, light and dark, in all three states above. Button counts: main non-member 4/4, fix non-member 0/4, fix member 8/8 (2 rows). - Skipped: `check full` and the integration/browser suites (left to CI).
What
A browser on a PC's own https address can now sign in to the Ovis account in Settings → Phone & devices → Account, as the desktop app can. No redirect can come back to that address (the account service sends sign-ins only to
https://app.ovis.sh/,ovis://account/callbackand loopback), so the page uses GitHub's device flow (RFC 8628). It shows GitHub's code and an Open GitHub link togithub.com/login/device, then polls the account service until the person approves there.server/static.ts: the PC's own shell carries<meta name="ovis-pc-account-service">, set to exactly the origin itsconnect-srcalready admits. There is no meta whenOVIS_ACCOUNT_SERVICE_URL=offor when that URL is not https. The hosted shell'sovis-account-servicemeta is a different one, so app.ovis.sh keeps its redirect sign-in./index.htmlnow revalidates like/.src/lib/account/deviceSignIn.ts: the sign-in is bound to a PKCE-style verifier (32 random bytes, kept in memory only). The service must answercode_challenge_method: "S256", or the page shows no code and polls nothing. The link goes only to GitHub's own device page. Onslow_downthe interval grows by 5 s, and a 429 waitsRetry-After. The session is stored under the same cross-tab lock as a refresh or a sign-out, and never after Cancel, a sign-out or closing Settings.src/components/AccountSection.tsx: when there is no desktop bridge, the section shows on a secure page with that meta, GitHub only. The desktop app keeps its loopback sign-in.shared/account-service-fake.ts: the bound device flow, as in the service.docs/account.md: the contract for the bound device flow and the PC's meta, plus device-code phishing and the PC-origin risk under "What this does not protect against".Nothing about admission changes.
devices.jsonstays the only authority, a new device is still approved from a linked device by comparing digits, there are no cookies, and the CSP is unchanged.Precedent: the device-code sign-in of GitHub CLI (
gh auth login) and of the Codex CLI. Both show a short code and link to the provider's device page, because nothing can redirect back to them.Service side: ovis-sh/account#6 (private), already deployed to production (account.ovis.sh, version d39a53c7). Without it the page says the service cannot sign in a browser here yet.
Design review
Codex (Terra, xhigh) reviewed the design before any code was written. What changed because of it:
/index.htmlrevalidates.Device-code phishing is inherent to RFC 8628 and already applied to the headless path; it is documented.
Validation
src/lib/account/account.test.ts(device sign-in: approve, unbound service refused, 429, denied, expired, cancel, foreign link; PC meta reader).server/static.test.ts(meta injection).shared/account-service-fake.test.ts(binding).bun run check faston the merged head: all steps ok (typecheck, build, unit tests, conventions, i18n).https://home-server.example.ts.net:17461(tailscale serve, isolated herdr session and state dir):/v1/tokenabout every 6 s./login/device. The run stopped there, where a human approves.bun run check full, and a completed GitHub approval (it needs a human click).