Skip to content

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

checkpoint

Daniel Hougaarde7b24637c80f
diff --git a/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts b/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts
index a2db74b031..9b0a2f2516 100644
--- a/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts
+++ b/backend/src/server/routes/v1/app-connection-routers/app-connection-endpoints.ts
@@ -37,6 +37,8 @@ export const registerAppConnectionEndpoints = <T extends TAppConnection, I exten
description?: string | null;
isPlatformManagedCredentials?: boolean;
gatewayId?: string | null;
+ isAutoRotationEnabled?: boolean | null;
+ rotation?: TCreateAppConnectionCredentialRotationSchema | null;
}>;
sanitizedResponseSchema: z.ZodTypeAny;
}) => {
@@ -344,11 +346,28 @@ export const registerAppConnectionEndpoints = <T extends TAppConnection, I exten
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const { name, credentials, description, isPlatformManagedCredentials, gatewayId } = req.body;
+ const {
+ name,
+ credentials,
+ description,
+ isPlatformManagedCredentials,
+ gatewayId,
+ rotation,
+ isAutoRotationEnabled
+ } = req.body;
const { connectionId } = req.params;
const appConnection = (await server.services.appConnection.updateAppConnection(
- { name, credentials, connectionId, description, isPlatformManagedCredentials, gatewayId },
+ {
+ name,
+ credentials,
+ connectionId,
+ description,
+ isPlatformManagedCredentials,
+ gatewayId,
+ isAutoRotationEnabled,
+ rotation
+ },
req.permission
)) as T;
diff --git a/backend/src/services/app-connection/app-connection-schemas.ts b/backend/src/services/app-connection/app-connection-schemas.ts
index b178c108f7..533975d0ee 100644
--- a/backend/src/services/app-connection/app-connection-schemas.ts
+++ b/backend/src/services/app-connection/app-connection-schemas.ts
@@ -8,7 +8,10 @@ import { TAppConnectionBaseConfig } from "@app/services/app-connection/app-conne
import { AppConnection } from "./app-connection-enums";
import { AppConnectionCredentialRotationStatus } from "./credential-rotation/app-connection-credential-rotation-enums";
-import { CreateAppConnectionCredentialRotationSchema } from "./credential-rotation/app-connection-credential-rotation-schemas";
+import {
+ CreateAppConnectionCredentialRotationSchema,
+ UpdateAppConnectionCredentialRotationSchema
+} from "./credential-rotation/app-connection-credential-rotation-schemas";
export const BaseAppConnectionSchema = AppConnectionsSchema.omit({
encryptedCredentials: true,
@@ -100,7 +103,11 @@ export const GenericCreateAppConnectionFieldsSchema = (
export const GenericUpdateAppConnectionFieldsSchema = (
app: AppConnection,
- { supportsPlatformManagedCredentials = false, supportsGateways = false }: TAppConnectionBaseConfig = {}
+ {
+ supportsPlatformManagedCredentials = false,
+ supportsGateways = false,
+ supportsCredentialRotation = false
+ }: TAppConnectionBaseConfig = {}
) =>
z.object({
name: slugSchema({ field: "name" }).describe(AppConnections.UPDATE(app).name).optional(),
@@ -120,6 +127,22 @@ export const GenericUpdateAppConnectionFieldsSchema = (
.describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`),
gatewayId: supportsGateways
? z.string().uuid().nullish().describe("The Gateway ID to use for this connection.")
+ : z
+ .undefined({ message: `Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections` })
+ .or(z.null({ message: `Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections` }))
+ .describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`),
+
+ isAutoRotationEnabled: supportsCredentialRotation
+ ? z.boolean().optional()
+ : z
+ .literal(false, {
+ errorMap: () => ({ message: `Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections` })
+ })
+ .optional()
+ .describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`),
+
+ rotation: supportsCredentialRotation
+ ? UpdateAppConnectionCredentialRotationSchema.omit({ isAutoRotationEnabled: true }).optional()
: z
.undefined({ message: `Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections` })
.or(z.null({ message: `Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections` }))
diff --git a/backend/src/services/app-connection/app-connection-service.ts b/backend/src/services/app-connection/app-connection-service.ts
index 4277f90744..df880430d8 100644
--- a/backend/src/services/app-connection/app-connection-service.ts
+++ b/backend/src/services/app-connection/app-connection-service.ts
@@ -531,7 +531,7 @@ export const appConnectionServiceFactory = ({
};
const updateAppConnection = async (
- { connectionId, credentials, gatewayId, ...params }: TUpdateAppConnectionDTO,
+ { connectionId, credentials, gatewayId, isAutoRotationEnabled, rotation, ...params }: TUpdateAppConnectionDTO,
actor: OrgServiceActor
) => {
const appConnection = await appConnectionDAL.findById(connectionId);
@@ -653,6 +653,17 @@ export const appConnectionServiceFactory = ({
let updatedConnection: TAppConnectionRaw;
+ // Check if the connection has an existing rotation
+ const existingRotation = await appConnectionCredentialRotationService.getRotationByConnectionId(connectionId);
+
+ if (credentials && existingRotation) {
+ // Credential change with active rotation: tear down old rotation first
+ await appConnectionCredentialRotationService.updateRotation({
+ connectionId,
+ isAutoRotationEnabled: false
+ });
+ }
+
if (params.isPlatformManagedCredentials) {
if (!updatedCredentials)
// prevent enabling platform managed credentials without re-confirming credentials
@@ -674,6 +685,57 @@ export const appConnectionServiceFactory = ({
updatedConnection = await updateConnection(updatedCredentials);
}
+ // Handle rotation updates
+ if (isAutoRotationEnabled !== undefined || rotation) {
+ if (isAutoRotationEnabled === false) {
+ // Disabling rotation — tear down if it exists and wasn't already torn down above
+ if (!credentials && existingRotation) {
+ await appConnectionCredentialRotationService.updateRotation({
+ connectionId,
+ isAutoRotationEnabled: false
+ });
+ }
+ } else if (credentials && existingRotation) {
+ // Credentials were changed and rotation was torn down above — re-initialize
+ const existingRotateAtUtc = existingRotation.rotateAtUtc as { hours: number; minutes: number };
+ await appConnectionCredentialRotationService.createRotation({
+ connectionId,
+ rotationInterval: rotation?.rotationInterval ?? existingRotation.rotationInterval,
+ rotateAtUtc: rotation?.rotateAtUtc ?? existingRotateAtUtc
+ });
+ // createRotation doesn't set isAutoRotationEnabled — restore it after re-initialization
+ await appConnectionDAL.updateById(connectionId, { isAutoRotationEnabled: true });
+ } else if (!existingRotation && isAutoRotationEnabled && rotation) {
+ // Enabling rotation on a connection that didn't have it
+ if (!rotation.rotationInterval || !rotation.rotateAtUtc) {
+ throw new BadRequestError({
+ message: "Rotation interval and schedule are required when enabling rotation"
+ });
+ }
+ await appConnectionCredentialRotationService.createRotation({
+ connectionId,
+ rotationInterval: rotation.rotationInterval,
+ rotateAtUtc: rotation.rotateAtUtc
+ });
+ await appConnectionDAL.updateById(connectionId, { isAutoRotationEnabled: true });
+ } else if (existingRotation && rotation) {
+ // Updating schedule/interval on existing rotation
+ await appConnectionCredentialRotationService.updateRotation({
+ connectionId,
+ ...rotation
+ });
+ }
+ } else if (credentials && existingRotation) {
+ // Credentials changed but no rotation fields provided — re-initialize with previous config
+ await appConnectionCredentialRotationService.createRotation({
+ connectionId,
+ rotationInterval: existingRotation.rotationInterval,
+ rotateAtUtc: existingRotation.rotateAtUtc as { hours: number; minutes: number }
+ });
+ // createRotation doesn't set isAutoRotationEnabled — restore it after re-initialization
+ await appConnectionDAL.updateById(connectionId, { isAutoRotationEnabled: true });
+ }
+
return await decryptAppConnection(updatedConnection, kmsService);
} catch (err) {
if (err instanceof DatabaseError && (err.error as { code: string })?.code === DatabaseErrorCode.UniqueViolation) {
diff --git a/backend/src/services/app-connection/app-connection-types.ts b/backend/src/services/app-connection/app-connection-types.ts
index 46bb4b2ee6..c7b9c02dba 100644
--- a/backend/src/services/app-connection/app-connection-types.ts
+++ b/backend/src/services/app-connection/app-connection-types.ts
@@ -428,8 +428,14 @@ export type TCreateAppConnectionDTO = Pick<
| "isAutoRotationEnabled"
>;
-export type TUpdateAppConnectionDTO = Partial<Omit<TCreateAppConnectionDTO, "method" | "app" | "projectId">> & {
+export type TUpdateAppConnectionDTO = Partial<
+ Omit<TCreateAppConnectionDTO, "method" | "app" | "projectId" | "rotation">
+> & {
connectionId: string;
+ rotation?: {
+ rotationInterval?: number;
+ rotateAtUtc?: { hours: number; minutes: number };
+ };
};
export type TGetAppConnectionByNameDTO = {
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.ts
index c7221cad8d..8d6ef9dd0b 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
@@ -88,7 +88,7 @@ export const UpdateAzureKeyVaultConnectionSchema = z
.optional()
.describe(AppConnections.UPDATE(AppConnection.AzureKeyVault).credentials)
})
- .and(GenericUpdateAppConnectionFieldsSchema(AppConnection.AzureKeyVault));
+ .and(GenericUpdateAppConnectionFieldsSchema(AppConnection.AzureKeyVault, { supportsCredentialRotation: true }));
const BaseAzureKeyVaultConnectionSchema = BaseAppConnectionSchema.extend({
app: z.literal(AppConnection.AzureKeyVault)
diff --git a/frontend/src/hooks/api/appConnections/types/index.ts b/frontend/src/hooks/api/appConnections/types/index.ts
index 954df4959f..00c634b0c9 100644
--- a/frontend/src/hooks/api/appConnections/types/index.ts
+++ b/frontend/src/hooks/api/appConnections/types/index.ts
@@ -182,6 +182,11 @@ export type TUpdateAppConnectionDTO = Partial<
> & {
connectionId: string;
app: AppConnection;
+ isAutoRotationEnabled?: boolean;
+ rotation?: {
+ rotationInterval?: number;
+ rotateAtUtc?: { hours: number; minutes: number };
+ };
};
export type TDeleteAppConnectionDTO = {
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
index 8e55e6fd8a..baf3d12c0f 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AppConnectionForm.tsx
@@ -1,4 +1,9 @@
+import { useState } from "react";
+import { faInfoCircle } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+
import { createNotification } from "@app/components/notifications";
+import { Button } from "@app/components/v2";
import { APP_CONNECTION_MAP } from "@app/helpers/appConnections";
import {
TAppConnection,
@@ -60,6 +65,59 @@ import { VercelConnectionForm } from "./VercelConnectionForm";
import { WindmillConnectionForm } from "./WindmillConnectionForm";
import { ZabbixConnectionForm } from "./ZabbixConnectionForm";
+type AppConnectionFormData = DiscriminativePick<
+ TAppConnection,
+ | "method"
+ | "name"
+ | "app"
+ | "credentials"
+ | "isPlatformManagedCredentials"
+ | "isAutoRotationEnabled"
+> & {
+ rotation?: {
+ rotationInterval: number;
+ rotateAtUtc: { hours: number; minutes: number };
+ };
+};
+
+const RotationConfirmation = ({
+ onConfirm,
+ onCancel,
+ isSubmitting
+}: {
+ onConfirm: () => void;
+ onCancel: () => void;
+ isSubmitting: boolean;
+}) => (
+ <div>
+ <div className="flex flex-col rounded-xs border border-l-2 border-mineshaft-600 border-l-primary bg-mineshaft-700/80 px-4 py-3">
+ <div className="mb-1 flex items-center text-sm">
+ <FontAwesomeIcon icon={faInfoCircle} size="sm" className="mr-1.5 text-primary" />
+ Automatic Credential Rotation
+ </div>
+ <p className="bor mt-1 text-sm text-bunker-200">
+ Enabling automatic credential rotation will give Infisical full control over the lifecycle
+ of this credential. Infisical will automatically rotate the credential on the schedule you
+ configured and you will no longer be able to manage it manually. The original credential
+ provided will be revoked and replaced.
+ </p>
+ </div>
+ <div className="mt-4 flex gap-4">
+ <Button
+ onClick={onConfirm}
+ colorSchema="secondary"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ I Understand
+ </Button>
+ <Button variant="plain" onClick={onCancel} colorSchema="secondary" isDisabled={isSubmitting}>
+ Cancel
+ </Button>
+ </div>
+ </div>
+);
+
type FormProps = {
onComplete: (appConnection: TAppConnection) => void;
} & ({ appConnection: TAppConnection } | { app: AppConnection });
@@ -73,21 +131,12 @@ type UpdateFormProps = FormProps & {
};
const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {
+ const [pendingFormData, setPendingFormData] = useState<AppConnectionFormData | null>(null);
+ const [isConfirmSubmitting, setIsConfirmSubmitting] = useState(false);
const createAppConnection = useCreateAppConnection();
const { name: appName } = APP_CONNECTION_MAP[app];
- const onSubmit = async (
- formData: DiscriminativePick<
- TAppConnection,
- | "method"
- | "name"
- | "app"
- | "credentials"
- | "isPlatformManagedCredentials"
- | "isAutoRotationEnabled"
- | "rotation"
- >
- ) => {
+ const submitForm = async (formData: AppConnectionFormData) => {
const connection = await createAppConnection.mutateAsync({
...formData,
projectId
@@ -99,6 +148,33 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {
onComplete(connection);
};
+ const onSubmit = async (formData: AppConnectionFormData) => {
+ if (formData.isAutoRotationEnabled) {
+ setPendingFormData(formData);
+ return;
+ }
+ await submitForm(formData);
+ };
+
+ if (pendingFormData) {
+ return (
+ <RotationConfirmation
+ onConfirm={async () => {
+ setIsConfirmSubmitting(true);
+ try {
+ await submitForm(pendingFormData);
+ } catch {
+ // Error is handled by the mutation's onError handler
+ } finally {
+ setIsConfirmSubmitting(false);
+ }
+ }}
+ onCancel={() => setPendingFormData(null)}
+ isSubmitting={isConfirmSubmitting}
+ />
+ );
+ }
+
switch (app) {
case AppConnection.AWS:
return <AwsConnectionForm onSubmit={onSubmit} />;
@@ -206,15 +282,12 @@ const CreateForm = ({ app, onComplete, projectId }: CreateFormProps) => {
};
const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {
+ const [pendingFormData, setPendingFormData] = useState<AppConnectionFormData | null>(null);
+ const [isConfirmSubmitting, setIsConfirmSubmitting] = useState(false);
const updateAppConnection = useUpdateAppConnection();
const { name: appName } = APP_CONNECTION_MAP[appConnection.app];
- const onSubmit = async (
- formData: DiscriminativePick<
- TAppConnection,
- "method" | "name" | "app" | "credentials" | "isPlatformManagedCredentials"
- >
- ) => {
+ const submitForm = async (formData: AppConnectionFormData) => {
const connection = await updateAppConnection.mutateAsync({
connectionId: appConnection.id,
...formData
@@ -226,6 +299,33 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {
onComplete(connection);
};
+ const onSubmit = async (formData: AppConnectionFormData) => {
+ if (formData.isAutoRotationEnabled && !appConnection.isAutoRotationEnabled) {
+ setPendingFormData(formData);
+ return;
+ }
+ await submitForm(formData);
+ };
+
+ if (pendingFormData) {
+ return (
+ <RotationConfirmation
+ onConfirm={async () => {
+ setIsConfirmSubmitting(true);
+ try {
+ await submitForm(pendingFormData);
+ } catch {
+ // Error is handled by the mutation's onError handler
+ } finally {
+ setIsConfirmSubmitting(false);
+ }
+ }}
+ onCancel={() => setPendingFormData(null)}
+ isSubmitting={isConfirmSubmitting}
+ />
+ );
+ }
+
switch (appConnection.app) {
case AppConnection.AWS:
return <AwsConnectionForm appConnection={appConnection} onSubmit={onSubmit} />;
diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx
index 48e89ad2e6..ef6e204cc9 100644
--- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx
+++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/AzureKeyVaultConnectionForm.tsx
@@ -59,18 +59,20 @@ const formSchema = z.discriminatedUnion("method", [oauthSchema, clientSecretSche
type FormData = z.infer<typeof formSchema>;
const getDefaultValues = (appConnection?: TAzureKeyVaultConnection): Partial<FormData> => {
+ const defaultRotation = {
+ rotationInterval: 30,
+ rotateAtUtc: {
+ hours: 0,
+ minutes: 0
+ }
+ };
+
if (!appConnection) {
return {
app: AppConnection.AzureKeyVault,
method: AzureKeyVaultConnectionMethod.OAuth,
isAutoRotationEnabled: false,
- rotation: {
- rotationInterval: 30,
- rotateAtUtc: {
- hours: 0,
- minutes: 0
- }
- }
+ rotation: defaultRotation
};
}
@@ -80,7 +82,7 @@ const getDefaultValues = (appConnection?: TAzureKeyVaultConnection): Partial<For
app: appConnection.app,
method: appConnection.method,
isAutoRotationEnabled: appConnection.isAutoRotationEnabled,
- rotation: appConnection.rotation
+ rotation: appConnection.rotation ?? defaultRotation
};
const { credentials } = appConnection;
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.tsx
index 7f8fbcf55b..361e8d2c76 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
@@ -60,9 +60,9 @@ export const CredentialRotationForm = ({ renderExtraFields }: Props) => {
<Input
value={value}
type="number"
- onChange={onChange}
+ onChange={(e) => onChange(parseInt(e.target.value, 10))}
min={1}
- placeholder="my-secret-rotation"
+ placeholder="30"
/>
</FormControl>
)}