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( - '
Return to your client and start the connection again.
', + `${escape(error.description)}
Return to your client and start the connection again.
`, 400, ); } @@ -59,6 +63,7 @@ function authorizationFailure(error: unknown) { 'The client metadata could not be verified. Try again from your client.
', 400, ); + console.error('OAuth consent failed', error); return page( 'Return to your client and try again.
', 503,