Skip to content

Consent links: optional return_url sends the person back once connected - #148

Merged
jerryfane merged 1 commit into
mainfrom
feat/consent-return-url
Nov 14, 2026
Merged

jerryfane merged 1 commit into
mainfrom
feat/consent-return-url

Conversation

@jerryfane

Copy link
Copy Markdown
Contributor

Owner request (Phobos, 2026-11-14): after Google sign-in the page should go back to the dashboard on its own after a few seconds.

  • consent.return_origins (policy): https origins only, exact match; Consent.ReturnAllowed.
  • POST /links (and /accounts/{id}/links, same handler) takes optional return_url: https, no userinfo, origin in the allowlist, ≤512 chars, no ;/whitespace (keeps the meta refresh value unambiguous). Stored on the link and the sign-in.
  • Done pages (OAuth callback, pasted value, Drive connected): "Taking you back…", <meta http-equiv=refresh content="3;url=…">, and a "Back now" button. Without return_url: unchanged text.
  • Cloudflare worker: RETURN_ORIGINS var → return_origins in consent settings, omitted when empty; pushConsent re-sends when public_url or origins change (stamp stays the bare URL when there are no origins, so existing keyrings are not re-pushed).

Tests: TestReturnURLAfterConnecting, TestValidateConsent additions. Mutants (all red): ReturnAllowed→true; done() not setting Return; dropping the ; check.
Rollout: keyring first; Phobos sends return_url only after this is live (an old keyring rejects the unknown field).

A link may carry return_url (https, on consent.return_origins, at most 512
characters). The done page then says "Taking you back…", refreshes there
after 3 seconds and shows a button to go at once; without one it keeps
"You can close this page." Covers OAuth sign-in, pasted values and the
Drive page. The Cloudflare worker sends RETURN_ORIGINS as return_origins
and re-sends consent when they change.
@jerryfane

Copy link
Copy Markdown
Contributor Author

Agent: g7-review
Runtime: omp
Job: local-review-review-router-18e7e3b55f924c06-1

Decision: approved
Summary: Reviewed the complete diff from 94cad50 to 5dce944. No correctness, security, or introduced P3 design findings. Executed origin-validation, escaping, browser navigation, return-URL propagation/tampering, and worker consent-update checks. No prior findings were recorded for PR #148 in the frozen verdict file or GitHub review comments. Verified exact-head CI rerun 43584508664, attempt 2, succeeded, including build/vet/race job 132423638922. Rollout constraint: keep RETURN_ORIGINS empty until compatible containers are running; an old container rejects return_origins, and that failure propagates without recording a successful consent stamp. No repository files changed.

Tests Run

  • PATH=/usr/local/go/bin:$PATH go test ./internal/consent ./internal/policy -> passed.
  • PATH=/usr/local/go/bin:$PATH go vet ./... -> passed.
  • PATH=/usr/local/go/bin:$PATH go build ./... -> passed.
  • PATH=/usr/local/go/bin:$PATH go test -race ./internal/consent ./internal/policy ./internal/googlelogin ./internal/instance -count=1 -> passed.
  • node /tmp/keyring-ts-review-czm4qK/node_modules/typescript/bin/tsc --noEmit --project deploy/cloudflare --typeRoots /tmp/keyring-ts-review-czm4qK/node_modules -> launcher failed under Node 20.9 with ERR_UNKNOWN_FILE_EXTENSION; compiler entry-point invocation below succeeded.
  • node /tmp/keyring-ts-review-czm4qK/node_modules/typescript/lib/tsc.js --noEmit --project deploy/cloudflare --typeRoots /tmp/keyring-ts-review-czm4qK/node_modules -> passed using isolated lockfile dependencies.
  • PATH=/usr/local/go/bin:$PATH go test -overlay=/tmp/keyring-review-overlay.json ./internal/consent -run '^TestReview' -count=1 -v -> passed three disposable probes covering 21 URL boundary cases, origin validation, template escaping, OAuth/value browser tampering, and gcloud link-to-signIn-to-connected-page propagation using an already-connected controller.
  • node /tmp/keyring-worker-review.mjs -> passed against bundled production consentSettings/pushConsent: legacy and empty-origin no-ops; trimming; add/change/remove pushed once; unchanged settings not repeated; PUT and state-sync failures do not advance the stamp.
  • Chromium 150 via browser.run: page.goto('http://127.0.0.1:8765'), DOM inspection, screenshot, and page.waitForNavigation() -> production-rendered completion page displayed correctly; quote/tag/entity-looking input created no injected image; timed meta refresh stayed on the allowed origin.
  • Chromium 150 via browser.run: page.goto('http://127.0.0.1:8765'), page.click('a.btn'), and page.waitForNavigation() -> Back now navigated immediately to the allowed origin. External destination requests were intercepted locally.

Raw runtime output was retained in local Gitmoot state and is not posted here.

@jerryfane
jerryfane merged commit da03961 into main Nov 14, 2026
4 of 5 checks passed
@jerryfane

Copy link
Copy Markdown
Contributor Author

Deployed (live base 31ac165 + this patch, patch-id identical): Worker fefd7478, container v17, RETURN_ORIGINS=https://app.askphobos.ai. Live smoke passed. Brief Worker rollback during the container rollout, see #149. Receipt: /root/fleet-tools/state/phobos-dev/keyring-deploy-return-20261114/RECEIPT.md.

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