check if OIDC provider supports PKCE before applying it

This commit is contained in:
x
2025-04-28 12:51:18 -04:00
parent 03d7f9f786
commit 8a035c8d82

View File

@@ -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) => {