Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
add credential validation for the remaining rotations
adilson0fe1aac8612b
diff --git a/backend/src/ee/services/secret-rotation-v2/hp-ilo-rotation/hp-ilo-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/hp-ilo-rotation/hp-ilo-rotation-fns.tsindex 39bcdf413a..36d005a51d 100644--- a/backend/src/ee/services/secret-rotation-v2/hp-ilo-rotation/hp-ilo-rotation-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/hp-ilo-rotation/hp-ilo-rotation-fns.ts@@ -3,6 +3,7 @@ import { Client, ClientChannel } from "ssh2";import {TRotationFactory,+ TRotationFactoryCheckActiveCredentials,TRotationFactoryGetSecretsPayload,TRotationFactoryIssueCredentials,TRotationFactoryRevokeCredentials,@@ -206,6 +207,14 @@ export const hpIloRotationFactory: TRotationFactory<const { connection, parameters, secretsMapping, activeIndex } = secretRotation;const { username, passwordRequirements, rotationMethod = HpIloRotationMethod.LoginAsRoot } = parameters;+ const sshConfig: TSshConnectionConfig = {+ method: connection.method,+ app: connection.app,+ orgId: connection.orgId,+ gatewayId: connection.gatewayId,+ credentials: connection.credentials+ } as TSshConnectionConfig;+const $rotatePassword = async (currentPassword?: string): Promise<{ username: string; password: string }> => {const newPassword = generatePassword(passwordRequirements ?? HP_ILO_DEFAULT_PASSWORD_REQUIREMENTS);@@ -213,14 +222,6 @@ export const hpIloRotationFactory: TRotationFactory<if (username === connection.credentials.username)throw new BadRequestError({ message: "Provided username is used in Infisical app connections." });- const sshConfig: TSshConnectionConfig = {- method: connection.method,- app: connection.app,- orgId: connection.orgId,- gatewayId: connection.gatewayId,- credentials: connection.credentials- } as TSshConnectionConfig;-if (isSelfRotation && currentPassword) {await rotateIloPasswordAsTarget(sshConfig, gatewayV2Service, username, currentPassword, newPassword);} else {@@ -267,10 +268,17 @@ export const hpIloRotationFactory: TRotationFactory<];};+ const checkActiveCredentials: TRotationFactoryCheckActiveCredentials<+ THpIloRotationGeneratedCredentials+ > = async ({ username: activeUsername, password }) => {+ await verifyIloPassword(sshConfig, gatewayV2Service, activeUsername, password);+ };+return {issueCredentials,revokeCredentials,rotateCredentials,- getSecretsPayload+ getSecretsPayload,+ checkActiveCredentials};};diff --git a/backend/src/ee/services/secret-rotation-v2/ldap-password/ldap-password-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/ldap-password/ldap-password-rotation-fns.tsindex aa45e9a069..495287f370 100644--- a/backend/src/ee/services/secret-rotation-v2/ldap-password/ldap-password-rotation-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/ldap-password/ldap-password-rotation-fns.ts@@ -2,6 +2,7 @@ import ldap, { Client, SearchOptions } from "@infisical/ldapjs";import {TRotationFactory,+ TRotationFactoryCheckActiveCredentials,TRotationFactoryGetSecretsPayload,TRotationFactoryIssueCredentials,TRotationFactoryRevokeCredentials,@@ -511,10 +512,17 @@ export const ldapPasswordRotationFactory: TRotationFactory<return secrets;};+ const checkActiveCredentials: TRotationFactoryCheckActiveCredentials<+ TLdapPasswordRotationGeneratedCredentials+ > = async ({ dn: activeDn, password }) => {+ await $verifyCredentials({ dn: activeDn, password });+ };+return {issueCredentials,revokeCredentials,rotateCredentials,- getSecretsPayload+ getSecretsPayload,+ checkActiveCredentials};};diff --git a/backend/src/ee/services/secret-rotation-v2/mongodb-credentials/mongodb-credentials-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/mongodb-credentials/mongodb-credentials-rotation-fns.tsindex aad286ecc5..0ebf7a636e 100644--- a/backend/src/ee/services/secret-rotation-v2/mongodb-credentials/mongodb-credentials-rotation-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/mongodb-credentials/mongodb-credentials-rotation-fns.ts@@ -3,6 +3,7 @@ import { MongoClient } from "mongodb";import {TRotationFactory,+ TRotationFactoryCheckActiveCredentials,TRotationFactoryGetSecretsPayload,TRotationFactoryIssueCredentials,TRotationFactoryRevokeCredentials,@@ -182,10 +183,17 @@ export const mongodbCredentialsRotationFactory: TRotationFactory<return secrets;};+ const checkActiveCredentials: TRotationFactoryCheckActiveCredentials<+ TMongoDBCredentialsRotationGeneratedCredentials+ > = async (activeCredentials) => {+ await $validateCredentials(activeCredentials);+ };+return {issueCredentials,revokeCredentials,rotateCredentials,- getSecretsPayload+ getSecretsPayload,+ checkActiveCredentials};};diff --git a/backend/src/ee/services/secret-rotation-v2/redis-credentials/redis-credentials-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/redis-credentials/redis-credentials-rotation-fns.tsindex ba59f417e0..7974336f7e 100644--- a/backend/src/ee/services/secret-rotation-v2/redis-credentials/redis-credentials-rotation-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/redis-credentials/redis-credentials-rotation-fns.ts@@ -3,6 +3,7 @@ import Redis from "ioredis";import {TRotationFactory,+ TRotationFactoryCheckActiveCredentials,TRotationFactoryGetSecretsPayload,TRotationFactoryIssueCredentials,TRotationFactoryRevokeCredentials,@@ -74,6 +75,38 @@ export const redisCredentialsRotationFactory: TRotationFactory<}};+ const $validateCredentials = async (credentials: TRedisCredentialsRotationGeneratedCredentials[number]) => {+ const [hostIp] = await verifyHostInputValidity({ host: connection.credentials.host, isDynamicSecret: false });++ let conn: Redis | null = null;+ try {+ conn = new Redis({+ username: credentials.username,+ host: hostIp,+ port: connection.credentials.port,+ password: credentials.password,+ ...(connection.credentials.sslEnabled && {+ tls: {+ rejectUnauthorized: connection.credentials.sslRejectUnauthorized,+ ca: connection.credentials.sslCertificate+ }+ })+ });++ const result = await conn.auth(credentials.username, credentials.password, () => {});++ if (result !== "OK") {+ throw new BadRequestError({ message: `Invalid credentials, Redis returned ${result} status` });+ }++ await conn.ping();+ } catch (err) {+ throw new Error(redactPasswords(err, [credentials]));+ } finally {+ if (conn) await conn.quit();+ }+ };+/*** Creates a new user and password for the redis user using ACL*/@@ -185,10 +218,17 @@ export const redisCredentialsRotationFactory: TRotationFactory<{ key: secretsMapping.password, value: password }];+ const checkActiveCredentials: TRotationFactoryCheckActiveCredentials<+ TRedisCredentialsRotationGeneratedCredentials+ > = async (activeCredentials) => {+ await $validateCredentials(activeCredentials);+ };+return {issueCredentials,revokeCredentials,rotateCredentials,- getSecretsPayload+ getSecretsPayload,+ checkActiveCredentials};};diff --git a/backend/src/ee/services/secret-rotation-v2/unix-linux-local-account-rotation/unix-linux-local-account-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/unix-linux-local-account-rotation/unix-linux-local-account-rotation-fns.tsindex 84fc1d3f46..0fb4c19324 100644--- a/backend/src/ee/services/secret-rotation-v2/unix-linux-local-account-rotation/unix-linux-local-account-rotation-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/unix-linux-local-account-rotation/unix-linux-local-account-rotation-fns.ts@@ -2,6 +2,7 @@ import { Client, ClientChannel } from "ssh2";import {TRotationFactory,+ TRotationFactoryCheckActiveCredentials,TRotationFactoryGetSecretsPayload,TRotationFactoryIssueCredentials,TRotationFactoryRevokeCredentials,@@ -475,10 +476,17 @@ export const unixLinuxLocalAccountRotationFactory: TRotationFactory<];};+ const checkActiveCredentials: TRotationFactoryCheckActiveCredentials<+ TUnixLinuxLocalAccountRotationGeneratedCredentials+ > = async ({ username: activeUsername, password }) => {+ await $verifyCredentials(activeUsername, password);+ };+return {issueCredentials,revokeCredentials,rotateCredentials,- getSecretsPayload+ getSecretsPayload,+ checkActiveCredentials};};diff --git a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-fns.tsindex f431e82bde..39883391ee 100644--- a/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/windows-local-account-rotation/windows-local-account-rotation-fns.ts@@ -1,5 +1,6 @@import {TRotationFactory,+ TRotationFactoryCheckActiveCredentials,TRotationFactoryGetSecretsPayload,TRotationFactoryIssueCredentials,TRotationFactoryRevokeCredentials,@@ -159,10 +160,17 @@ export const windowsLocalAccountRotationFactory: TRotationFactory<];};+ const checkActiveCredentials: TRotationFactoryCheckActiveCredentials<+ TWindowsLocalAccountRotationGeneratedCredentials+ > = async ({ username: activeUsername, password }) => {+ await $verifyCredentials(activeUsername, password);+ };+return {issueCredentials,revokeCredentials,rotateCredentials,- getSecretsPayload+ getSecretsPayload,+ checkActiveCredentials};};