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
feat(notifications): secret rotation failed notification
x03220566d2ecf28964
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-queue.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-queue.tsindex 50c81f444e..f653802b68 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-queue.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-queue.ts@@ -17,6 +17,8 @@ import {import { getConfig } from "@app/lib/config/env";import { logger } from "@app/lib/logger";import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";+import { TNotificationServiceFactory } from "@app/services/notification/notification-service";+import { NotificationType } from "@app/services/notification/notification-types";import { TProjectDALFactory } from "@app/services/project/project-dal";import { TProjectMembershipDALFactory } from "@app/services/project-membership/project-membership-dal";import { SmtpTemplates, TSmtpService } from "@app/services/smtp/smtp-service";@@ -28,6 +30,7 @@ type TSecretRotationV2QueueServiceFactoryDep = {smtpService: Pick<TSmtpService, "sendMail">;projectMembershipDAL: Pick<TProjectMembershipDALFactory, "findAllProjectMembers">;projectDAL: Pick<TProjectDALFactory, "findById">;+ notificationService: Pick<TNotificationServiceFactory, "createUserNotifications">;};export const secretRotationV2QueueServiceFactory = async ({@@ -36,7 +39,8 @@ export const secretRotationV2QueueServiceFactory = async ({secretRotationV2Service,projectMembershipDAL,projectDAL,- smtpService+ smtpService,+ notificationService}: TSecretRotationV2QueueServiceFactoryDep) => {const appCfg = getConfig();@@ -152,6 +156,19 @@ export const secretRotationV2QueueServiceFactory = async ({const rotationType = SECRET_ROTATION_NAME_MAP[type as SecretRotation];+ const rotationPath = `/projects/secret-management/${projectId}/secrets/${environment.slug}`;++ await notificationService.createUserNotifications(+ projectAdmins.map((admin) => ({+ userId: admin.userId,+ orgId: project.orgId,+ type: NotificationType.SECRET_ROTATION_FAILED,+ title: "Secret Rotation Failed",+ body: `Your **${rotationType}** rotation **${rotationName}** failed to rotate.`,+ link: rotationPath+ }))+ );+await smtpService.sendMail({recipients: projectAdmins.map((member) => member.user.email!).filter(Boolean),template: SmtpTemplates.SecretRotationFailed,@@ -165,9 +182,7 @@ export const secretRotationV2QueueServiceFactory = async ({secretPath: folder.path,environment: environment.name,projectName: project.name,- rotationUrl: encodeURI(- `${appCfg.SITE_URL}/projects/secret-management/${projectId}/secrets/${environment.slug}`- )+ rotationUrl: encodeURI(`${appCfg.SITE_URL}${rotationPath}`)}});} catch (error) {diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 4de76665a8..11cf65d15f 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -2017,7 +2017,8 @@ export const registerRoutes = async (queueService,projectDAL,projectMembershipDAL,- smtpService+ smtpService,+ notificationService});const secretScanningV2Queue = await secretScanningV2QueueServiceFactory({diff --git a/backend/src/services/notification/notification-types.ts b/backend/src/services/notification/notification-types.tsindex d62fbb07cc..800e412d5d 100644--- a/backend/src/services/notification/notification-types.ts+++ b/backend/src/services/notification/notification-types.ts@@ -3,7 +3,8 @@ export enum NotificationType {ACCESS_APPROVAL_REQUEST_UPDATED = "access-approval-request-updated",ACCESS_POLICY_BYPASSED = "access-policy-bypassed",SECRET_CHANGE_REQUEST = "secret-change-request",- SECRET_CHANGE_POLICY_BYPASSED = "secret-change-policy-bypassed"+ SECRET_CHANGE_POLICY_BYPASSED = "secret-change-policy-bypassed",+ SECRET_ROTATION_FAILED = "secret-rotation-failed"}export interface TCreateUserNotificationDTO {