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
checkpoint
Daniel Hougaard21748557c994
diff --git a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-fns.ts b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-fns.tsindex cd35838004..9227c1a331 100644--- a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-fns.ts+++ b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-fns.ts@@ -223,10 +223,11 @@ export const validateAzureKeyVaultConnectionCredentials = async (config: TAzureK};case AzureKeyVaultConnectionMethod.ClientSecret:- const { tenantId, clientId, clientSecret } = inputCredentials as {+ const { tenantId, clientId, clientSecret, clientSecretKeyId } = inputCredentials as {tenantId: string;clientId: string;clientSecret: string;+ clientSecretKeyId?: string;};try {@@ -245,7 +246,8 @@ export const validateAzureKeyVaultConnectionCredentials = async (config: TAzureKaccessToken: clientData.access_token,expiresAt: Date.now() + clientData.expires_in * 1000,clientId,- clientSecret+ clientSecret,+ clientSecretKeyId};} catch (e: unknown) {if (e instanceof AxiosError) {diff --git a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-schemas.ts b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-schemas.tsindex 53eedff946..c7221cad8d 100644--- a/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-schemas.ts+++ b/backend/src/services/app-connection/azure-key-vault/azure-key-vault-connection-schemas.ts@@ -35,13 +35,22 @@ export const AzureKeyVaultConnectionClientSecretInputCredentialsSchema = z.objec.trim().min(1, "Client Secret required").max(50, "Client Secret must be at most 50 characters long"),- tenantId: z.string().uuid().trim().min(1, "Tenant ID required")+ tenantId: z.string().uuid().trim().min(1, "Tenant ID required"),+ clientSecretKeyId: z+ .string()+ .uuid()+ .trim()+ .optional()+ .describe(+ "The Key ID of the client secret in Azure AD. Required when enabling credential rotation so the original secret can be revoked."+ )});export const AzureKeyVaultConnectionClientSecretOutputCredentialsSchema = z.object({clientId: z.string(),clientSecret: z.string(),tenantId: z.string(),+ clientSecretKeyId: z.string().optional(),accessToken: z.string(),expiresAt: z.number()});diff --git a/backend/src/services/app-connection/credential-rotation/providers/azure-client-secret/azure-client-secret-credential-rotation-fns.ts b/backend/src/services/app-connection/credential-rotation/providers/azure-client-secret/azure-client-secret-credential-rotation-fns.tsindex 34152cefd5..adf3f6a9c5 100644--- a/backend/src/services/app-connection/credential-rotation/providers/azure-client-secret/azure-client-secret-credential-rotation-fns.ts+++ b/backend/src/services/app-connection/credential-rotation/providers/azure-client-secret/azure-client-secret-credential-rotation-fns.ts@@ -354,8 +354,17 @@ export const azureClientSecretRotationProviderFactory: TCredentialRotationProvidclientSecret: string;tenantId: string;applicationObjectId?: string;+ clientSecretKeyId?: string;};+ if (!azureCredentials.clientSecretKeyId) {+ throw new BadRequestError({+ message: "Client Secret Key ID is required when enabling credential rotation."+ });+ }++ const originalKeyId = azureCredentials.clientSecretKeyId;+const accessToken = await getGraphApiToken(azureCredentials);let { applicationObjectId } = azureCredentials;@@ -366,10 +375,6 @@ export const azureClientSecretRotationProviderFactory: TCredentialRotationProvidconst strategyConfig: TAzureClientSecretStrategyConfig = { objectId: applicationObjectId };await validateAzureClientSecretRotationConfig(strategyConfig, azureCredentials, accessToken);- // Create one Infisical-managed credential. The second slot starts empty (null) and will- // be filled on the first rotation cycle. The original user-provided secret becomes unused- // but can't be revoked because Azure doesn't expose which keyId maps to a given secret value.- // It will expire naturally based on its configured expiry in Azure AD.const newCredential = await createAzureClientSecret({accessToken,connectionName: connection.name,@@ -379,12 +384,35 @@ export const azureClientSecretRotationProviderFactory: TCredentialRotationProvidattempt: 0});+ const updatedCredentials = {+ ...azureCredentials,+ clientSecret: newCredential.clientSecret,+ applicationObjectId+ };++ // Verify the new credential works by obtaining a fresh Graph API token with it.+ // getGraphApiToken has built-in retry logic for propagation delays (AADSTS7000215).+ const freshAccessToken = await getGraphApiToken(updatedCredentials);++ // Revoke the original user-provided secret using its Key ID.+ try {+ await revokeAzureClientSecret(originalKeyId, strategyConfig, updatedCredentials, freshAccessToken);+ logger.info(+ `credentialRotation: Revoked original client secret keyId=${originalKeyId} [connection=${connection.name}]`+ );+ } catch (e) {+ logger.warn(+ e,+ `credentialRotation: Failed to revoke original client secret keyId=${originalKeyId} [connection=${connection.name}] — it will need to be removed manually or will expire naturally`+ );+ }+const generatedCredentials: (TAzureClientSecretGeneratedCredential | null)[] = [newCredential, null];return {strategyConfig,generatedCredentials,- updatedCredentials: { ...azureCredentials, clientSecret: newCredential.clientSecret, applicationObjectId }+ updatedCredentials};};diff --git a/frontend/src/hooks/api/appConnections/types/root-connection.ts b/frontend/src/hooks/api/appConnections/types/root-connection.tsindex d186aee216..40e204be51 100644--- a/frontend/src/hooks/api/appConnections/types/root-connection.ts+++ b/frontend/src/hooks/api/appConnections/types/root-connection.ts@@ -1,5 +1,7 @@import { ProjectType } from "@app/hooks/api/projects/types";+import { AppConnectionCredentialRotationStatus } from "./root-connection-enums";+export type TRootAppConnection = {id: string;name: string;@@ -11,7 +13,10 @@ export type TRootAppConnection = {isPlatformManagedCredentials?: boolean;isAutoRotationEnabled?: boolean;rotation?: {+ nextRotationAt: Date;+ lastRotationMessage?: string | null;rotationInterval: number;+ rotationStatus: AppConnectionCredentialRotationStatus;rotateAtUtc: {hours: number;minutes: number;diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsxindex 2b1b520f56..48e89ad2e6 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx@@ -49,7 +49,8 @@ const clientSecretSchema = baseSchema.extend({credentials: z.object({clientSecret: z.string().trim().min(1, "Client Secret is required"),clientId: z.string().trim().min(1, "Client ID is required"),- tenantId: z.string().trim().min(1, "Tenant ID is required")+ tenantId: z.string().trim().min(1, "Tenant ID is required"),+ clientSecretKeyId: z.string().trim().optional()})});@@ -284,7 +285,24 @@ export const AzureKeyVaultConnectionForm = ({ appConnection, onSubmit, projectId)}/>- <CredentialRotationForm />+ <CredentialRotationForm+ renderExtraFields={+ <Controller+ name="credentials.clientSecretKeyId"+ control={control}+ render={({ field, fieldState: { error } }) => (+ <FormControl+ isError={Boolean(error?.message)}+ label="Client Secret Key ID"+ errorText={error?.message}+ tooltipText="The Key ID of the client secret provided above. Found in Azure Portal under App Registrations > Certificates & Secrets. Required so Infisical can revoke the original secret after rotation."+ >+ <Input {...field} placeholder="00000000-0000-0000-0000-000000000000" />+ </FormControl>+ )}+ />+ }+ /></>)}diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/shared/CredentialRotationForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/shared/CredentialRotationForm.tsxindex 19fb80b0df..7f8fbcf55b 100644--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/shared/CredentialRotationForm.tsx+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/shared/CredentialRotationForm.tsx@@ -1,3 +1,4 @@+import { ReactNode } from "react";import { Controller, useFormContext } from "react-hook-form";import { format, setHours, setMinutes } from "date-fns";import { twMerge } from "tailwind-merge";@@ -5,7 +6,11 @@ import { twMerge } from "tailwind-merge";import { FormControl, Input, Switch } from "@app/components/v2";import { getRotateAtLocal } from "@app/helpers/secretRotationsV2";-export const CredentialRotationForm = () => {+type Props = {+ renderExtraFields?: ReactNode;+};++export const CredentialRotationForm = ({ renderExtraFields }: Props) => {const { control, watch } = useFormContext();const isAutoRotationEnabled = watch("isAutoRotationEnabled");@@ -40,61 +45,64 @@ export const CredentialRotationForm = () => {</div>{isAutoRotationEnabled && (- <div className="flex w-full items-center gap-2">- <Controller- render={({ field: { value, onChange }, fieldState: { error } }) => (- <FormControl- className="flex-1"- tooltipText="How often Infisical will rotate the credentials of this connection."- isError={Boolean(error)}- errorText={error?.message}- label="Rotation Interval (In Days)"- >- <Input- value={value}- type="number"- onChange={onChange}- min={1}- placeholder="my-secret-rotation"- />- </FormControl>- )}- control={control}- name="rotation.rotationInterval"- />- <Controller- render={({ field: { value, onChange }, fieldState: { error } }) => {- return (+ <>+ {renderExtraFields}+ <div className="flex w-full items-center gap-2">+ <Controller+ render={({ field: { value, onChange }, fieldState: { error } }) => (<FormControlclassName="flex-1"- tooltipText="The time of day at which Infisical will rotate the credentials of this connection."- label="Rotate At (Local Time)"+ tooltipText="How often Infisical will rotate the credentials of this connection."isError={Boolean(error)}errorText={error?.message}+ label="Rotation Interval (In Days)"><Input- type="time"- value={format(getRotateAtLocal(value), "HH:mm")}- onChange={(e) => {- const time = e.target.value;- if (time) {- const [hours, minutes] = time.split(":").map((str) => parseInt(str, 10));- const newSelectedDate = setHours(setMinutes(new Date(), minutes), hours);- onChange({- hours: newSelectedDate.getUTCHours(),- minutes: newSelectedDate.getUTCMinutes()- });- }- }}- className="bg-mineshaft-700 text-white scheme-dark"+ value={value}+ type="number"+ onChange={onChange}+ min={1}+ placeholder="my-secret-rotation"/></FormControl>- );- }}- control={control}- name="rotation.rotateAtUtc"- />- </div>+ )}+ control={control}+ name="rotation.rotationInterval"+ />+ <Controller+ render={({ field: { value, onChange }, fieldState: { error } }) => {+ return (+ <FormControl+ className="flex-1"+ tooltipText="The time of day at which Infisical will rotate the credentials of this connection."+ label="Rotate At (Local Time)"+ isError={Boolean(error)}+ errorText={error?.message}+ >+ <Input+ type="time"+ value={format(getRotateAtLocal(value), "HH:mm")}+ onChange={(e) => {+ const time = e.target.value;+ if (time) {+ const [hours, minutes] = time.split(":").map((str) => parseInt(str, 10));+ const newSelectedDate = setHours(setMinutes(new Date(), minutes), hours);+ onChange({+ hours: newSelectedDate.getUTCHours(),+ minutes: newSelectedDate.getUTCMinutes()+ });+ }+ }}+ className="bg-mineshaft-700 text-white scheme-dark"+ />+ </FormControl>+ );+ }}+ control={control}+ name="rotation.rotateAtUtc"+ />+ </div>+ </>)}</div>);