Public: anyone can read this; the crew can change it.

The OAuth consent page lists, in plain words, what an agent token can do and for how long #14089

opened this

Merged 20d 1h ago, live in production

The consent page now shows when each token lifetime ends and links to where a token is revoked. I left unknown scopes ignored rather than refused. The updated consent tests and oauth-page-shape pass (13 tests), as do bun x tsc --noEmit and bun scripts/design-lint.ts.

Notes

opened this

The consent page now shows when each token lifetime ends and links to where a token is revoked. I left unknown scopes ignored rather than refused. The updated consent tests and oauth-page-shape pass (13 tests), as do bun x tsc --noEmit and bun scripts/design-lint.ts. I did not run the full suite, and scripts/gate.ts --fix changed no files.

Already on main. d3d4ab246 (#13614) made the page list each scope as a sentence from SCOPE_WORDS. The page never prints a raw scope id.

What changed (src/web/pages/oauth.ts):

  • Expiry: each timed lifetime option now reads "A year (until 2027-11-16)", "30 days (until …)" and "A day (until …)". The default stays "Until I revoke it".
  • Revoke link: a line under the lifetime picker says "You can end it sooner: revoke it any time under Settings, tokens", linking to /settings/tokens, where each token has a Revoke button.

Tests (test/oauth-consent-words.test.ts):

  • The page shows the end date for each timed lifetime, "Until I revoke it", and the /settings/tokens link. These assertions fail without the change.
  • Every grantable scope (ro, rw, openid, profile, email) has a sentence.
  • An unknown scope (admin) is not offered or granted: the page falls back to the read-only default.

What I chose not to do: the issue says an unknown scope is "refused". I kept it ignored, which is existing behaviour that earlier tests pin. Refusing would break clients that send extra scopes such as offline_access, and I don't change behaviour in a refactor. If you want refusal, it needs its own issue.

Pre-push hook: it demanded a "Try:" commit, so I added an empty one.

To try it: open /oauth/authorize with a registered client and look at the "Lasts" field.

🤖 Generated with Claude Code

Closes #14069

Show 1 earlier items

7 earlier comments
commented

<!-- look-pages 9844d5b41b55 --> Look pages for 9844d5b, from the gate:

  • look pages (inferred): this pull changes src/web/pages/oauth.ts; the forge pictures / (src/web/pages/oauth.ts), /docs (src/web/pages/oauth.ts), /explore (src/web/pages/oauth.ts) and 24 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The "both doors" gate rule failed because I edited src/web/pages/oauth.ts with no matching change under src/tui/ or a docs/features/ how-to. I added a No door: line to a new empty commit instead. The terminal has no consent screen to change. A person approves a token only in the browser a client sends them to. The terminal already has an src/tui/screens/oauthgrants.ts screen for revoking tokens, and it is not touched here.

bun scripts/gate.ts now passes locally, with only the inferred-looks notice printed. I pushed the commit. The forge's check will run on it next. I did not rerun the tests, since nothing else changed.

The pull's code is the same as before:

  • Expiry: the consent page shows the date each timed lifetime ends.
  • Revoke link: it links to /settings/tokens so a person can revoke a token.
  • Tests: they cover both.
  • Scopes: unknown scopes stay ignored rather than refused, as described earlier.

🤖 Generated with Claude Code

commented

<!-- look-pages 4dc8bb164856 --> Look pages for 4dc8bb1, from the gate:

  • look pages (inferred): this pull changes src/web/pages/oauth.ts; the forge pictures / (src/web/pages/oauth.ts), /docs (src/web/pages/oauth.ts), /explore (src/web/pages/oauth.ts) and 24 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The look-pages comment inferred 27 pages to picture, but only one page changed. That is the consent page at /oauth/authorize. The other 26 come from src/web/pages/oauth.ts being imported by many routes, and their rendering is untouched.

I added a commit with an empty diff and the line Looks: /oauth/authorize, which is the override the comment describes, so the forge pictures only the consent page. No code changed. I did not run tsc or the tests, because nothing in the tree changed since the last push.

The pull still contains:

  • The consent page lists, in plain words, what an agent token can do and for how long.
  • It shows the date each lifetime ends.
  • It links to revoking.
  • It has no terminal consent screen. Consent is only ever approved in a browser the client sends a person to, and token revoking already lives in the connections screen.

To try it, start an OAuth authorize flow against the preview and open /oauth/authorize in a browser.

commented

<!-- look-pages 74f2e44c397f --> Look pages for 74f2e44, from the gate:

  • look pages (inferred): "Looks: /oauth/authorize" is not a page of app.looks in forge.json; this pull changes src/web/pages/oauth.ts; the forge pictures / (src/web/pages/oauth.ts), /docs (src/web/pages/oauth.ts), /explore (src/web/pages/oauth.ts) and 24 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

I got the Looks: override wrong last time. The gate only accepts paths listed in app.looks in forge.json, and /oauth/authorize isn't one. I've pushed a new empty commit with a No look: line instead. I haven't seen the gate's verdict on it yet.

The line says the consent page needs a client_id and a redirect to render, so it can't be pictured as a plain look. It also says the other pages that import oauth.ts render the same as before.

I disagree with the 27 inferred pages. They only exist because many routes import src/web/pages/oauth.ts; the one page that changed is the consent page. I didn't add /oauth/authorize to app.looks, because it wouldn't render without request parameters and forge.json is outside this change. No code changed in this round, so I didn't re-run tsc or the tests.

commented

The consent page now refuses an unknown scope and sends people to Connected agents to revoke. The OAuth tests pass (100 pass, 3 skipped), and gate.ts, tsc and design-lint are clean.

  • Revoke link: the consent page now says "Revoke it any time under Connected agents", linking to /settings/grants. That's where an OAuth grant is listed. The line is one plain sentence in place of the old "You can end it sooner…" wording. The test asserts the new target.
  • Unknown scope: parseAuthRequest in src/core/oauth.ts now refuses any scope word it has no sentence for. That covers admin, offline_access, nonsense and constructor. The page answers 400 with "This forge does not offer the scope …" and no grant form. I tested the refusal for those scopes. The old test that asserted they were ignored is gone. An empty scope still defaults to read-only, with its own test.
  • Sentence test: I removed the check that only asserted SCOPE_WORDS was truthy for five ids. The existing per-scope test renders the page for each scope and asserts its sentence appears exactly once.

Behaviour change: a client that sends an extra scope such as offline_access alongside ro is now refused where it was previously let through. That is what issue box 3 asks for, and a person should know it before merging.

commented

The test/capacity.test.ts failure doesn't come from my change, so I pushed nothing. I changed no code, and a push alone wouldn't re-run the check. A shard timed out at 30 s in a crew-concurrency test, which has nothing to do with the OAuth consent page.

  • What I ran: test/capacity.test.ts locally. All 16 tests pass here, including the "raised from one to two" case that failed.
  • What the check said: the file is green on main at 30d06a2, and it didn't re-run it alone because the pull touches "a failed test or what it imports". That wording looks like a false positive, since my diff only touches src/core/oauth.ts, src/web/pages/oauth.ts and test/oauth-consent-words.test.ts.
  • Likely cause: the test spawns two fake agent runs and waits on timing. A 30 s timeout on a busy 77-shard run looks like contention rather than a defect in this pull.

The pull is unchanged from the last push (c984966df). Re-running the check on that commit should clear it. If it fails again in the same place, someone should look at that test's timing on a loaded machine, because there is no code in this pull to fix.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs