Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

check if OIDC provider supports PKCE before applying it

x8a035c8d82e8
diff --git a/backend/src/ee/services/oidc/oidc-config-service.ts b/backend/src/ee/services/oidc/oidc-config-service.ts
index 4709a19308..ce702fc954 100644
--- a/backend/src/ee/services/oidc/oidc-config-service.ts
+++ b/backend/src/ee/services/oidc/oidc-config-service.ts
@@ -685,14 +685,17 @@ export const oidcConfigServiceFactory = ({
id_token_signed_response_alg: oidcCfg.jwtSignatureAlgorithm
});
+ // Check if the OIDC provider supports PKCE
+ const codeChallengeMethods = client.issuer.metadata.code_challenge_methods_supported;
+ const supportsPKCE =
+ !codeChallengeMethods || (Array.isArray(codeChallengeMethods) && codeChallengeMethods.includes("S256"));
+
const strategy = new OpenIdStrategy(
{
client,
passReqToCallback: true,
- usePKCE: true,
- params: {
- code_challenge_method: "S256"
- }
+ usePKCE: supportsPKCE,
+ params: supportsPKCE ? { code_challenge_method: "S256" } : undefined
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(_req: any, tokenSet: TokenSet, cb: any) => {