feat/auth: owner linking and OAuth-only account connection (0.3.0) #32
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/account-sign-in"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Refs #31. Implements backend sign-in links and a separate shared discovery/login service for fresh installs; explicit owner linking, one-time audience-bound assertions and Cloudflare D1 tickets; removes scoped API-token setup/manual connection. Existing backend updates preserve secrets. Tests: full typecheck/test/build pass; new SQL-backed security and login-service tests. Production shared login is intentionally inactive until project-owned OAuth credentials/public Cloudflare client are configured; not deployed. Review security boundaries, account switching, provisioning preservation, and both discovery paths.
Verified findings from review job 988 (old head
4245988): fixed shared-login relay risk by requiring both the initiator claim secret and a separate browser-only unlock secret. Obsidian accepts the return secret only for its active initiating flow; a copied login URL or claim secret cannot release credentials. Added negative tests for absent/wrong unlock. Fixed multi-account provisioning with post-OAuth account chooser and account-scoped zone preflight before mutations. Interrupted initial setup recovery was fixed inf94b869: Cloudflare D1 write authority can atomically initialize a missing owner before ticket issuance. Please recheck current head.Addressed the additional verified mixed-version and expired-session findings from job 996: owner linking now probes an explicit backend capability before starting OAuth (old backends never see a link attempt), verifies the returned session is the same owner, and has compatibility tests. A backend 401 now clears currentUser/vault-list state and stops the engine; the provider control also requires a live session before choosing link mode. Full typecheck/tests pass.
Verified follow-up findings from job 1000 fixed: backend-local OAuth now also requires a distinct browser-only unlock secret, not just public OAuth state. Complete links include the secret and initiating plugin flows route it to the matching poll; missing/wrong unlock tests remain pending without releasing a session. Cloudflare discovery skips denied accounts and retains accessible backends, with a regression test. Migration 0006 adds the local completion verifier. Full typecheck and 27 tests pass.
Fixed the verified privacy finding from job 1002: opening settings no longer contacts login.behold.quest. The user explicitly presses Load sign-in providers after seeing the IP/contact disclosure. Backend-local settings/sign-in remain independent. Prior local-claim and restricted-account findings were fixed in
14e86cc. Typecheck and 27 tests pass.Verified job 1004 recovery-key regression fixed: retain existing scoped cached SESSION_SECRET, use it when recreating a missing Worker, and fail closed before mutations if a database survives but no recovery key is available. Existing Worker updates still preserve secret bindings rather than uploading keys. Added missing-Worker/surviving-database regression coverage; full typecheck and 28 tests pass.
Pi code review
1 new actionable finding
packages/plugin/src/main.ts:1047Merged the candidate reviews of the 0.3.0 authentication, discovery, and provisioning changes, retaining one provisioning defect after checking current code and base behavior. Verification was read-only; no checks were run, and Obsidian handoffs, Cloudflare APIs, and the intentionally inactive shared-login deployment were not exercised.
Change walkthrough
packages/plugin/src/main.ts,packages/plugin/src/api.ts,packages/plugin/src/login.ts,packages/plugin/src/ui/settings-tab.ts(+11 more)packages/plugin/src/provisioning/cloudflare.test.ts,packages/worker/src/account.test.ts,packages/worker/src/login-service.test.tsREADME.md,docs/DEPLOY.md,docs/UPDATING.mdpackage.jsonReview effort: 4/5.
Static observations (not validation results)
Reviewed
a945cf0f17d0bf4f2b4f7f61208c2972460cc02ewithproxy/glm-5.3-flash + proxy/deepseek-v4.1-flash + proxy/gpt-6.1-sol → proxy/gpt-6.1-sol. Automated advisory review; no project commands or tests were executed.@ -899,1 +1044,4 @@: undefined,});if (this.settings.backendUrl && this.settings.backendUrl !== result.apiUrl) {if (!(await this.switchBackend(result.apiUrl))) return;[P2] A second switch prompt can silently abandon completed backend setup
Quality: provision() confirms the backend switch before deploying, but asks for the same confirmation again after provisioning has completed. Declining or closing that second dialog returns before saving the new backend URL and generated session secret or exchanging the bootstrap token, silently leaving setup incomplete despite resources having been created.
Trigger: A device configured for backend A runs Cloudflare setup for a new backend B, such as in another authorized Cloudflare account, accepts the first switch confirmation, then declines or closes the second confirmation.
Impact: The Worker, database, DNS record, and route have already been provisioned, but the plugin remains on A and never initializes B's vault. B's generated bootstrap token and session secret are discarded from the setup result rather than retained by the plugin; the user must reauthorize through Cloudflare reconnect to access B, with no failure notice explaining the partial setup.
Evidence: In packages/plugin/src/main.ts, provision() calls confirmBackendSwitch(nextBackend) before await provisionBackend(), without changing settings.backendUrl. The added branch at line 1047 then calls switchBackend(result.apiUrl), whose implementation prompts again whenever the URL differs and returns false on cancellation. Persistence of result.apiUrl/result.sessionSecret and connect(result.bootstrapToken) occurs only after this early return. packages/plugin/src/provisioning/cloudflare.ts generates both secrets for a new Worker and completes the upload, backend_url registration, DNS, and routing before returning. The base provision() saved the returned backend settings immediately and had no post-deployment cancellation branch.
Verified and fixed the remaining P2 from review 343: provisioning now reuses the switch approval obtained before deployment, rather than offering a second cancellation after resources and recovery keys have been created. Full typecheck, 28 tests, both Worker builds, plugin build, and packaging pass.
Merged as
213f5bband deployed vault backend to https://api.behold.quest. Worker version a0c181c2-d1f0-4a9c-b0c3-862fe570c1f6. Applied account-login/discovery/completion migrations 0004–0006 and registered backend_url. Health returns ownerLinking capability; /signin returns 200. Existing SESSION_SECRET and BOOTSTRAP_TOKEN bindings and original DO namespace remain intact. Shared login service is not deployed/configured; its project-owned OAuth registrations remain required. Final review rerun job 1049 failed due to invalid reviewer-output schema; all previously reported findings were addressed. Typecheck, 28 tests, build, packaging passed.