fix: build oidc callback url in a more proper way (#28)

This commit is contained in:
Akira Yamazaki 2024-10-08 11:23:31 +08:00 committed by GitHub
parent 98d1cb1333
commit 29d91785fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,8 +51,8 @@ export async function startOidc(oidc: OidcConfig, req: Request) {
const challenge = await calculatePKCECodeChallenge(verifier)
const callback = new URL('/admin/oidc/callback', req.url)
callback.protocol = req.url.includes('localhost') ? 'http:' : 'https:'
callback.hostname = req.headers.get('Host') ?? ''
callback.protocol = req.headers.get('X-Forwarded-Proto') ?? 'http:'
callback.host = req.headers.get('Host') ?? ''
const authUrl = new URL(processed.authorization_endpoint)
authUrl.searchParams.set('client_id', oidcClient.client_id)
@ -119,8 +119,8 @@ export async function finishOidc(oidc: OidcConfig, req: Request) {
}
const callback = new URL('/admin/oidc/callback', req.url)
callback.protocol = req.url.includes('localhost') ? 'http:' : 'https:'
callback.hostname = req.headers.get('Host') ?? ''
callback.protocol = req.headers.get('X-Forwarded-Proto') ?? 'http:'
callback.host = req.headers.get('Host') ?? ''
const tokenResponse = await authorizationCodeGrantRequest(
processed,