Skip to content

CLI authorize page and Settings CLI keys card - #317

Merged
neuromechanist merged 12 commits into
stagingfrom
feature/issue-316-cli-authorize
Sep 7, 2026
Merged

neuromechanist merged 12 commits into
stagingfrom
feature/issue-316-cli-authorize

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Website half of ORCID-first CLI sign-in (nemarOrg/nemar-cli#1272, phase 2; tracked by nemarOrg/nemar-cli#1282). The backend device authorization grant shipped in nemarOrg/nemar-cli#1287 on that epic's branch (its ADR 0047).

  • /cli/authorize?code=XXXX-XXXX: a server-rendered page with no client script. Not signed in, it sends the person through sign-in with next preserving the code. Signed in, it looks the code up and asks "Did you just run nemar auth login on ?", naming the account (username, masked email) and the machine, with Authorize and Deny as real form buttons. Success outcomes finish with a 303 post-redirect-get so a refresh never re-posts; refusals render the backend's own sentence.
  • /cli is now an app-host route, so the page always runs where the session cookie lives.
  • next now survives a brand-new ORCID sign-up through email verification (complete.astro, dashboard, VerifyEmailStep); the matching backend line lands in the epic's phase 3.
  • Settings gains a CLI keys card: the list is server-rendered with the page's own Origin pinned (the backend's cookie path requires one), keys are created through a same-origin route and shown once, and revoke sits behind the confirm dialog.
  • astro dev has no backend, so the page and the two key routes carry DEV branches over an in-memory store; the build is checked to contain none of it.
  • ADR 0016 records the two constraints a future contributor would otherwise rediscover: pin the request's own Origin on server-side calls, and always end the confirm/deny POST in a redirect.

Refs #316 (close by hand after merge; closing keywords do not fire on staging).

Test plan

  • src/lib/host.test.ts: /cli/authorize is an app route; cross-host redirect keeps ?code=; canonical origin
  • src/lib/device-auth-api.test.ts: exact URLs, methods, headers and bodies for lookup, confirm, deny, list; network failure sentinel
  • src/lib/device-authorize.test.ts: every status and body combination of the view model, next-step links, the PRG redirect, the query-driven done view
  • src/lib/device-authorize-dev.test.ts: dev store fixtures and cap
  • test/routes/api-auth-keys.test.ts: DEV branches and the forwarding branch through the route harness
  • test/cli-authorize-ui.test.ts, test/settings-cli-keys.test.ts, test/orcid-complete-next.test.ts: page-source assertions (Origin check, content-type check, 303, one POST form with both intent buttons, no script, no set:html, no api_key; card placement, pinned Origin, confirm dialog; next plumbing)
  • bun run lint, bun run typecheck, bun run test (91 files, 2147 tests), bun run build; no dev-store string in dist/_worker.js
  • Prove-the-test-fails: the /cli prefix, the Origin comparison, the 303, the pinned Origin, the next navigation each mutated and caught
  • Staging walk-through with a real ORCID account once the backend routes reach api-test.nemar.org (they deploy from nemar-cli dev), recorded on Phase 2: Website authorize page and CLI keys card nemar-cli#1282

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant