Skip to content

Scheduling infrastructure for absolutely everyone.

Fix Keycloak OIDC flow (#27716)

Richard Henkenjohann2509116b28f2
diff --git a/apps/web/app/api/auth/oidc/route.ts b/apps/web/app/api/auth/oidc/route.ts
index 693ae9a203d..30799e3c708 100644
--- a/apps/web/app/api/auth/oidc/route.ts
+++ b/apps/web/app/api/auth/oidc/route.ts
@@ -9,20 +9,18 @@ import logger from "@calcom/lib/logger";
// This is the callback endpoint for the OIDC provider
// A team must set this endpoint in the OIDC provider's configuration
async function handler(req: NextRequest) {
- const log = logger.getSubLogger({ prefix: ["[ODIC auth]"] });
+ const log = logger.getSubLogger({ prefix: ["[OIDC auth]"] });
const { searchParams } = req.nextUrl;
- const code = searchParams.get("code");
- const state = searchParams.get("state");
- const tenant = searchParams.get("tenant");
+ const params = Object.fromEntries(searchParams.entries());
- if (!code || !state) {
+ if (!params.code || !params.state) {
return NextResponse.json({ message: "Code and state are required" }, { status: 400 });
}
const { oauthController } = await jackson();
try {
- const { redirect_url } = await oauthController.oidcAuthzResponse({ code, state });
+ const { redirect_url } = await oauthController.oidcAuthzResponse(params);
if (!redirect_url) {
throw new HttpError({
@@ -33,7 +31,7 @@ async function handler(req: NextRequest) {
return NextResponse.redirect(redirect_url, 302);
} catch (err) {
- log.error(`Error authorizing tenant ${tenant}: ${err}`);
+ log.error(`Error authorizing tenant ${params.tenant}: ${err}`);
const { message, statusCode = 500 } = err as HttpError;
return NextResponse.json({ message }, { status: statusCode });