Skip to content

Commit e747ceb

Browse files
committed
fix(pages,oauth): avoid double base; proxy client_id optional
1 parent 16de217 commit e747ceb

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

app/src/lib/data/catalog/cloudSnapshot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async function fetchBundledJson<T>(path: string): Promise<T | null> {
7474

7575
async function readBundledCurrentEntries(): Promise<CurrentTermEntry[] | null> {
7676
if (!browser) return null;
77-
return fetchBundledJson<CurrentTermEntry[]>(withBasePath('/crawler/data/current.json'));
77+
return fetchBundledJson<CurrentTermEntry[]>('/crawler/data/current.json');
7878
}
7979

8080
async function readBundledTermSnapshotText(termId: string): Promise<string | null> {

app/src/lib/policies/github/oauthPkce.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ export async function completeGithubPkceCallback(url: URL): Promise<GithubPkceCa
178178
'Content-Type': 'application/json'
179179
},
180180
body: JSON.stringify({
181-
client_id: availability.clientId,
182181
code,
183182
redirect_uri: session.redirectUri,
184183
code_verifier: session.verifier

oauth-proxy/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,21 @@ async function handleToken(request: Request, env: Env): Promise<Response> {
5252
return withCors(request, env, new Response('Invalid JSON', { status: 400 }));
5353
}
5454

55-
const client_id = typeof payload?.client_id === 'string' ? payload.client_id.trim() : '';
55+
const payloadClientId = typeof payload?.client_id === 'string' ? payload.client_id.trim() : '';
5656
const code = typeof payload?.code === 'string' ? payload.code.trim() : '';
5757
const redirect_uri = typeof payload?.redirect_uri === 'string' ? payload.redirect_uri.trim() : '';
5858
const code_verifier = typeof payload?.code_verifier === 'string' ? payload.code_verifier.trim() : '';
5959

60+
// If the worker is configured with a fixed client_id, prefer it and allow callers to omit client_id entirely.
61+
const configuredClientId = String(env.GITHUB_CLIENT_ID || '').trim();
62+
const client_id = payloadClientId || configuredClientId;
63+
6064
if (!client_id || !code || !redirect_uri || !code_verifier) {
6165
return withCors(request, env, new Response('Missing required fields', { status: 400 }));
6266
}
6367

6468
// Optional hardening: if the worker is configured with a fixed client_id, reject mismatches.
65-
const configuredClientId = String(env.GITHUB_CLIENT_ID || '').trim();
66-
if (configuredClientId && configuredClientId !== client_id) {
69+
if (configuredClientId && payloadClientId && configuredClientId !== payloadClientId) {
6770
return withCors(request, env, new Response('Invalid client_id', { status: 400 }));
6871
}
6972

0 commit comments

Comments
 (0)