Skip to content

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

misc: improve support for jwks via http

Sheen Capadngan4dc56033b121
diff --git a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
index 2c9b6306ec..555dc00a6c 100644
--- a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
+++ b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts
@@ -78,14 +78,22 @@ export const identityJwtAuthServiceFactory = ({
let tokenData: Record<string, string | boolean | number> = {};
if (identityJwtAuth.configurationType === JwtConfigurationType.JWKS) {
- const decryptedJwksCaCert = orgDataKeyDecryptor({
- cipherTextBlob: identityJwtAuth.encryptedJwksCaCert
- }).toString();
- const requestAgent = new https.Agent({ ca: decryptedJwksCaCert, rejectUnauthorized: !!decryptedJwksCaCert });
- const client = new JwksClient({
- jwksUri: identityJwtAuth.jwksUrl,
- requestAgent
- });
+ let client: JwksClient;
+ if (identityJwtAuth.jwksUrl.includes("https:")) {
+ const decryptedJwksCaCert = orgDataKeyDecryptor({
+ cipherTextBlob: identityJwtAuth.encryptedJwksCaCert
+ }).toString();
+
+ const requestAgent = new https.Agent({ ca: decryptedJwksCaCert, rejectUnauthorized: !!decryptedJwksCaCert });
+ client = new JwksClient({
+ jwksUri: identityJwtAuth.jwksUrl,
+ requestAgent
+ });
+ } else {
+ client = new JwksClient({
+ jwksUri: identityJwtAuth.jwksUrl
+ });
+ }
const { kid } = decodedToken.header;
const jwtSigningKey = await client.getSigningKey(kid);