Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions scripts/oauth-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ export async function testOAuth({
response.headers.get('content-security-policy') ?? '',
/frame-ancestors 'none'/,
);
// A browser sends "Origin: null" on this page's same-origin POST under 'no-referrer', which the
// CSRF check rejects, so the Connect button would fail for real users.
assert.equal(
response.headers.get('referrer-policy'),
'same-origin',
'consent page must keep real same-origin Origin headers on its form post',
);
const handle = /name="handle"\s+value="([^"]+)"/.exec(html)?.[1];
assert.ok(handle, 'browser-bound consent handle rendered');
const cookie = response.headers
Expand Down
4 changes: 3 additions & 1 deletion src/routes/admin/oauth/authorize/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ function page(body: string, status = 200, extra?: Headers) {
headers.set('Content-Type', 'text/html; charset=utf-8');
headers.set('Cache-Control', 'no-store');
headers.set('X-Frame-Options', 'DENY');
headers.set('Referrer-Policy', 'no-referrer');
// Not 'no-referrer': browsers then send "Origin: null" on the page's own same-origin form POST,
// which the CSRF check rightly rejects ("Cross-site POST form submissions are forbidden").
headers.set('Referrer-Policy', 'same-origin');
headers.set(
'Content-Security-Policy',
"default-src 'none'; style-src 'unsafe-inline'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'",
Expand Down
Loading