From 75c2d26f6885dad72dc3d04f32d1bcfffaaede5f Mon Sep 17 00:00:00 2001 From: Max Farrell Date: Thu, 5 Nov 2026 19:53:46 -0600 Subject: [PATCH] Show why an OAuth consent request was rejected The consent page replaced every AuthorizationError with a generic 'could not be verified', hiding the library's specific, non-sensitive reason (e.g. authorization not started in this browser, expired or already used, unknown client, redirect mismatch) and logging nothing, so real-world failures could not be diagnosed. Show the reason to the signed-in admin and log it. Co-Authored-By: Claude Sonnet 5.5 --- scripts/oauth-smoke.mjs | 7 ++++++- src/routes/admin/oauth/authorize/+server.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/oauth-smoke.mjs b/scripts/oauth-smoke.mjs index b5221c3..72c6f04 100644 --- a/scripts/oauth-smoke.mjs +++ b/scripts/oauth-smoke.mjs @@ -216,11 +216,16 @@ export async function testOAuth({ 'framework still rejects cross-site admin form posts', ); const csrf = await consentPage('cms:read'); + const unbound = await decide({ ...csrf, cookie: '' }, ['cms:read']); assert.equal( - (await decide({ ...csrf, cookie: '' }, ['cms:read'])).status, + unbound.status, 400, 'consent cannot be forged without browser cookie', ); + assert.ok( + (await unbound.text()).includes('not started in this browser'), + 'a rejected consent explains why, so failures can be diagnosed', + ); const crossOrigin = await consentPage('cms:read'); assert.ok( ( diff --git a/src/routes/admin/oauth/authorize/+server.ts b/src/routes/admin/oauth/authorize/+server.ts index 9f59603..40d799a 100644 --- a/src/routes/admin/oauth/authorize/+server.ts +++ b/src/routes/admin/oauth/authorize/+server.ts @@ -49,8 +49,12 @@ function authorizationFailure(error: unknown) { status: 302, headers: { Location: error.redirectTo, 'Cache-Control': 'no-store' }, }); + // The library's descriptions are fixed, non-sensitive sentences (e.g. "This authorization was + // not started in this browser; start again"). Only a signed-in admin reaches this page, and + // without the reason a failure cannot be diagnosed (the generic text hid it). + console.warn('OAuth consent rejected', error.code, error.description); return page( - '

Connection request could not be verified

Return to your client and start the connection again.

', + `

Connection request could not be verified

${escape(error.description)}

Return to your client and start the connection again.

`, 400, ); } @@ -59,6 +63,7 @@ function authorizationFailure(error: unknown) { '

Client identity is unavailable

The client metadata could not be verified. Try again from your client.

', 400, ); + console.error('OAuth consent failed', error); return page( '

Connection could not be completed

Return to your client and try again.

', 503,