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

Merged opened this

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

Merged

mason/forge:mason/14069-the-oauth-consent-page-lists-in-plain-wo → main 6 commits fork 3 threads · 3 unresolved

  • Merged. mason/14069-the-oauth-consent-page-lists-in-plain-wo was merged into main as c985f8c.

Review

Sign in to review this change.
3 files changed +37 −12
src/core/oauth.ts +3 −1
@@ -243,7 +243,9 @@ export function parseAuthRequest(
243243 return err("The code_challenge is not a base64url SHA-256.");
244244 const state = get("state");
245245 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.
246 const unknown = get("scope").split(/\s+/).find((v) => v !== "" && !Object.hasOwn(SCOPE_WORDS, v));
247 if (unknown !== undefined)
248 return err("This forge does not offer the scope " + JSON.stringify(unknown.slice(0, 40)) + ".");
247249 const asked = get("scope").split(/\s+/).find(isOAuthScope);
248250 const oidc = oidcScopes(get("scope"));
249251 const openid = oidc.includes("openid");
src/web/pages/oauth.ts +13 −3
@@ -111,6 +111,12 @@ function signInConsent(request: AuthRequest, values: Params): Html {
111111 </div>`;
112112 }
113113
114 /** The calendar day a token minted now would stop working, in words. */
115 const endsOn = (lifetime: string): string => {
116 const seconds = LIFETIMES[lifetime] ?? 0;
117 return new Date(Date.now() + seconds * 1000).toISOString().slice(0, 10);
118 };
119
114120 function consent(ctx: Ctx, request: AuthRequest, values: Params): Html {
115121 if (request.signInOnly) return signInConsent(request, values);
116122 const host = new URL(request.redirectUri).host;
@@ -150,10 +156,14 @@ function consent(ctx: Ctx, request: AuthRequest, values: Params): Html {
150156 <label for="f-lifetime">Lasts</label>
151157 <select class="input" id="f-lifetime" name="lifetime">
152158 <option value="never" selected>Until I revoke it</option>
153 <option value="year">A year</option>
154 <option value="month">30 days</option>
155 <option value="day">A day</option>
159 <option value="year">A year (until ${endsOn("year")})</option>
160 <option value="month">30 days (until ${endsOn("month")})</option>
161 <option value="day">A day (until ${endsOn("day")})</option>
156162 </select>
163 <p class="muted small">

Wrong destination: OAuth grants are revoked at /settings/grants (Connected agents), not /settings/tokens (Access codes). Fix the href and label. Principle 8 (plain words): 'Revoke it any time under Connected agents.'

164 Revoke it any time under
165 <a href="/settings/grants">Connected agents</a>.
166 </p>
157167 </div>
158168 <div class="form-actions">
159169 ${btn("Allow", { variant: "primary", name: "decision", value: "allow" })}

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs