From f85612d9fd225477c445696f3cd588e5d9f72534 Mon Sep 17 00:00:00 2001 From: x032205 Date: Tue, 16 Sep 2025 00:30:38 -0400 Subject: [PATCH] feat(notifications): access policy bypass notification --- .../access-approval-request-service.ts | 16 +++++++++++++++- .../services/notification/notification-types.ts | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/backend/src/ee/services/access-approval-request/access-approval-request-service.ts b/backend/src/ee/services/access-approval-request/access-approval-request-service.ts index 008b61919..da87978fd 100644 --- a/backend/src/ee/services/access-approval-request/access-approval-request-service.ts +++ b/backend/src/ee/services/access-approval-request/access-approval-request-service.ts @@ -777,6 +777,20 @@ export const accessApprovalRequestServiceFactory = ({ .map((appUser) => appUser.email) .filter((email): email is string => !!email); + const approvalPath = `/projects/secret-management/${project.id}/approval`; + const approvalUrl = `${cfg.SITE_URL}${approvalPath}`; + + await notificationService.createUserNotifications( + approverUsersForEmail.map((approver) => ({ + userId: approver.id, + orgId: actorOrgId, + type: NotificationType.ACCESS_POLICY_BYPASSED, + title: "Secret Access Policy Bypassed", + body: `**${actingUser.firstName} ${actingUser.lastName}** (${actingUser.email}) has accessed a secret in **${policy.secretPath || "/"}** in the **${environment?.name || permissionEnvironment}** environment for project **${project.name}** without obtaining the required approval.`, + link: approvalPath + })) + ); + if (recipientEmails.length > 0) { await smtpService.sendMail({ recipients: recipientEmails, @@ -788,7 +802,7 @@ export const accessApprovalRequestServiceFactory = ({ bypassReason: bypassReason || "No reason provided", secretPath: policy.secretPath || "/", environment: environment?.name || permissionEnvironment, - approvalUrl: `${cfg.SITE_URL}/projects/secret-management/${project.id}/approval`, + approvalUrl, requestType: "access" }, template: SmtpTemplates.AccessSecretRequestBypassed diff --git a/backend/src/services/notification/notification-types.ts b/backend/src/services/notification/notification-types.ts index 30bc87244..76ffc2ea1 100644 --- a/backend/src/services/notification/notification-types.ts +++ b/backend/src/services/notification/notification-types.ts @@ -1,6 +1,7 @@ export enum NotificationType { ACCESS_APPROVAL_REQUEST = "access-approval-request", - ACCESS_APPROVAL_REQUEST_UPDATED = "access-approval-request-updated" + ACCESS_APPROVAL_REQUEST_UPDATED = "access-approval-request-updated", + ACCESS_POLICY_BYPASSED = "access-policy-bypassed" } export interface TCreateUserNotificationDTO {