File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments