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

The OAuth consent page names the client and lists each scope in plain words #13614

opened this

Merged 20d 17h ago, live in production

The consent page now lists one plain sentence for each scope the client asked for, and an unknown scope is refused before the screen. I ran tsc, scripts/gate.ts and the OAuth, guide and feature-index tests, and they pass. I did not run the full suite, and I did not try it on a preview.

Notes

opened this

The consent page now lists one plain sentence for each scope the client asked for, and an unknown scope is refused before the screen. I ran tsc, scripts/gate.ts and the OAuth, guide and feature-index tests, and they pass. I did not run the full suite, and I did not try it on a preview. I also didn't call keep_plan or estimate, because I didn't have those tools in this session.

  • Scope table: SCOPE_WORDS in src/core/oauth.ts holds the sentences for ro, rw, openid, profile and email. The Read and Read-and-act radio labels and the sign-in "what it learns" list read from the same table, so the wording can't drift from what is offered.
  • Refusal: parseAuthRequest now rejects any scope outside that table, admin included, with the existing plain "can't connect" page. Nothing redirects, and the consent form is never rendered. Before this, unknown scopes were silently ignored.
  • Page: it already named the client and showed only the redirect host. It now adds an "It asked for:" list, one sentence per scope. The client name is escaped.
  • Tests: test/oauth-consent-words.test.ts covers each scope's sentence, the client name and host-only redirect, refusal of admin, ro admin and rw nonsense, and a hostile client name.
  • Docs: I added docs/features/oauth-consent.md and indexed it in docs/features/README.md. The issue named docs/features/oauth.md, which doesn't exist, so I used a new file.
  • Not done: the consent screen has no terminal door (the commit says No door:), and there's no looks page for it because it needs a signed-in OAuth session (No look:).

To try it, register a client at POST /oauth/register, then open /oauth/authorize?scope=ro%20admin (refused) and scope=ro (sentence listed).

Closes #13601

commented

Both review points are fixed and pushed.

What changed

  • Each sentence once. I removed the "It asked for" list. The ro and rw sentences now appear only on the Read / Read and act radios. The openid, profile and email sentences appear only in the "What it will learn about you" fieldset. The hand-rolled <ul> and <code> markup went with the list, so there is no new component class.
  • Unknown scopes ignored again. parseAuthRequest no longer returns a 400 for them. ro offline_access is granted ro, and admin alone still gets the ro default. The asked field on AuthRequest is gone.
  • Typed properly. AuthRequest.oidcScopes is now OidcScope[]. identity() indexes SCOPE_WORDS directly, so the as keyof … ?? "" cast is gone.
  • Tests. Each scope's sentence now appears exactly once on the page. A new test checks that admin, ro offline_access, rw nonsense and offline_access still render the consent form, and that rw offline_access pre-selects rw. The old refusal test is gone. docs/features/oauth-consent.md is updated to match.

Checks

  • bun x tsc --noEmit and bun scripts/gate.ts --fix are clean.
  • bun scripts/design-lint.ts reports nothing outside the system.
  • test/oauth-consent-words.test.ts passes, 8 of 8.
  • The first run of the broader OAuth tests had one failure, my own new assertion that the page never contains offline_access. It was wrong, because the existing hidden scope field echoes the raw request. I dropped that line and re-ran only the consent-words file, so the other OAuth suites have not been re-run since.
  • I did not open the preview.

Left out: I did not add anything that shows ignored scopes to the person. The page lists only what the forge will actually grant.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs