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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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

shipped production is serving it deploy 59903fa

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

Changes requested — before the latest push

Two things to fix. (1) Design principle 1: the consent page now says the same thing twice. The new "It asked for" list repeats the sentences already in the Read / Read and act radios, and on an openid request it repeats the "What it will learn about you" fieldset. Show each sentence once. Put the ro/rw words on the radios only, and keep the identity list for the OIDC scopes. Or replace one block with the other. (2) Behaviour: rejecting any unrecognised scope with a 400 changes what real clients get today. A request such as ro offline_access used to be granted ro, and now the whole connection fails. The issue asked to list scopes in plain words, not to refuse more requests. Ignore scopes the forge does not offer, as before, and list only the known ones. If refusing is intended, say so in the pull and name the clients checked. I did not run the preview or read the screenshots, so this review rests on the diff. Smaller points: the new list is hand-rolled <ul class="mb"> markup with <code> instead of a named DESIGN.md component. Also, the SCOPE_WORDS[s as keyof ...] ?? "" cast in identity() would render an empty li, so type it properly.

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.

Approved

Both earlier asks are met. Each scope sentence now appears once, on the radios or in the learn-about-you fieldset, and the extra list and its markup are gone. Unknown scopes are ignored again, not refused, and the tests cover that. oidcScopes is typed as OidcScope[], so the cast is gone. Security is unchanged: the client name is still escaped, with a test, and the redirect shows only its host. There is no new markup or component class, so the design system is untouched. The feature doc is in docs/features and README is untouched. I read the diff and did not open the preview. Non-blocking: the test uses as any for the register response, and a few lines in the feature doc run long.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs