fix: read oidc configuration from env then config

This commit is contained in:
Aarnav Tale 2024-03-30 19:11:13 -04:00
parent 78140927ad
commit 6fa27e5d28
No known key found for this signature in database
3 changed files with 48 additions and 11 deletions

View file

@ -1,15 +1,15 @@
import { type LoaderFunctionArgs } from '@remix-run/node'
import { getContext } from '~/utils/config'
import { finishOidc } from '~/utils/oidc'
export async function loader({ request }: LoaderFunctionArgs) {
const issuer = process.env.OIDC_ISSUER
const id = process.env.OIDC_CLIENT_ID
const secret = process.env.OIDC_CLIENT_SECRET
const context = await getContext()
const oidc = context.oidcConfig
if (!issuer || !id || !secret) {
if (!oidc) {
throw new Error('An invalid OIDC configuration was provided')
}
return finishOidc(issuer, id, secret, request)
return finishOidc(oidc.issuer, oidc.client, oidc.secret, request)
}