Skip to content

Commit 61b8509

Browse files
author
flowcore-platform
committed
fix: enable PKCE for Keycloak OAuth to prevent invalid_grant errors
Added code_challenge_method: "S256" to KeycloakProvider authorization params to enable PKCE (Proof Key for Code Exchange). This prevents double-submit and code replay attacks that were causing invalid_grant errors during OAuth callback, which manifested as 502 Bad Gateway errors in the browser. PKCE adds an extra layer of security and ensures authorization codes can only be used once by the client that initiated the OAuth flow.
1 parent 9fa36a6 commit 61b8509

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/auth.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ export const authOptions: NextAuthOptions = {
130130
scope: "openid email profile offline_access",
131131
// Request token with correct audience for MCP server
132132
audience: env.USABLE_CLIENT_ID,
133+
// Enable PKCE (Proof Key for Code Exchange) to prevent double-submit and code replay attacks
134+
code_challenge_method: "S256",
133135
},
134136
},
135137
}),

0 commit comments

Comments
 (0)