Merge pull request #3223 from Infisical/misc/improve-support-for-jwks-via-http

misc: improve support for jwks via http
This commit is contained in:
Akhil Mohan
2025-03-11 23:02:17 +05:30
committed by GitHub

View File

@@ -78,14 +78,22 @@ export const identityJwtAuthServiceFactory = ({
let tokenData: Record<string, string | boolean | number> = {}; let tokenData: Record<string, string | boolean | number> = {};
if (identityJwtAuth.configurationType === JwtConfigurationType.JWKS) { if (identityJwtAuth.configurationType === JwtConfigurationType.JWKS) {
const decryptedJwksCaCert = orgDataKeyDecryptor({ let client: JwksClient;
cipherTextBlob: identityJwtAuth.encryptedJwksCaCert if (identityJwtAuth.jwksUrl.includes("https:")) {
}).toString(); const decryptedJwksCaCert = orgDataKeyDecryptor({
const requestAgent = new https.Agent({ ca: decryptedJwksCaCert, rejectUnauthorized: !!decryptedJwksCaCert }); cipherTextBlob: identityJwtAuth.encryptedJwksCaCert
const client = new JwksClient({ }).toString();
jwksUri: identityJwtAuth.jwksUrl,
requestAgent 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 { kid } = decodedToken.header;
const jwtSigningKey = await client.getSigningKey(kid); const jwtSigningKey = await client.getSigningKey(kid);