Skip to content

Commit 925667b

Browse files
committed
fix(oauth-proxy): ignore stale client_id
1 parent c73d374 commit 925667b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

oauth-proxy/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ async function handleToken(request: Request, env: Env): Promise<Response> {
6565
return withCors(request, env, new Response('Missing required fields', { status: 400 }));
6666
}
6767

68-
// Optional hardening: if the worker is configured with a fixed client_id, reject mismatches.
69-
if (configuredClientId && payloadClientId && configuredClientId !== payloadClientId) {
70-
return withCors(request, env, new Response('Invalid client_id', { status: 400 }));
71-
}
68+
// Hardening: if a fixed client_id is configured, always use it and ignore any caller-provided client_id.
69+
// This prevents stale frontend bundles (or user tampering) from breaking token exchange with "Invalid client_id".
70+
// Origin restriction still applies via ALLOWED_ORIGINS, and the GitHub secret remains server-side only.
71+
const effectiveClientId = configuredClientId || client_id;
7272

73-
const params = new URLSearchParams({ client_id, code, redirect_uri, code_verifier });
73+
const params = new URLSearchParams({ client_id: effectiveClientId, code, redirect_uri, code_verifier });
7474
const clientSecret = String(env.GITHUB_CLIENT_SECRET || '').trim();
7575
if (clientSecret) params.set('client_secret', clientSecret);
7676

0 commit comments

Comments
 (0)