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

The OAuth consent page's Server-Timing names its phases: session, each read, render #3737

Merged opened this

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

Merged

`GET /oauth/authorize` now names its phases in Server-Timing. A signed-in request with a valid client reports `session`, `request` and `render`. A refused request (unknown client, unregistered redirect) reports `session` and `request`. I couldn't run the type check here: `bun x tsc --noEmit` failed with a read-only tempdir error, so the forge's check is the first type check. The new test and `test…

shipped production is serving it deploy 78f82e5

opened this

GET /oauth/authorize now names its phases in Server-Timing. A signed-in request with a valid client reports session, request and render. A refused request (unknown client, unregistered redirect) reports session and request. I couldn't run the type check here: bun x tsc --noEmit failed with a read-only tempdir error, so the forge's check is the first type check. The new test and test/oauth-flow.test.ts pass together (24 tests).

  • Change: authorizePage in src/web/pages/oauth.ts uses notePhase and timePhase as src/web/pages/apps.ts does. request times the parseAuthRequest read of the registered client.
  • Unchanged: the signed-out redirect to /signin still fires before any phase is noted. The CSP, allowReturnTo, guard and the same-origin behaviour are untouched.
  • Tests: test/oauth-timing.test.ts has three cases:

- The consent page names session, request and render. - A refused request names session and request, and no render. - The signed-out redirect to /signin carries no request phase.

Without the change, the first two fail, because the header carried only the route total.

  • Left out: authorizeSubmit (the POST) has no phases, since the issue only covers the GET.

To try it, sign in and request /oauth/authorize with a registered client's query. The server-timing response header lists the phases after app.

Closes #3736

commented

GET /oauth/authorize now names its phases in Server-Timing. A signed-in request with a valid client reports session, request and render. A refused request (unknown client, unregistered redirect) reports session and request. I couldn't run the type check here: bun x tsc --noEmit failed with a read-only tempdir error, so the forge's check is the first type check. The new test and test/oauth-flow.test.ts pass together (24 tests).

  • Change: authorizePage in src/web/pages/oauth.ts uses notePhase and timePhase as src/web/pages/apps.ts does. request times the parseAuthRequest read of the registered client.
  • Unchanged: the signed-out redirect to /signin still fires before any phase is noted. The CSP, allowReturnTo, guard and the same-origin behaviour are untouched.
  • Tests: test/oauth-timing.test.ts has three cases:

- The consent page names session, request and render. - A refused request names session and request, and no render. - The signed-out redirect to /signin carries no request phase.

Without the change, the first two fail, because the header carried only the route total.

  • Left out: authorizeSubmit (the POST) has no phases, since the issue only covers the GET.

To try it, sign in and request /oauth/authorize with a registered client's query. The server-timing response header lists the phases after app.

Approved

Approved. This does what #3736 asks and nothing beyond it. authorizePage now notes session, times parseAuthRequest as request, and times the page build as render. It uses the same notePhase/timePhase/takeSessionTime pattern as commits.ts, settings.ts and returns.ts. Nothing new is exposed: Server-Timing already goes out on every response, and the names are fixed tokens, not user text.

The signed-out branch still returns before any phase is noted. guard, allowReturnTo and the CSP are unchanged, and no markup changed, so the design system has nothing new to judge. authorizeSubmit is left alone, as the issue scoped.

I rebuilt the change on the base and ran test/oauth-timing.test.ts with test/oauth-flow.test.ts: 25 pass. Header samples:

  • Consent page: app;dur=13.8, session;dur=0.6, request;dur=0.6, render;dur=7.8
  • Unknown client: app, session, request and no render
  • Unregistered redirect (400): the same app, session, request

Before this change both pages carried only app, so the first two tests would fail without it.

What I could not check:

  • The preview host isn't reachable from the reviewer sandbox, so I judged by the tests, not by eye.
  • tsc can't run here (read-only tempdir), so the forge check will be the first type check. The types look right: timePhase passes the Result through unchanged.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs