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

scout/forge:scout/13601-the-oauth-consent-page-names-the-client → main 3 commits fork 2 threads · 2 unresolved

  • Merged. scout/13601-the-oauth-consent-page-names-the-client was merged into main as d3d4ab2.

Review

Sign in to review this change.
5 files changed +128 −14
docs/features/README.md +1
@@ -378,6 +378,7 @@ Read with the guide page [Agents: MCP, git, or the terminal](../guide-agents.md)
378378 - [Atom feeds](atom.md)
379379 - [Guest pulls](guest-pulls.md)
380380 - [How a person with no account gets in to contribute](guests.md)
381 - [OAuth consent words](oauth-consent.md)
381382 - [Connected agents](oauth-grants.md)
382383 - [OAuth refresh](oauth-refresh.md)
383384 - [OAuth revoke](oauth-revoke.md)
src/core/oauth.ts +17 −2
@@ -7,7 +7,7 @@ import type { Database } from "bun:sqlite";
77 import { sha256 } from "../kernel/hash.ts";
88 import { id, secret } from "../kernel/id.ts";
99 import { err, ok, type Result } from "../kernel/result.ts";
10 import { NONCE_MAX, oidcScopes, recordGrant, signIdToken } from "./oidc.ts";
10 import { NONCE_MAX, oidcScopes, recordGrant, signIdToken, type OidcScope } from "./oidc.ts";
1111 import { createToken, listTokens, type TokenInfo } from "./tokens.ts";
1212 import { getUserById, isActive } from "./users.ts";
1313
@@ -187,6 +187,20 @@ export type OAuthScope = (typeof OAUTH_SCOPES)[number];
187187 export const isOAuthScope = (v: string): v is OAuthScope =>
188188 OAUTH_SCOPES.some((scope) => scope === v);
189189
190 /**
191 * One plain sentence per scope the authorize page can name: the page reads
192 * its words here, so a scope cannot be granted that has no sentence, and a
193 * sentence cannot outlive its scope. `ro`/`rw` are the API grants, the rest
194 * are what an OpenID sign-in tells the app about the person.
195 */
196 export const SCOPE_WORDS: Readonly<Record<OAuthScope | OidcScope, string>> = {
197 ro: "Read: see your apps, issues and runs",
198 rw: "Read and act: tell the crew, plan, and change things as you",
199 openid: "who you are on this forge (an identifier that stays the same)",
200 profile: "your username and name",
201 email: "your email address",
202 };
203
190204 /** A valid authorization request: the client is real and the redirect is one it registered. */
191205 export interface AuthRequest {
192206 readonly client: OAuthClient;
@@ -195,7 +209,7 @@ export interface AuthRequest {
195209 readonly state: string;
196210 readonly scope: OAuthScope;
197211 /** `openid` and the OIDC scopes asked with it; empty for a plain OAuth grant. */
198 readonly oidcScopes: readonly string[];
212 readonly oidcScopes: readonly OidcScope[];
199213 readonly nonce: string;
200214 /** OpenID scopes and no `ro`/`rw`: the person is signed in, no API token is granted. */
201215 readonly signInOnly: boolean;
@@ -229,6 +243,7 @@ export function parseAuthRequest(
229243 return err("The code_challenge is not a base64url SHA-256.");
230244 const state = get("state");
231245 if (state.length > STATE_MAX) return err("The state is too long.");
246 // Scopes the forge does not offer are ignored, as they always were.
232247 const asked = get("scope").split(/\s+/).find(isOAuthScope);
233248 const oidc = oidcScopes(get("scope"));
234249 const openid = oidc.includes("openid");
src/web/pages/oauth.ts +7 −12
@@ -11,6 +11,7 @@ import {
1111 LIFETIMES,
1212 parseAuthRequest,
1313 redirectWith,
14 SCOPE_WORDS,
1415 tokenName,
1516 type AuthRequest,
1617 } from "../../core/oauth.ts";
@@ -36,8 +37,9 @@ const PARAMS = [
3637 /** Nothing here is cacheable, and nothing here may be sent on as a referrer. */
3738 const guard = (response: Response): Response => {
3839 response.headers.set("cache-control", "no-store");
39 // same-origin, not no-referrer: no-referrer makes the browser send `Origin: null` on the consent form's
40 // own POST, and the CSRF gate refused every consent (2026-10-27). Other sites still get no referrer.
40 // same-origin, not no-referrer: no-referrer makes the browser send `Origin: null` on the consent
41 // form's own POST, and the CSRF gate refused every consent (2026-10-27). Other sites still get no
42 // referrer.
4143 response.headers.set("referrer-policy", "same-origin");
4244 return response;
4345 };
@@ -77,20 +79,13 @@ const refused = (ctx: Ctx, message: string): Response =>
7779 const hidden = (name: string, value: string): Html =>
7880 html`<input type="hidden" name="${name}" value="${value}" />`;
7981
80 /** What an OpenID grant tells the app about the person, in plain words. */
81 const IDENTITY: Record<string, string> = {
82 openid: "who you are on this forge (an identifier that stays the same)",
83 profile: "your username and name",
84 email: "your email address",
85 };
86
8782 const identity = (request: AuthRequest): Html | "" =>
8883 request.oidcScopes.length === 0
8984 ? ""
9085 : html`<fieldset class="field">
9186 <legend>What it will learn about you</legend>
9287 <ul>
93 ${request.oidcScopes.map((s) => html`<li>${IDENTITY[s] ?? s}</li>`)}
88 ${request.oidcScopes.map((s) => html`<li>${SCOPE_WORDS[s]}</li>`)}
9489 </ul>
9590 </fieldset>`;
9691
@@ -136,12 +131,12 @@ function consent(ctx: Ctx, request: AuthRequest, values: Params): Html {
136131 <label
137132 ><input type="radio" name="grant" value="ro"
138133 ${request.scope === "ro" ? "checked" : ""} />
139 Read: see your apps, issues and runs</label
134 ${SCOPE_WORDS.ro}</label
140135 >
141136 <label
142137 ><input type="radio" name="grant" value="rw"
143138 ${request.scope === "rw" ? "checked" : ""} />
144 Read and act: tell the crew, plan, and change things as you</label
139 ${SCOPE_WORDS.rw}</label
145140 >
146141 </fieldset>
147142 ${formField({

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs