From 37f84cfba55fc14aab6a14eb7e2babe68b3ae129 Mon Sep 17 00:00:00 2001 From: Aarnav Tale Date: Sat, 30 Mar 2024 05:17:53 -0400 Subject: [PATCH] fix: use the request url protocol for oidc --- app/utils/oidc.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/utils/oidc.ts b/app/utils/oidc.ts index 77ab240..df84684 100644 --- a/app/utils/oidc.ts +++ b/app/utils/oidc.ts @@ -43,7 +43,10 @@ export async function startOidc(issuer: string, client: string, request: Request const nonce = generateRandomNonce() const verifier = generateRandomCodeVerifier() const challenge = await calculatePKCECodeChallenge(verifier) + const callback = new URL('/admin/oidc/callback', request.url) + callback.protocol = request.url.includes('localhost') ? 'http:' : 'https:' + callback.hostname = request.headers.get('Host') ?? '' const authUrl = new URL(processed.authorization_endpoint) authUrl.searchParams.set('client_id', oidcClient.client_id) @@ -106,6 +109,9 @@ export async function finishOidc(issuer: string, client: string, secret: string, } const callback = new URL('/admin/oidc/callback', request.url) + callback.protocol = request.url.includes('localhost') ? 'http:' : 'https:' + callback.hostname = request.headers.get('Host') ?? '' + const tokenResponse = await authorizationCodeGrantRequest(processed, oidcClient, parameters, callback.href, verifier) const challenges = parseWwwAuthenticateChallenges(tokenResponse) if (challenges) {