Skip to content

Commit 99f34a9

Browse files
Merge pull request #459 from codeanker/fix/oidc-redirect
fix: redirect based on request host
2 parents 1fb71ec + 0f1e04b commit 99f34a9

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

apps/api/src/routes/oidc/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,16 @@ oidcRouter.get('/dlrg/login', async (c) => {
136136
const as = await oauth.processDiscoveryResponse(issuer, discoveryRequestResponse)
137137
const authorizationUrl = new URL(as.authorization_endpoint!)
138138

139-
const redirectUri = new URL('/api/connect/dlrg/callback', config.clientUrl)
139+
const host = await prisma.hostname.findFirst({
140+
where: {
141+
hostname: c.req.header('Host'),
142+
}
143+
})
144+
if (host === null) {
145+
return c.text('Invalid domain', 400)
146+
}
147+
148+
const redirectUri = new URL('/api/connect/dlrg/callback', host.hostname)
140149
const registerAs = c.req.query('as')?.trim()
141150
if (registerAs !== undefined && registerAs?.length > 0) {
142151
redirectUri.searchParams.set('as', registerAs)

0 commit comments

Comments
 (0)