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
address reviews
Andrey423692aa4ed0
diff --git a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.tsindex 8057de539e..835ae1a84a 100644--- a/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts+++ b/backend/src/ee/services/pam-account-rotation/pam-account-rotation-service.ts@@ -14,8 +14,9 @@ import { TKmsServiceFactory } from "@app/services/kms/kms-service";import { KmsDataKey } from "@app/services/kms/kms-types";import { TMembershipDALFactory } from "@app/services/membership/membership-dal";import { TMembershipRoleDALFactory } from "@app/services/membership/membership-role-dal";+import { TProjectDALFactory } from "@app/services/project/project-dal";-import { PamAccountType, PamProductRole } from "../pam/pam-enums";+import { PamAccountType, PamPostgresAuthMethod, PamProductRole } from "../pam/pam-enums";import {checkAccountAccess,getResourceIdsWithActions,@@ -28,6 +29,7 @@ import { PamTemplateSettingsSchema } from "../pam-account-template/pam-account-timport { TPamAccountDependencyDALFactory } from "../pam-discovery/pam-account-dependency-dal";import { resolveHostsViaDcDns, winrmRpcWithGateway } from "../pam-discovery/pam-discovery-fns";import { TPamDiscoverySourceDALFactory } from "../pam-discovery/pam-discovery-source-dal";+import { generateRdsAuthToken } from "../pam-session/aws-iam/aws-iam-federation";import {TGetPamAccountRotationDTO,TListPamRotationCandidatesDTO,@@ -78,6 +80,7 @@ type TPamAccountRotationServiceFactoryDep = {| "transaction">;pamDiscoverySourceDAL: Pick<TPamDiscoverySourceDALFactory, "find">;+ projectDAL: Pick<TProjectDALFactory, "findById">;permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission">;membershipDAL: Pick<TMembershipDALFactory, "findResourceMembershipsForActor">;membershipRoleDAL: Pick<TMembershipRoleDALFactory, "find">;@@ -105,6 +108,7 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServicgatewayPoolService,pamAccountDependencyDAL,pamDiscoverySourceDAL,+ projectDAL,rotationHandlers = PAM_ROTATION_FACTORY_MAP} = deps;@@ -123,7 +127,13 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServicreturn JSON.parse(decryptor({ cipherTextBlob: blob }).toString("utf-8")) as Record<string, unknown>;};- type TSqlAccountCredentials = { username: string; password?: string; authMethod?: string };+ type TSqlAccountCredentials = {+ username: string;+ password?: string;+ authMethod?: string;+ awsRegion?: string;+ roleArn?: string;+ };const decryptSqlCredentials = async (projectId: string,@@ -424,6 +434,35 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServicreturn visible.filter((v): v is { id: string; name: string; discoverySources: string[] } => v !== null);};+ // A rotator authenticates as itself to run the password change. An IAM login has no stored password,+ // so it gets the same short-lived token a session would.+ const resolveRotatorPassword = async (+ projectId: string,+ credentials: TSqlAccountCredentials,+ connectionDetails: Record<string, unknown>+ ): Promise<string> => {+ if (credentials.authMethod !== PamPostgresAuthMethod.AwsIam) {+ if (!credentials.password) {+ throw new BadRequestError({ message: "Rotation account has no stored password" });+ }+ return credentials.password;+ }++ const project = await projectDAL.findById(projectId);+ if (!project) throw new NotFoundError({ message: "Project not found" });++ const { host, port } = connectionDetails as { host: string; port: number };+ return generateRdsAuthToken({+ roleArn: credentials.roleArn as string,+ externalId: project.orgId,+ roleSessionName: "infisical-pam-rotation",+ region: credentials.awsRegion as string,+ host,+ port,+ username: credentials.username+ });+ };+const resolveRotator = async (account: TPamAccountDetail,targetCredentials: TSqlAccountCredentials,@@ -458,15 +497,13 @@ export const pamAccountRotationServiceFactory = (deps: TPamAccountRotationServicaccount.accountType as PamAccountType,rotator.encryptedCredentials);- if (!rotatorCredentials.password) {- throw new BadRequestError({ message: "Rotation account has no stored password" });- }const rotatorConnectionDetails = resolveConnectionDetails(account.accountType as PamAccountType,await decrypt(projectId, rotator.encryptedConnectionDetails));+ const rotatorPassword = await resolveRotatorPassword(projectId, rotatorCredentials, rotatorConnectionDetails);return {- auth: { username: rotatorCredentials.username, password: rotatorCredentials.password },+ auth: { username: rotatorCredentials.username, password: rotatorPassword },connectionDetails: rotatorConnectionDetails,gatewayId: rotator.gatewayId ?? rotator.templateGatewayId,gatewayPoolId: rotator.gatewayPoolId ?? rotator.templateGatewayPoolIddiff --git a/backend/src/ee/services/pam-account/pam-account-schemas.ts b/backend/src/ee/services/pam-account/pam-account-schemas.tsindex d8c306d732..c537e55b09 100644--- a/backend/src/ee/services/pam-account/pam-account-schemas.ts+++ b/backend/src/ee/services/pam-account/pam-account-schemas.ts@@ -133,7 +133,11 @@ export const ACCOUNT_TYPE_CONFIGS = {defaultValue: PamPostgresAuthMethod.Password,options: [{ label: "Password", value: PamPostgresAuthMethod.Password },- { label: "AWS IAM (RDS / Aurora)", value: PamPostgresAuthMethod.AwsIam }+ {+ label: "AWS IAM (RDS / Aurora)",+ value: PamPostgresAuthMethod.AwsIam,+ docsUrl: "https://infisical.com/docs/documentation/platform/pam/accounts/postgresql#aws-iam-authentication"+ }]},awsRegion: {@@ -763,7 +767,7 @@ export const ACCOUNT_TYPE_CONFIGS = {showWhen?: TFieldConditionHint;forceWhen?: readonly TFieldForcedRuleHint[];tooltip?: string;- options?: { label: string; value: string }[];+ options?: { label: string; value: string; docsUrl?: string }[];}>;internalMetadata?: z.ZodTypeAny;@@ -1060,7 +1064,7 @@ export const PamFieldDescriptorSchema = z.object({required: z.boolean(),secret: z.boolean(),optional: z.boolean().optional(),- options: z.array(z.object({ label: z.string(), value: z.string() })).optional(),+ options: z.array(z.object({ label: z.string(), value: z.string(), docsUrl: z.string().optional() })).optional(),// Value the form prefills the field with on createdefaultValue: z.union([z.string(), z.number(), z.boolean()]).optional(),@@ -1111,7 +1115,7 @@ type TFieldUiHint = {showWhen?: TFieldConditionHint;forceWhen?: readonly TFieldForcedRuleHint[];tooltip?: string;- options?: { label: string; value: string }[];+ options?: { label: string; value: string; docsUrl?: string }[];};const humanizeKey = (key: string) => {diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 3814fb4862..2a48dbacf9 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -1954,7 +1954,8 @@ export const registerRoutes = async (gatewayV2Service,gatewayPoolService,pamAccountDependencyDAL,- pamDiscoverySourceDAL+ pamDiscoverySourceDAL,+ projectDAL});const pamSessionService = pamSessionServiceFactory({diff --git a/frontend/src/hooks/api/pam/types/index.ts b/frontend/src/hooks/api/pam/types/index.tsindex 7425653bbd..8e6f762780 100644--- a/frontend/src/hooks/api/pam/types/index.ts+++ b/frontend/src/hooks/api/pam/types/index.ts@@ -152,7 +152,7 @@ export type TPamFieldDescriptor = {required: boolean;secret: boolean;optional?: boolean;- options?: { label: string; value: string }[];+ options?: { label: string; value: string; docsUrl?: string }[];defaultValue?: string | number | boolean;showWhen?: TPamFieldCondition;forceWhen?: { when: TPamFieldCondition; value: string | number | boolean; reason: string }[];diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsxindex bb54af842c..7d0ff2336c 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamSchemaFields.tsx@@ -7,7 +7,7 @@ import {UseFormSetValue,useWatch} from "react-hook-form";-import { Info } from "lucide-react";+import { ExternalLink, Info } from "lucide-react";import {Field,@@ -195,6 +195,9 @@ export const PamSchemaFields = ({ control, setValue, namePrefix, fields, smartPa{fields.map((descriptor, idx) => {if (!isFieldVisible(descriptor, namePrefix, values)) return null;const forcedRule = forcedRules[idx];+ const selectedDocsUrl = descriptor.options?.find(+ (option) => option.value === values[namePrefix][descriptor.key]+ )?.docsUrl;return (<Controller@@ -235,6 +238,19 @@ export const PamSchemaFields = ({ control, setValue, namePrefix, fields, smartPaisDisabled={Boolean(forcedRule)}smartPaste={smartPaste?.fieldKey === descriptor.key ? smartPaste : undefined}/>+ {selectedDocsUrl && (+ <FieldDescription>+ <a+ href={selectedDocsUrl}+ target="_blank"+ rel="noopener noreferrer"+ className="inline-flex items-center gap-1"+ >+ Documentation+ <ExternalLink className="size-3" />+ </a>+ </FieldDescription>+ )}{forcedRule && <FieldDescription>{forcedRule.reason}</FieldDescription>}<FieldError>{fieldState.error?.message}</FieldError></FieldContent>