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(pam): move to alerting module
Andreye84e371c9330
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.mdindex 558029097a..42413170c0 100644--- a/backend/CLAUDE.md+++ b/backend/CLAUDE.md@@ -809,6 +809,9 @@ provider's. A`resourceType` that doesn't declare the `eventType` fails the row terminally with both named, so a bademit site shows up in the logs on its first event.+Approval lifecycle events reach the outbox through `TApprovalResource.buildEvent`, which the approval+service emits inside each transition's transaction (PAM folder alerts use it).+**The event contract belongs to the domain that emits it, not to a consumer.** The identity auth methodevent (key, resource type, change enum, payload schema, and the `emitIdentityAuthMethodChanged` helper)lives in `src/services/identity/identity-auth-method-events.ts`. The 13 auth method services import thediff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.tsindex ae920bc957..1461ef6cf0 100644--- a/backend/src/ee/services/audit-log/audit-log-types.ts+++ b/backend/src/ee/services/audit-log/audit-log-types.ts@@ -774,6 +774,10 @@ export enum EventType {PAM_ACCESS_REQUEST_REVIEW = "pam-access-request-review",PAM_ACCESS_GRANT_REVOKE = "pam-access-grant-revoke",PAM_APPROVAL_CONFIG_UPDATE = "pam-approval-config-update",+ PAM_FOLDER_ALERT_CREATE = "pam-folder-alert-create",+ PAM_FOLDER_ALERT_UPDATE = "pam-folder-alert-update",+ PAM_FOLDER_ALERT_DELETE = "pam-folder-alert-delete",+ PAM_FOLDER_ALERT_CHANNEL_TEST = "pam-folder-alert-channel-test",AGENT_VAULT_ACCESS_BUNDLE_CREATE = "agent-vault-access-bundle-create",AGENT_VAULT_ACCESS_BUNDLE_UPDATE = "agent-vault-access-bundle-update",AGENT_VAULT_ACCESS_BUNDLE_DELETE = "agent-vault-access-bundle-delete",@@ -6741,6 +6745,36 @@ interface PamApprovalConfigUpdateEvent {};}+type TPamFolderAlertEventMetadata = { folderId?: string; alertId: string; name: string; eventType: string };++interface PamFolderAlertCreateEvent {+ type: EventType.PAM_FOLDER_ALERT_CREATE;+ metadata: TPamFolderAlertEventMetadata;+}++interface PamFolderAlertUpdateEvent {+ type: EventType.PAM_FOLDER_ALERT_UPDATE;+ metadata: TPamFolderAlertEventMetadata;+}++interface PamFolderAlertDeleteEvent {+ type: EventType.PAM_FOLDER_ALERT_DELETE;+ metadata: TPamFolderAlertEventMetadata;+}++interface PamFolderAlertChannelTestEvent {+ type: EventType.PAM_FOLDER_ALERT_CHANNEL_TEST;+ metadata: {+ folderId?: string;+ alertId?: string;+ channelId?: string;+ channelType: string;+ success: boolean;+ deliveredTo?: number;+ error?: string;+ };+}+interface UpdateCertificateRenewalConfigEvent {type: EventType.UPDATE_CERTIFICATE_RENEWAL_CONFIG;metadata: {@@ -8519,6 +8553,10 @@ export type Event =| PamAccessRequestReviewEvent| PamAccessGrantRevokeEvent| PamApprovalConfigUpdateEvent+ | PamFolderAlertCreateEvent+ | PamFolderAlertUpdateEvent+ | PamFolderAlertDeleteEvent+ | PamFolderAlertChannelTestEvent| UpdateCertificateRenewalConfigEvent| UpdateCertificateMetadataEvent| DisableCertificateRenewalConfigEventdiff --git a/backend/src/ee/services/license/__mocks__/license-fns.ts b/backend/src/ee/services/license/__mocks__/license-fns.tsindex 3bf41b977c..294aae2e34 100644--- a/backend/src/ee/services/license/__mocks__/license-fns.ts+++ b/backend/src/ee/services/license/__mocks__/license-fns.ts@@ -48,7 +48,7 @@ export const getDefaultOnPremFeatures = () => {kmip: false,gateway: false,gatewayPool: false,- pamSlackNotifications: false,+ pamEnterpriseAlerting: false,secretScanning: false,enterpriseSecretSyncs: false,enterpriseAppConnections: true,diff --git a/backend/src/ee/services/license/license-fns.ts b/backend/src/ee/services/license/license-fns.tsindex ae1f3624f0..cb4084aa87 100644--- a/backend/src/ee/services/license/license-fns.ts+++ b/backend/src/ee/services/license/license-fns.ts@@ -99,7 +99,7 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({kmip: false,gateway: false,gatewayPool: false,- pamSlackNotifications: false,+ pamEnterpriseAlerting: false,secretScanning: false,enterpriseSecretSyncs: false,enterpriseAppConnections: false,diff --git a/backend/src/ee/services/license/license-types.ts b/backend/src/ee/services/license/license-types.tsindex 2889f5d4a1..38086767d3 100644--- a/backend/src/ee/services/license/license-types.ts+++ b/backend/src/ee/services/license/license-types.ts@@ -93,7 +93,7 @@ export type TFeatureSet = {kmip: false;gateway: false;gatewayPool: false;- pamSlackNotifications: boolean;+ pamEnterpriseAlerting: boolean;secretScanning: false;enterpriseSecretSyncs: false;enterpriseAppConnections: false;diff --git a/backend/src/ee/services/pam-access-request/pam-access-approval-resource.ts b/backend/src/ee/services/pam-access-request/pam-access-approval-resource.tsindex a5595dac15..b4af3b434b 100644--- a/backend/src/ee/services/pam-access-request/pam-access-approval-resource.ts+++ b/backend/src/ee/services/pam-access-request/pam-access-approval-resource.ts@@ -4,7 +4,6 @@ import { RESOURCE_SCOPE, ResourceType, TApprovalRequestGrants } from "@app/db/scimport { EventType } from "@app/ee/services/audit-log/audit-log-types";import { TGatewayV2ServiceFactory } from "@app/ee/services/gateway-v2/gateway-v2-service";import { TUserGroupMembershipDALFactory } from "@app/ee/services/group/user-group-membership-dal";-import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";import {ResourcePermissionApprovalPolicyActions,@@ -75,6 +74,7 @@ import { TPamAccountTemplateDALFactory } from "../pam-account-template/pam-accouimport { TPamFolderDALFactory } from "../pam-folder/pam-folder-dal";import { TPamSessionDALFactory } from "../pam-session/pam-session-dal";import { terminatePamSessions } from "../pam-session/pam-session-fns";+import { buildPamAccessRequestEvent } from "./pam-access-request-events";import { escapeMarkdown, getSlackSendTargets } from "./pam-access-request-fns";import { TPamAccessRequestData } from "./pam-access-request-types";import { TPamFolderNotificationConfigDALFactory } from "./pam-folder-notification-config-dal";@@ -97,7 +97,6 @@ type TPamAccessApprovalResourceDep = {userDAL: Pick<TUserDALFactory, "findById">;gatewayV2Service: Pick<TGatewayV2ServiceFactory, "getPAMConnectionDetails">;kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;- licenseService: Pick<TLicenseServiceFactory, "getPlan">;pamFolderNotificationConfigDAL: Pick<TPamFolderNotificationConfigDALFactory, "findByFolderIdWithIntegration">;};@@ -161,7 +160,6 @@ export const pamAccessApprovalResourceFactory = ({userDAL,gatewayV2Service,kmsService,- licenseService,pamFolderNotificationConfigDAL}: TPamAccessApprovalResourceDep): TPamAccessApprovalResource => {const $assertFolderInProject = async (folderId: string, projectId: string) => {@@ -705,10 +703,7 @@ export const pamAccessApprovalResourceFactory = ({});};- const $chatDeliveries = async (event: PamNotificationEvent, orgId: string, folderId: string) => {- const plan = await licenseService.getPlan(orgId);- if (!plan.pamSlackNotifications) return [];-+ const $chatDeliveries = async (event: PamNotificationEvent, folderId: string) => {const configs = await pamFolderNotificationConfigDAL.findByFolderIdWithIntegration(folderId);return getSlackSendTargets(configs, event);};@@ -761,7 +756,7 @@ export const pamAccessApprovalResourceFactory = ({approvalUrl}},- chat: (await $chatDeliveries(PamNotificationEvent.AccessRequested, orgId, inputs.folderId)).map((target) => ({+ chat: (await $chatDeliveries(PamNotificationEvent.AccessRequested, inputs.folderId)).map((target) => ({...target,notification: {type: TriggerFeature.PAM_ACCESS_REQUESTED,@@ -800,22 +795,20 @@ export const pamAccessApprovalResourceFactory = ({bypassReason}},- chat: (await $chatDeliveries(PamNotificationEvent.AccessRequestBypassed, orgId, inputs.folderId)).map(- (target) => ({- ...target,- notification: {- type: TriggerFeature.PAM_ACCESS_REQUEST_BYPASSED,- payload: {- requesterFullName: requesterName,- requesterEmail: request.requesterEmail ?? "",- accountName,- folderName,- accessDuration: formatDuration(inputs.duration),- bypassReason: bypassReason ?? ""- }+ chat: (await $chatDeliveries(PamNotificationEvent.AccessRequestBypassed, inputs.folderId)).map((target) => ({+ ...target,+ notification: {+ type: TriggerFeature.PAM_ACCESS_REQUEST_BYPASSED,+ payload: {+ requesterFullName: requesterName,+ requesterEmail: request.requesterEmail ?? "",+ accountName,+ folderName,+ accessDuration: formatDuration(inputs.duration),+ bypassReason: bypassReason ?? ""}- })- )+ }+ }))};}@@ -833,7 +826,6 @@ export const pamAccessApprovalResourceFactory = ({chat: (await $chatDeliveries(approved ? PamNotificationEvent.AccessRequestApproved : PamNotificationEvent.AccessRequestDenied,- orgId,inputs.folderId)).map((target) => ({@@ -853,6 +845,19 @@ export const pamAccessApprovalResourceFactory = ({};};+ const buildEvent: NonNullable<TPamAccessApprovalResource["buildEvent"]> = ({ event, request }) => {+ const folderId = requestDataOf(request)?.folderId;+ return folderId+ ? buildPamAccessRequestEvent({+ event,+ requestId: request.id,+ orgId: request.organizationId,+ projectId: request.projectId,+ folderId+ })+ : null;+ };+const isLiveApprover: NonNullable<TPamAccessApprovalResource["isLiveApprover"]> = async ({projectId,scopeId,@@ -1051,6 +1056,7 @@ export const pamAccessApprovalResourceFactory = ({canAccess,matchesInputs,buildNotification,+ buildEvent,buildAuditEvent,buildTelemetryEvent,decorateRequests,diff --git a/backend/src/ee/services/pam-access-request/pam-access-request-events.ts b/backend/src/ee/services/pam-access-request/pam-access-request-events.tsnew file mode 100644index 0000000000..4908f3ee48--- /dev/null+++ b/backend/src/ee/services/pam-access-request/pam-access-request-events.ts@@ -0,0 +1,41 @@+import { ApprovalNotificationEvent } from "@app/services/approval-policy/approval-policy-enums";+import { TEventInput } from "@app/services/event-outbox/event-outbox-types";++export const PAM_FOLDER_RESOURCE_TYPE = "pam.folder";++export enum PamAccessRequestEvent {+ Requested = "pam.folder.access-requested",+ Approved = "pam.folder.access-request-approved",+ Denied = "pam.folder.access-request-denied",+ Bypassed = "pam.folder.access-request-bypassed"+}++const EVENT_BY_APPROVAL_EVENT: Record<ApprovalNotificationEvent, PamAccessRequestEvent> = {+ [ApprovalNotificationEvent.Requested]: PamAccessRequestEvent.Requested,+ [ApprovalNotificationEvent.Approved]: PamAccessRequestEvent.Approved,+ [ApprovalNotificationEvent.Rejected]: PamAccessRequestEvent.Denied,+ [ApprovalNotificationEvent.Bypassed]: PamAccessRequestEvent.Bypassed+};++export const buildPamAccessRequestEvent = ({+ event,+ requestId,+ orgId,+ projectId,+ folderId+}: {+ event: ApprovalNotificationEvent;+ requestId: string;+ orgId: string;+ projectId: string;+ folderId: string;+}): TEventInput => ({+ eventType: EVENT_BY_APPROVAL_EVENT[event],+ payload: {+ orgId,+ projectId,+ resourceType: PAM_FOLDER_RESOURCE_TYPE,+ resourceId: folderId,+ targetIds: [requestId]+ }+});diff --git a/backend/src/ee/services/pam-access-request/pam-access-request-service.ts b/backend/src/ee/services/pam-access-request/pam-access-request-service.tsindex 982aedd894..b8f24e39e1 100644--- a/backend/src/ee/services/pam-access-request/pam-access-request-service.ts+++ b/backend/src/ee/services/pam-access-request/pam-access-request-service.ts@@ -1,7 +1,6 @@import { Knex } from "knex";import { TApprovalRequestGrants } from "@app/db/schemas";-import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";import {ResourcePermissionApprovalPolicyActions,@@ -67,7 +66,6 @@ type TPamAccessRequestServiceFactoryDep = {"findByFolderIdWithIntegration" | "delete" | "insertMany" | "transaction">;workflowIntegrationDAL: Pick<TWorkflowIntegrationDALFactory, "find">;- licenseService: Pick<TLicenseServiceFactory, "getPlan">;approvalPolicyService: Pick<TApprovalPolicyServiceFactory,| "create"@@ -96,6 +94,17 @@ type TPamAccessRequestServiceFactoryDep = {export type TPamAccessRequestServiceFactory = ReturnType<typeof pamAccessRequestServiceFactory>;+const toNotificationConfigKey = (config: {+ workflowIntegrationId: string;+ channels: { id: string }[];+ events: string[];+}) =>+ JSON.stringify([+ config.workflowIntegrationId,+ config.channels.map((channel) => channel.id).sort(),+ [...config.events].sort()+ ]);+export const pamAccessRequestServiceFactory = ({approvalPolicyDAL,approvalRequestDAL,@@ -106,7 +115,6 @@ export const pamAccessRequestServiceFactory = ({identityDAL,pamFolderNotificationConfigDAL,workflowIntegrationDAL,- licenseService,approvalPolicyService,pamAccessApprovalResource}: TPamAccessRequestServiceFactoryDep) => {@@ -221,14 +229,6 @@ export const pamAccessRequestServiceFactory = ({if (notificationConfigs !== undefined) {if (notificationConfigs.length > 0) {- const plan = await licenseService.getPlan(ctx.actorOrgId);- if (!plan.pamSlackNotifications) {- throw new BadRequestError({- message:- "Failed to save notification configuration due to plan restriction. Upgrade plan to configure Slack notifications for PAM approvals."- });- }-const integrationIds = [...new Set(notificationConfigs.map((c) => c.workflowIntegrationId))];const integrations = await workflowIntegrationDAL.find({ $in: { id: integrationIds } });const integrationById = new Map(integrations.map((i) => [i.id, i]));@@ -244,6 +244,19 @@ export const pamAccessRequestServiceFactory = ({});}}++ // Legacy Slack configs can only be removed, so every config sent back must match a stored one.+ const storedKeys = (await getNotificationConfigs(folderId)).map(toNotificationConfigKey);+ for (const config of notificationConfigs) {+ const index = storedKeys.indexOf(toNotificationConfigKey(config));+ if (index === -1) {+ throw new BadRequestError({+ message:+ "Slack notifications on PAM folders can no longer be added or edited, only removed. Create an alert on the folder instead."+ });+ }+ storedKeys.splice(index, 1);+ }}await pamFolderNotificationConfigDAL.transaction(async (tx) => {diff --git a/backend/src/ee/services/pam-folder/pam-folder-service.ts b/backend/src/ee/services/pam-folder/pam-folder-service.tsindex 06c4f78f99..3c486007b9 100644--- a/backend/src/ee/services/pam-folder/pam-folder-service.ts+++ b/backend/src/ee/services/pam-folder/pam-folder-service.ts@@ -9,12 +9,14 @@ import {} from "@app/ee/services/permission/resource-permission";import { DatabaseErrorCode } from "@app/lib/error-codes";import { BadRequestError, DatabaseError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";+import { TAlertServiceFactory } from "@app/services/alert/alert-service";import { ActorType } from "@app/services/auth/auth-type";import { TMembershipDALFactory } from "@app/services/membership/membership-dal";import { TMembershipRoleDALFactory } from "@app/services/membership/membership-role-dal";import { PamProductRole, PamResourceRole } from "../pam/pam-enums";import { getResourceIdsWithActions, TActorContext, verifyProductMembership } from "../pam/pam-permission";+import { PAM_FOLDER_RESOURCE_TYPE } from "../pam-access-request/pam-access-request-events";import { TPamAccessRequestServiceFactory } from "../pam-access-request/pam-access-request-service";import { TPamFolderDALFactory } from "./pam-folder-dal";import {@@ -34,6 +36,7 @@ type TPamFolderServiceFactoryDep = {membershipRoleDAL: Pick<TMembershipRoleDALFactory, "create" | "delete" | "find">;permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission">;pamAccessRequestService: Pick<TPamAccessRequestServiceFactory, "cleanupFolderResources">;+ alertService: Pick<TAlertServiceFactory, "deleteAlertsForDeletedResource">;};export type TPamFolderServiceFactory = ReturnType<typeof pamFolderServiceFactory>;@@ -43,7 +46,8 @@ export const pamFolderServiceFactory = ({membershipDAL,membershipRoleDAL,permissionService,- pamAccessRequestService+ pamAccessRequestService,+ alertService}: TPamFolderServiceFactoryDep) => {const verifyMembership = (projectId: string, ctx: TActorContext) =>verifyProductMembership(permissionService, projectId, ctx);@@ -210,6 +214,10 @@ export const pamFolderServiceFactory = ({}await pamAccessRequestService.cleanupFolderResources(folderId, tx);+ await alertService.deleteAlertsForDeletedResource(+ { resourceType: PAM_FOLDER_RESOURCE_TYPE, resourceId: folderId },+ tx+ );return pamFolderDAL.deleteById(folderId, tx);});diff --git a/backend/src/ee/services/pam/CLAUDE.md b/backend/src/ee/services/pam/CLAUDE.mdindex c78323537d..fc0cde8101 100644--- a/backend/src/ee/services/pam/CLAUDE.md+++ b/backend/src/ee/services/pam/CLAUDE.md@@ -168,6 +168,10 @@ routes emitting PAM's own audit events, so folder and account auditors still seekeeps only what the generic API cannot express: the CLI's `folderName/accountName` create, the paginatedfolder list, the approver queue and count, the approver roster, and the folder notification configs.+**Folder alerts are the `pam.folder` provider on the shared alert module**, fed by the resource's `buildEvent`.+The older per-folder Slack configs (`pam_folder_notification_configs`) are legacy: they still post and can be+removed, never added or edited.+## Policies & Settings**Policies** are governance controls on a template (MFA, reason, session duration, command-blocking),diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 68f4912b4a..056f85d55e 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -253,6 +253,8 @@ import { certManagerApplicationAlertDALFactory } from "@app/services/alert/proviimport { certManagerApplicationAlertProviderFactory } from "@app/services/alert/providers/cert-manager-application-alert-provider";import { identityCredentialAlertDALFactory } from "@app/services/alert/providers/identity-credential-alert-dal";import { identityCredentialAlertProviderFactory } from "@app/services/alert/providers/identity-credential-alert-provider";+import { pamFolderAlertDALFactory } from "@app/services/alert/providers/pam-folder-alert-dal";+import { pamFolderAlertProviderFactory } from "@app/services/alert/providers/pam-folder-alert-provider";import { announcementServiceFactory } from "@app/services/announcement/announcement-service";import { appConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";import { appConnectionServiceFactory } from "@app/services/app-connection/app-connection-service";@@ -1100,6 +1102,13 @@ export const registerRoutes = async (licenseService}));+ alertProviderRegistry.register(+ pamFolderAlertProviderFactory({+ pamFolderAlertDAL: pamFolderAlertDALFactory(db),+ permissionService,+ licenseService+ })+ );const alertRecipientResolver = alertRecipientResolverFactory({userDAL,userGroupMembershipDAL,@@ -3678,7 +3687,6 @@ export const registerRoutes = async (});const pamAccessApprovalResource = pamAccessApprovalResourceFactory({- licenseService,pamFolderNotificationConfigDAL,approvalPolicyDAL,userGroupMembershipDAL,@@ -3731,6 +3739,7 @@ export const registerRoutes = async (groupDAL,slackIntegrationDAL,kmsService,+ eventEmitter: eventOutboxService,resources: approvalResources});@@ -3764,7 +3773,6 @@ export const registerRoutes = async (identityDAL,pamFolderNotificationConfigDAL,workflowIntegrationDAL,- licenseService,approvalPolicyService,pamAccessApprovalResource});@@ -3774,7 +3782,8 @@ export const registerRoutes = async (membershipDAL,membershipRoleDAL,permissionService,- pamAccessRequestService+ pamAccessRequestService,+ alertService});const pamDiscoverySourceDAL = pamDiscoverySourceDALFactory(db);diff --git a/backend/src/services/alert/providers/pam-folder-alert-dal.ts b/backend/src/services/alert/providers/pam-folder-alert-dal.tsnew file mode 100644index 0000000000..63782c0cc2--- /dev/null+++ b/backend/src/services/alert/providers/pam-folder-alert-dal.ts@@ -0,0 +1,119 @@+import { Knex } from "knex";++import { TDbClient } from "@app/db";+import { ProjectType, TableName } from "@app/db/schemas";+import { DatabaseError } from "@app/lib/errors";+import {+ ApprovalPolicyType,+ ApprovalRequestApprovalDecision+} from "@app/services/approval-policy/approval-policy-enums";++export type TPamFolderAlertDALFactory = ReturnType<typeof pamFolderAlertDALFactory>;++// Event-path reads go to the primary: the request commits with the event, and an empty read is terminal.+export const pamFolderAlertDALFactory = (db: TDbClient) => {+ const findFolderById = async (+ folderId: string,+ { readFromPrimary = false }: { readFromPrimary?: boolean } = {},+ tx?: Knex+ ) => {+ try {+ const folder = (await (tx || (readFromPrimary ? db : db.replicaNode()))(TableName.PamFolder)+ .join(TableName.Project, `${TableName.PamFolder}.projectId`, `${TableName.Project}.id`)+ .where(`${TableName.PamFolder}.id`, folderId)+ .where(`${TableName.Project}.type`, ProjectType.PAM)+ .whereNull(`${TableName.Project}.deleteAfter`)+ .select(`${TableName.PamFolder}.name`, `${TableName.PamFolder}.projectId`, `${TableName.Project}.orgId`)+ .first()) as { name: string; projectId: string; orgId: string } | undefined;++ return folder;+ } catch (error) {+ throw new DatabaseError({ error, name: "FindPamAlertFolderById" });+ }+ };++ const findAccessRequestsByIds = async (+ { orgId, projectId, requestIds }: { orgId: string; projectId: string; requestIds: string[] },+ tx?: Knex+ ) => {+ try {+ const requests = (await (tx || db)(TableName.ApprovalRequests)+ .whereIn("id", requestIds)+ .where({ organizationId: orgId, projectId, type: ApprovalPolicyType.PamAccess })+ .select("id", "requesterName", "requesterEmail", "machineIdentityId", "requestData")+ .orderBy("createdAt", "asc")) as {+ id: string;+ requesterName: string;+ requesterEmail: string;+ machineIdentityId: string | null;+ requestData: unknown;+ }[];++ return requests;+ } catch (error) {+ throw new DatabaseError({ error, name: "FindPamAlertAccessRequestsByIds" });+ }+ };++ const findAccountNamesByIds = async (+ { projectId, accountIds }: { projectId: string; accountIds: string[] },+ tx?: Knex+ ) => {+ if (accountIds.length === 0) return [];+ try {+ const accounts = (await (tx || db)(TableName.PamAccount)+ .whereIn("id", accountIds)+ .where({ projectId })+ .select("id", "name")) as { id: string; name: string }[];++ return accounts;+ } catch (error) {+ throw new DatabaseError({ error, name: "FindPamAlertAccountNamesByIds" });+ }+ };++ const findDecisionCommentsByRequestIds = async (+ { requestIds, decision }: { requestIds: string[]; decision: ApprovalRequestApprovalDecision },+ tx?: Knex+ ) => {+ try {+ const decisions = (await (tx || db)(TableName.ApprovalRequestApprovals)+ .join(+ TableName.ApprovalRequestSteps,+ `${TableName.ApprovalRequestApprovals}.stepId`,+ `${TableName.ApprovalRequestSteps}.id`+ )+ .whereIn(`${TableName.ApprovalRequestSteps}.requestId`, requestIds)+ .where(`${TableName.ApprovalRequestApprovals}.decision`, decision)+ .select(`${TableName.ApprovalRequestSteps}.requestId`, `${TableName.ApprovalRequestApprovals}.comment`)+ .orderBy(`${TableName.ApprovalRequestApprovals}.createdAt`, "asc")) as {+ requestId: string;+ comment: string | null;+ }[];++ return decisions;+ } catch (error) {+ throw new DatabaseError({ error, name: "FindPamAlertDecisionCommentsByRequestIds" });+ }+ };++ const findBypassReasonsByRequestIds = async (requestIds: string[], tx?: Knex) => {+ try {+ const grants = (await (tx || db)(TableName.ApprovalRequestGrants)+ .whereIn("requestId", requestIds)+ .select("requestId", "bypassReason")) as { requestId: string; bypassReason: string | null }[];++ return grants;+ } catch (error) {+ throw new DatabaseError({ error, name: "FindPamAlertBypassReasonsByRequestIds" });+ }+ };++ return {+ findFolderById,+ findAccessRequestsByIds,+ findAccountNamesByIds,+ findDecisionCommentsByRequestIds,+ findBypassReasonsByRequestIds+ };+};diff --git a/backend/src/services/alert/providers/pam-folder-alert-provider.ts b/backend/src/services/alert/providers/pam-folder-alert-provider.tsnew file mode 100644index 0000000000..d6c0d3b500--- /dev/null+++ b/backend/src/services/alert/providers/pam-folder-alert-provider.ts@@ -0,0 +1,321 @@+import { z } from "zod";++import { Event as TAuditEvent, EventType } from "@app/ee/services/audit-log/audit-log-types";+import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";+import { PamAccessType } from "@app/ee/services/pam/pam-enums";+import { checkFolderPermission, verifyProductMembership } from "@app/ee/services/pam/pam-permission";+import {+ PAM_FOLDER_RESOURCE_TYPE,+ PamAccessRequestEvent+} from "@app/ee/services/pam-access-request/pam-access-request-events";+import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";+import {+ ResourcePermissionPamResourceActions,+ ResourcePermissionSub+} from "@app/ee/services/permission/resource-permission";+import { getConfig } from "@app/lib/config/env";+import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";+import { formatDuration } from "@app/lib/ms";+import { ApprovalRequestApprovalDecision } from "@app/services/approval-policy/approval-policy-enums";++import { AlertChannelType, TAlertPayload, TAlertSeverity } from "../alert-channel-types";+import {+ AlertAuditAction,+ AlertPermissionAction,+ AlertTriggerType,+ IEventAlertProvider,+ TAlertAuditInput,+ TAlertContext,+ TAlertPermissionInput,+ TFindEventTargetsInput+} from "../alert-types";+import { TPamFolderAlertDALFactory } from "./pam-folder-alert-dal";++const EventConditionSchema = z.object({}).strict().nullish();++const RequestDataSchema = z.object({+ requestData: z.object({+ accountId: z.string().optional(),+ folderId: z.string(),+ reason: z.string().optional(),+ duration: z.string().optional(),+ accessType: z.nativeEnum(PamAccessType).optional()+ })+});++const EVENT_LABELS: Record<PamAccessRequestEvent, string> = {+ [PamAccessRequestEvent.Requested]: "Request",+ [PamAccessRequestEvent.Approved]: "Approval",+ [PamAccessRequestEvent.Denied]: "Denial",+ [PamAccessRequestEvent.Bypassed]: "Break-Glass"+};++const EVENT_SEVERITY: Record<PamAccessRequestEvent, TAlertSeverity> = {+ [PamAccessRequestEvent.Requested]: "info",+ [PamAccessRequestEvent.Approved]: "info",+ [PamAccessRequestEvent.Denied]: "warning",+ [PamAccessRequestEvent.Bypassed]: "critical"+};++const DECISION_BY_EVENT: Partial<Record<PamAccessRequestEvent, ApprovalRequestApprovalDecision>> = {+ [PamAccessRequestEvent.Approved]: ApprovalRequestApprovalDecision.Approved,+ [PamAccessRequestEvent.Denied]: ApprovalRequestApprovalDecision.Rejected+};++type TPamAccessRequestTarget = {+ requestId: string;+ folderName: string;+ accountName: string | null;+ requesterName: string;+ requesterLabel: string;+ accessType: PamAccessType;+ duration?: string;+ reason?: string;+ comment: string | null;+ bypassReason: string | null;+};++const assertValidFolderId = (folderId: string) => {+ if (!z.string().uuid().safeParse(folderId).success) {+ throw new BadRequestError({ message: `Invalid folder ID '${folderId}': must be a UUID` });+ }+};++const toRequesterLabel = ({+ requesterName,+ requesterEmail,+ machineIdentityId+}: {+ requesterName: string;+ requesterEmail: string;+ machineIdentityId: string | null;+}) => {+ if (machineIdentityId) return `${requesterName} (machine identity)`;+ return requesterEmail ? `${requesterName} (${requesterEmail})` : requesterName;+};++const describeTarget = (eventType: PamAccessRequestEvent, target: TPamAccessRequestTarget) => {+ const account = target.accountName ? `account '${target.accountName}'` : "a deleted account";+ const access = `${target.accessType === PamAccessType.Credential ? "credential access" : "access"} to ${account} in folder '${target.folderName}'`;+ if (eventType === PamAccessRequestEvent.Requested) return `${target.requesterName} requested ${access}`;+ if (eventType === PamAccessRequestEvent.Bypassed) {+ return `${target.requesterName} used break-glass to get ${access} without approval`;+ }+ const decision = eventType === PamAccessRequestEvent.Approved ? "approved" : "denied";+ return `${target.requesterName}'s request for ${access} was ${decision}`;+};++export type TPamFolderAlertProviderDep = {+ pamFolderAlertDAL: TPamFolderAlertDALFactory;+ permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission">;+ licenseService: Pick<TLicenseServiceFactory, "getPlan">;+};++export const pamFolderAlertProviderFactory = ({+ pamFolderAlertDAL,+ permissionService,+ licenseService+}: TPamFolderAlertProviderDep): IEventAlertProvider<TPamAccessRequestTarget> => {+ const buildViewUrl = async (alert: TAlertContext): Promise<string> => {+ const base = `${getConfig().SITE_URL}/organizations/${alert.orgId}/pam`;+ if (alert.eventType === PamAccessRequestEvent.Requested) return `${base}/approval-requests`;+ return `${base}/accounts/${alert.resourceId}`;+ };++ const findEventTargets = async (input: TFindEventTargetsInput): Promise<TPamAccessRequestTarget[]> => {+ if (!input.projectId || !input.resourceId) return [];+ EventConditionSchema.parse(input.condition);++ const eventType = input.eventType as PamAccessRequestEvent;+ const folderId = input.resourceId;+ const requests = (+ await pamFolderAlertDAL.findAccessRequestsByIds({+ orgId: input.orgId,+ projectId: input.projectId,+ requestIds: input.targetIds+ })+ ).flatMap((request) => {+ const parsed = RequestDataSchema.safeParse(request.requestData);+ return parsed.success && parsed.data.requestData.folderId === folderId+ ? [{ ...request, inputs: parsed.data.requestData }]+ : [];+ });+ if (requests.length === 0) return [];++ const requestIds = requests.map((request) => request.id);+ const decision = DECISION_BY_EVENT[eventType];+ const [folder, accounts, decisions, grants] = await Promise.all([+ pamFolderAlertDAL.findFolderById(folderId, { readFromPrimary: true }),+ pamFolderAlertDAL.findAccountNamesByIds({+ projectId: input.projectId,+ accountIds: requests.flatMap((request) => (request.inputs.accountId ? [request.inputs.accountId] : []))+ }),+ decision ? pamFolderAlertDAL.findDecisionCommentsByRequestIds({ requestIds, decision }) : [],+ eventType === PamAccessRequestEvent.Bypassed ? pamFolderAlertDAL.findBypassReasonsByRequestIds(requestIds) : []+ ]);+ if (!folder) return [];++ const accountNameById = new Map(accounts.map((account) => [account.id, account.name]));+ // Rows come back oldest first, so the last decision per request wins.+ const commentByRequestId = new Map(decisions.map((row) => [row.requestId, row.comment]));+ const bypassReasonByRequestId = new Map(grants.map((row) => [row.requestId, row.bypassReason]));++ return requests.map((request) => ({+ requestId: request.id,+ folderName: folder.name,+ accountName: accountNameById.get(request.inputs.accountId ?? "") ?? null,+ requesterName: request.requesterName,+ requesterLabel: toRequesterLabel(request),+ accessType: request.inputs.accessType ?? PamAccessType.Session,+ duration: request.inputs.duration,+ reason: request.inputs.reason,+ comment: commentByRequestId.get(request.id) || null,+ bypassReason: bypassReasonByRequestId.get(request.id) || null+ }));+ };++ const buildPayload = (alert: TAlertContext, targets: TPamAccessRequestTarget[], viewUrl: string): TAlertPayload => {+ const eventType = alert.eventType as PamAccessRequestEvent;+ const isSingleRequest = eventType === PamAccessRequestEvent.Requested && targets.length === 1;++ return {+ alert: {+ id: alert.id,+ name: alert.name,+ orgId: alert.orgId,+ ...(alert.projectId ? { projectId: alert.projectId } : {}),+ resourceType: alert.resourceType,+ ...(alert.resourceId ? { resourceId: alert.resourceId } : {}),+ viewUrl: isSingleRequest ? `${viewUrl}?requestId=${targets[0].requestId}` : viewUrl+ },+ eventKey: eventType,+ eventLabel: EVENT_LABELS[eventType],+ webhookType: `com.infisical.${eventType}`,+ resourceKind: "PAM Access",+ resourceOwnerKind: "Folder",+ severity: EVENT_SEVERITY[eventType],+ summary: describeTarget(eventType, targets[0]),+ items: targets.map((target) => ({+ id: target.requestId,+ title: target.accountName ?? "Deleted account",+ summary: describeTarget(eventType, target),+ fields: [+ { label: "Requester", value: target.requesterLabel },+ { label: "Folder", value: target.folderName },+ { label: "Access Type", value: target.accessType === PamAccessType.Credential ? "Credentials" : "Session" },+ ...(target.duration ? [{ label: "Duration", value: formatDuration(target.duration) }] : []),+ ...(target.reason ? [{ label: "Reason", value: target.reason }] : []),+ ...(target.comment ? [{ label: "Reviewer Comment", value: target.comment }] : []),+ ...(target.bypassReason && target.bypassReason !== target.reason+ ? [{ label: "Break-Glass Reason", value: target.bypassReason }]+ : [])+ ]+ }))+ };+ };++ const assertResourceInScope = async ({+ orgId,+ projectId,+ resourceId+ }: {+ orgId: string;+ projectId?: string | null;+ resourceId?: string | null;+ }): Promise<void> => {+ if (!resourceId) return;+ assertValidFolderId(resourceId);++ const folder = await pamFolderAlertDAL.findFolderById(resourceId);+ if (!folder || folder.orgId !== orgId || folder.projectId !== projectId) {+ throw new NotFoundError({ message: `PAM folder with ID '${resourceId}' not found` });+ }+ };++ const assertPermission = async ({+ action,+ orgId,+ projectId,+ resourceId,+ actor+ }: TAlertPermissionInput): Promise<void> => {+ if (!projectId || !resourceId) {+ throw new BadRequestError({ message: "PAM folder alerts require the PAM project ID and a folder ID" });+ }++ await verifyProductMembership(permissionService, projectId, actor);+ await assertResourceInScope({ orgId, projectId, resourceId });++ const { permission } = await checkFolderPermission(permissionService, resourceId, projectId, actor);+ const isRead = action === AlertPermissionAction.Read;+ if (+ permission.can(ResourcePermissionPamResourceActions.ManagePolicies, ResourcePermissionSub.PamResource) ||+ (isRead && permission.can(ResourcePermissionPamResourceActions.ViewAuditLogs, ResourcePermissionSub.PamResource))+ ) {+ return;+ }++ throw new ForbiddenRequestError({+ message: isRead+ ? "You need permission to manage approvals or view audit logs on this folder to see its alerts"+ : "You need permission to manage approvals on this folder to change its alerts"+ });+ };++ const assertChannelTypesAllowed = async ({ orgId, channelTypes }: { orgId: string; channelTypes: string[] }) => {+ const gatedType = channelTypes.find((channelType) => channelType !== AlertChannelType.EMAIL);+ if (!gatedType) return;++ const plan = await licenseService.getPlan(orgId);+ if (!plan.pamEnterpriseAlerting) {+ throw new BadRequestError({+ message: `Failed to add a ${gatedType} channel due to plan restriction. Upgrade plan to send PAM alerts to channels other than email.`+ });+ }+ };++ const getAuditEvent = (input: TAlertAuditInput): TAuditEvent => {+ if (input.action === AlertAuditAction.TestChannel) {+ const { test } = input;+ return {+ type: EventType.PAM_FOLDER_ALERT_CHANNEL_TEST,+ metadata: {+ ...(test.resourceId ? { folderId: test.resourceId } : {}),+ alertId: test.alertId,+ channelId: test.channelId,+ channelType: test.channelType,+ success: test.success,+ deliveredTo: test.deliveredTo,+ error: test.error+ }+ };+ }++ const metadata = {+ ...(input.alert.resourceId ? { folderId: input.alert.resourceId } : {}),+ alertId: input.alert.id,+ name: input.alert.name,+ eventType: input.alert.eventType+ };+ if (input.action === AlertAuditAction.Create) return { type: EventType.PAM_FOLDER_ALERT_CREATE, metadata };+ if (input.action === AlertAuditAction.Update) return { type: EventType.PAM_FOLDER_ALERT_UPDATE, metadata };+ return { type: EventType.PAM_FOLDER_ALERT_DELETE, metadata };+ };++ return {+ resourceType: PAM_FOLDER_RESOURCE_TYPE,+ events: Object.values(PamAccessRequestEvent).map((key) => ({+ key,+ triggerType: AlertTriggerType.Event,+ conditionSchema: EventConditionSchema+ })),+ findEventTargets,+ buildViewUrl,+ buildPayload,+ targetId: (target) => target.requestId,+ assertPermission,+ assertResourceInScope,+ assertChannelTypesAllowed,+ getAuditEvent+ };+};diff --git a/backend/src/services/approval-policy/approval-policy-service.ts b/backend/src/services/approval-policy/approval-policy-service.tsindex ec8f9f00e9..df9e7a24f3 100644--- a/backend/src/services/approval-policy/approval-policy-service.ts+++ b/backend/src/services/approval-policy/approval-policy-service.ts@@ -27,6 +27,7 @@ import {import { BadRequestError, DatabaseError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";import { ms } from "@app/lib/ms";import { ActorType } from "@app/services/auth/auth-type";+import { TEventEmitter } from "@app/services/event-outbox/event-outbox-types";import { TKmsServiceFactory } from "@app/services/kms/kms-service";import { TNotificationServiceFactory } from "@app/services/notification/notification-service";import { TPkiApplicationDALFactory } from "@app/services/pki-application/pki-application-dal";@@ -109,6 +110,7 @@ type TApprovalPolicyServiceFactoryDep = {smtpService: Pick<TSmtpService, "sendMail">;userDAL: Pick<TUserDALFactory, "findById" | "find">;groupDAL: Pick<TGroupDALFactory, "find">;+ eventEmitter: TEventEmitter;resources: TApprovalResourceRegistry;};@@ -136,6 +138,7 @@ export const approvalPolicyServiceFactory = ({smtpService,userDAL,groupDAL,+ eventEmitter,resources}: TApprovalPolicyServiceFactoryDep) => {const $resource = (policyType: ApprovalPolicyType) => {@@ -168,6 +171,11 @@ export const approvalPolicyServiceFactory = ({$notificationDeps);+ const $emitEvent = async (args: { event: ApprovalNotificationEvent; request: TApprovalRequests }, tx: Knex) => {+ const event = resources[args.request.type as ApprovalPolicyType]?.buildEvent?.(args);+ if (event) await eventEmitter.emit(event, tx);+ };+const $buildDecorationContext = (actor: TApprovalActor): TDecorationContext => {let cached: Promise<Set<string>> | null = null;return {@@ -476,6 +484,7 @@ export const approvalPolicyServiceFactory = ({throw new BadRequestError({ message: `Bypassing approval is not supported for ${policyType} requests` });}+ await $emitEvent({ event: ApprovalNotificationEvent.Bypassed, request: approvedRequest }, tx);return result;});@@ -1002,7 +1011,10 @@ export const approvalPolicyServiceFactory = ({approvalRequestStepsDAL,approvalRequestStepEligibleApproversDAL},- tx+ tx,+ skipApproverNotification+ ? undefined+ : (request, trx) => $emitEvent({ event: ApprovalNotificationEvent.Requested, request }, trx));if (!skipApproverNotification) {@@ -1407,6 +1419,7 @@ export const approvalPolicyServiceFactory = ({);nextStepToNotifyInner = nextStep;+ await $emitEvent({ event: ApprovalNotificationEvent.Requested, request: locked }, tx);} else {const completedReq = await approvalRequestDAL.updateById(requestId,@@ -1417,6 +1430,7 @@ export const approvalPolicyServiceFactory = ({);await resource.postApprovalTxRoutine?.(completedReq as TApprovalRequest, tx);+ await $emitEvent({ event: ApprovalNotificationEvent.Approved, request: completedReq }, tx);return { updatedRequest: completedReq, nextStepToNotify: null };}@@ -1539,13 +1553,14 @@ export const approvalPolicyServiceFactory = ({tx);- await approvalRequestDAL.updateById(+ const rejected = await approvalRequestDAL.updateById(requestId,{status: ApprovalRequestStatus.Rejected},tx);+ await $emitEvent({ event: ApprovalNotificationEvent.Rejected, request: rejected }, tx);});const finalSteps = await approvalRequestDAL.findStepsByRequestId(requestId);diff --git a/backend/src/services/approval-policy/approval-policy-types.ts b/backend/src/services/approval-policy/approval-policy-types.tsindex 61b0ba933e..5bf0d24fe4 100644--- a/backend/src/services/approval-policy/approval-policy-types.ts+++ b/backend/src/services/approval-policy/approval-policy-types.ts@@ -5,6 +5,7 @@ import { Event } from "@app/ee/services/audit-log/audit-log-types";import { ResourcePermissionApprovalPolicyActions } from "@app/ee/services/permission/resource-permission";import { OrgServiceActor } from "@app/lib/types";import { TNotification } from "@app/lib/workflow-integrations/types";+import { TEventInput } from "@app/services/event-outbox/event-outbox-types";import { NotificationType } from "@app/services/notification/notification-types";import { SmtpTemplates } from "@app/services/smtp/smtp-service";import { TPostHogEvent } from "@app/services/telemetry/telemetry-types";@@ -215,6 +216,8 @@ export type TApprovalResource<comment?: string;bypassReason?: string;}) => Promise<TApprovalNotification | null>;+ // The domain event a lifecycle event owes; called inside the transaction, so it must not touch the database.+ buildEvent?: (args: { event: ApprovalNotificationEvent; request: TApprovalRequests }) => TEventInput | null;// Narrows the notified approvers to those still eligible, for a type where an approver row can// outlive the membership behind it.filterActiveApprovers?: (diff --git a/backend/src/services/approval-policy/approval-request-fns.ts b/backend/src/services/approval-policy/approval-request-fns.tsindex ec67f81721..e125bc3eb2 100644--- a/backend/src/services/approval-policy/approval-request-fns.ts+++ b/backend/src/services/approval-policy/approval-request-fns.ts@@ -75,7 +75,8 @@ export const createApprovalRequestWithSteps = async (approvalRequestStepsDAL: Pick<TApprovalRequestStepsDALFactory, "create">;approvalRequestStepEligibleApproversDAL: Pick<TApprovalRequestStepEligibleApproversDALFactory, "create">;},- externalTx?: Knex+ externalTx?: Knex,+ onCreated?: (request: TApprovalRequests, tx: Knex) => Promise<void>): Promise<TApprovalRequestWithSteps> => {const { approvalRequestDAL, approvalRequestStepsDAL, approvalRequestStepEligibleApproversDAL } = dependencies;@@ -138,6 +139,7 @@ export const createApprovalRequestWithSteps = async (}));+ await onCreated?.(newRequest, tx);return { request: newRequest, steps: newSteps };};diff --git a/backend/src/services/license-client/feature-mapping.ts b/backend/src/services/license-client/feature-mapping.tsindex 5a7ec25d36..66b6b63335 100644--- a/backend/src/services/license-client/feature-mapping.ts+++ b/backend/src/services/license-client/feature-mapping.ts@@ -353,8 +353,8 @@ const pamMappings: TFeatureMapping[] = [v1Field: "enterprisePamAccount"},{- v2Key: "pam_slack_notifications",- v1Field: "pamSlackNotifications"+ v2Key: "pam_enterprise_alerting",+ v1Field: "pamEnterpriseAlerting"},{// Max PAM accounts allowed. null (v1 default) means uncapped.diff --git a/docs/documentation/platform/pam/access-requests/overview.mdx b/docs/documentation/platform/pam/access-requests/overview.mdxindex c5bcbf0da5..c975f1030e 100644--- a/docs/documentation/platform/pam/access-requests/overview.mdx+++ b/docs/documentation/platform/pam/access-requests/overview.mdx@@ -162,12 +162,29 @@ Every use of break-glass:- Emails every approver who was skipped, with the reason given- Notifies them in the app-- Posts to the folder's Slack channels, if you've configured notifications on the folder+- Notifies the channels on the folder's **Break-Glass Used** [alert](#alerts), if the folder has one- Writes a **PAM Access Policy Bypassed** entry to the [audit log](/documentation/platform/pam/auditing) with the reason, the account, the folder, and how many approvers were skipped- Marks the request with a **Break-glass** badge in the folder's request historyThe badge and the audit entry are permanent.+## Alerts++An alert notifies your team about access requests in a folder through email, Slack, a webhook, or PagerDuty. Each alert watches one event:++| Event | When it fires |+|-------|---------------|+| **Access Requested** | Someone requests access to an account in the folder |+| **Request Approved** | An approver approves a request |+| **Request Denied** | An approver rejects a request |+| **Break-Glass Used** | Someone uses [break-glass](#break-glass-access) to get access without an approver |++A Folder Admin adds and manages alerts by selecting **Alerts** on the folder's **Approvals** tab. A folder can have one alert per event, and Slack, webhook, and PagerDuty channels need an Enterprise plan.++<Note>+ Slack notifications set up on a folder before alerts were available keep posting. You can remove them on the **Approvals** tab, but you can't add or edit them.+</Note>+## Requests from AI agentsAn agent requests access on the same terms as a person, but from the [CLI](/cli/reference#pam-agentic-access) instead of the dashboard. A request from an agent running as a machine identity shows the identity's name in place of a requester's email; one from an agent you started yourself is filed under your own name.diff --git a/frontend/src/hooks/api/alerts/types.ts b/frontend/src/hooks/api/alerts/types.tsindex 779c289a47..d56ff5d2c6 100644--- a/frontend/src/hooks/api/alerts/types.ts+++ b/frontend/src/hooks/api/alerts/types.ts@@ -1,14 +1,32 @@import { z } from "zod";export enum AlertResourceType {- IdentityAuthentication = "identity.authentication"+ IdentityAuthentication = "identity.authentication",+ PamFolder = "pam.folder"}export enum AlertEventType {IdentityAuthenticationExpiry = "identity.authentication.expiry",- IdentityAuthMethodChanged = "identity.authentication.auth-method-changed"+ IdentityAuthMethodChanged = "identity.authentication.auth-method-changed",+ PamAccessRequested = "pam.folder.access-requested",+ PamAccessRequestApproved = "pam.folder.access-request-approved",+ PamAccessRequestDenied = "pam.folder.access-request-denied",+ PamAccessRequestBypassed = "pam.folder.access-request-bypassed"}+export const ALERT_RESOURCE_EVENT_TYPES: Record<AlertResourceType, AlertEventType[]> = {+ [AlertResourceType.IdentityAuthentication]: [+ AlertEventType.IdentityAuthenticationExpiry,+ AlertEventType.IdentityAuthMethodChanged+ ],+ [AlertResourceType.PamFolder]: [+ AlertEventType.PamAccessRequested,+ AlertEventType.PamAccessRequestApproved,+ AlertEventType.PamAccessRequestDenied,+ AlertEventType.PamAccessRequestBypassed+ ]+};+export enum AlertChannelType {Email = "email",Slack = "slack",@@ -44,19 +62,39 @@ export const MAX_ALERT_BEFORE_DAYS = 90;export const MAX_CERTIFICATE_ALERT_BEFORE_DAYS = 365;export const ALERT_RESOURCE_TYPE_LABELS: Record<AlertResourceType, string> = {- [AlertResourceType.IdentityAuthentication]: "Machine Identity Authentication"+ [AlertResourceType.IdentityAuthentication]: "Machine Identity Authentication",+ [AlertResourceType.PamFolder]: "PAM Folder"};export const ALERT_EVENT_TYPE_LABELS: Record<AlertEventType, string> = {[AlertEventType.IdentityAuthenticationExpiry]: "Credential Expiration",- [AlertEventType.IdentityAuthMethodChanged]: "Auth Method Change"+ [AlertEventType.IdentityAuthMethodChanged]: "Auth Method Change",+ [AlertEventType.PamAccessRequested]: "Access Requested",+ [AlertEventType.PamAccessRequestApproved]: "Request Approved",+ [AlertEventType.PamAccessRequestDenied]: "Request Denied",+ [AlertEventType.PamAccessRequestBypassed]: "Break-Glass Used"};export const ALERT_EVENT_TYPE_DESCRIPTIONS: Record<AlertEventType, string> = {[AlertEventType.IdentityAuthenticationExpiry]:"Notify a set number of days before a Universal Auth client secret or Token Auth access token expires.",[AlertEventType.IdentityAuthMethodChanged]:- "Notify whenever an auth method is added, updated, or removed, or one of its credentials is created, updated, or revoked."+ "Notify whenever an auth method is added, updated, or removed, or one of its credentials is created, updated, or revoked.",+ [AlertEventType.PamAccessRequested]:+ "Notify when someone requests access to an account in this folder.",+ [AlertEventType.PamAccessRequestApproved]:+ "Notify when an access request in this folder is approved.",+ [AlertEventType.PamAccessRequestDenied]:+ "Notify when an access request in this folder is denied.",+ [AlertEventType.PamAccessRequestBypassed]:+ "Notify when someone uses break-glass to access an account in this folder without approval."+};++// Channel types a plan doesn't include, and the paywall shown when one is picked.+export type TAlertChannelPaywall = {+ lockedChannelTypes: AlertChannelType[];+ paywallKey: string;+ text: string;};export const ALERT_CHANNEL_TYPE_LABELS: Record<AlertChannelType, string> = {diff --git a/frontend/src/hooks/api/auditLogs/constants.tsx b/frontend/src/hooks/api/auditLogs/constants.tsxindex b8bdef0b94..1170a1da2d 100644--- a/frontend/src/hooks/api/auditLogs/constants.tsx+++ b/frontend/src/hooks/api/auditLogs/constants.tsx@@ -380,6 +380,10 @@ export const eventToNameMap: { [K in EventType]: string } = {[EventType.PAM_ACCOUNT_SSH_CA_CREATE]: "Create PAM Account SSH CA",[EventType.PAM_ACCOUNT_CREDENTIALS_VIEW]: "View PAM Account Credentials",[EventType.PAM_APPROVAL_CONFIG_UPDATE]: "Update PAM Approval Configuration",+ [EventType.PAM_FOLDER_ALERT_CREATE]: "Create PAM Folder Alert",+ [EventType.PAM_FOLDER_ALERT_UPDATE]: "Update PAM Folder Alert",+ [EventType.PAM_FOLDER_ALERT_DELETE]: "Delete PAM Folder Alert",+ [EventType.PAM_FOLDER_ALERT_CHANNEL_TEST]: "Test PAM Folder Alert Channel",[EventType.PAM_DISCOVERY_SOURCE_CREATE]: "Create PAM Discovery Source",[EventType.PAM_DISCOVERY_SOURCE_UPDATE]: "Update PAM Discovery Source",[EventType.PAM_DISCOVERY_SOURCE_DELETE]: "Delete PAM Discovery Source",@@ -545,6 +549,10 @@ export const projectToEventsMap: Partial<Record<ProjectType, EventType[]>> = {EventType.PAM_ACCOUNT_SSH_CA_CREATE,EventType.PAM_ACCOUNT_CREDENTIALS_VIEW,EventType.PAM_APPROVAL_CONFIG_UPDATE,+ EventType.PAM_FOLDER_ALERT_CREATE,+ EventType.PAM_FOLDER_ALERT_UPDATE,+ EventType.PAM_FOLDER_ALERT_DELETE,+ EventType.PAM_FOLDER_ALERT_CHANNEL_TEST,EventType.PAM_DISCOVERY_SOURCE_CREATE,EventType.PAM_DISCOVERY_SOURCE_UPDATE,EventType.PAM_DISCOVERY_SOURCE_DELETE,diff --git a/frontend/src/hooks/api/auditLogs/enums.tsx b/frontend/src/hooks/api/auditLogs/enums.tsxindex a282f93cd9..6bc00d6047 100644--- a/frontend/src/hooks/api/auditLogs/enums.tsx+++ b/frontend/src/hooks/api/auditLogs/enums.tsx@@ -369,6 +369,10 @@ export enum EventType {PAM_ACCOUNT_SSH_CA_CREATE = "pam-account-ssh-ca-create",PAM_ACCOUNT_CREDENTIALS_VIEW = "pam-account-credentials-view",PAM_APPROVAL_CONFIG_UPDATE = "pam-approval-config-update",+ PAM_FOLDER_ALERT_CREATE = "pam-folder-alert-create",+ PAM_FOLDER_ALERT_UPDATE = "pam-folder-alert-update",+ PAM_FOLDER_ALERT_DELETE = "pam-folder-alert-delete",+ PAM_FOLDER_ALERT_CHANNEL_TEST = "pam-folder-alert-channel-test",PAM_DISCOVERY_SOURCE_CREATE = "pam-discovery-source-create",PAM_DISCOVERY_SOURCE_UPDATE = "pam-discovery-source-update",PAM_DISCOVERY_SOURCE_DELETE = "pam-discovery-source-delete",diff --git a/frontend/src/hooks/api/subscriptions/types.ts b/frontend/src/hooks/api/subscriptions/types.tsindex 63f3b8621a..fd9877a9a8 100644--- a/frontend/src/hooks/api/subscriptions/types.ts+++ b/frontend/src/hooks/api/subscriptions/types.ts@@ -64,7 +64,7 @@ export type SubscriptionPlan = {instanceUserManagement: boolean;gateway: boolean;gatewayPool: boolean;- pamSlackNotifications: boolean;+ pamEnterpriseAlerting: boolean;externalKms: boolean;// PKI / Cert Manager. The /plan route returns z.any(), so nothing enforces that this mirrors// the backend's TFeatureSet.diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertAction.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertAction.tsxindex 660cffc634..b0aa30110d 100644--- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertAction.tsx+++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAlertAction.tsx@@ -8,7 +8,7 @@ type Props = {export const IdentityAlertAction = ({ identityId }: Props) => (<AlertAction- identityId={identityId}+ resourceId={identityId}renderPermissionGate={(render) => (<OrgPermissionCan I={OrgPermissionIdentityActions.Edit} a={OrgPermissionSubjects.Identity}>{render}diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsxindex 3d78ba4fa0..a90db85587 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx@@ -40,12 +40,13 @@ import {TooltipTrigger} from "@app/components/v3";import { Skeleton } from "@app/components/v3/generic/Skeleton";-import { useOrganization, useSubscription } from "@app/context";+import { useOrganization, useProject, useSubscription } from "@app/context";import {getUserTablePreference,PreferenceKey,setUserTablePreference} from "@app/helpers/userTablePreferences";+import { AlertChannelType, AlertResourceType } from "@app/hooks/api/alerts";import { useGetOrganizationGroups } from "@app/hooks/api/organization/queries";import {PamAccessRequestStatus,@@ -61,6 +62,7 @@ import {} from "@app/hooks/api/pam";import { TPamAccessRequest, TPamNotificationConfig } from "@app/hooks/api/pam/types";import { useGetOrgUsers } from "@app/hooks/api/users/queries";+import { AlertAction } from "@app/views/Alerts";import { AccessTypeBadge } from "../../components/AccessTypeBadge";import { AccountPlatformIcon } from "../../components/AccountPlatformIcon";@@ -106,8 +108,8 @@ type Props = {export const FolderApprovalsTab = ({ folderId, onDirtyChange }: Props) => {const { currentOrg } = useOrganization();+ const { currentProject } = useProject();const { subscription } = useSubscription();- const isPamSlackEnabled = Boolean(subscription?.pamSlackNotifications);const { data: config, isLoading } = useGetPamApprovalConfig(folderId);const { data: orgUsers } = useGetOrgUsers(currentOrg.id);const { data: orgGroups } = useGetOrganizationGroups(currentOrg.id);@@ -313,19 +315,6 @@ export const FolderApprovalsTab = ({ folderId, onDirtyChange }: Props) => {};const handleSave = () => {- const hasIncompleteConfig =- isPamSlackEnabled &&- notificationConfigs.some(- (c) => !c.workflowIntegrationId || c.channels.length === 0 || c.events.length === 0- );- if (hasIncompleteConfig) {- createNotification({- type: "error",- text: "Each notification needs a Slack workspace, at least one channel, and at least one event"- });- return;- }-if (breakGlassUsers.length > 0 && approvers.length === 0) {createNotification({type: "error",@@ -339,8 +328,8 @@ export const FolderApprovalsTab = ({ folderId, onDirtyChange }: Props) => {folderId,steps: [{ approvers }],breakGlassUsers,- // undefined leaves server-side configs untouched when the plan doesn't include the feature- notificationConfigs: isPamSlackEnabled ? notificationConfigs : undefined+ // Legacy Slack configs can only be removed, so they're sent only when one was.+ notificationConfigs: isNotifDirty ? notificationConfigs : undefined},{onSuccess: () => {@@ -546,7 +535,38 @@ export const FolderApprovalsTab = ({ folderId, onDirtyChange }: Props) => {</CardContent></Card>- {isPamSlackEnabled && (+ <Card>+ <CardHeader>+ <CardTitle className="text-base">Alerts</CardTitle>+ <CardDescription>+ Notify email, Slack, webhook, or PagerDuty channels about access request activity for+ accounts in this folder.+ </CardDescription>+ <CardAction>+ <AlertAction+ resourceType={AlertResourceType.PamFolder}+ resourceId={folderId}+ projectId={currentProject.id}+ renderPermissionGate={(render) => render(true)}+ channelPaywall={+ subscription?.pamEnterpriseAlerting+ ? undefined+ : {+ lockedChannelTypes: [+ AlertChannelType.Slack,+ AlertChannelType.Webhook,+ AlertChannelType.PagerDuty+ ],+ paywallKey: "pam.folder-alert-channels",+ text: "Slack, webhook, and PagerDuty alert channels for PAM are available on the Enterprise plan."+ }+ }+ />+ </CardAction>+ </CardHeader>+ </Card>++ {savedNotificationConfigs.length > 0 && (<FolderNotificationsSectionconfigs={notificationConfigs}integrationSlugById={integrationSlugById}diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderNotificationsSection.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderNotificationsSection.tsxindex 1e885a64ff..2fc55aa030 100644--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderNotificationsSection.tsx+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderNotificationsSection.tsx@@ -5,21 +5,15 @@ import {OptionProps,SingleValueProps} from "react-select";-import { Bell, ChevronDown, Plus, Slack, Trash2 } from "lucide-react";+import { Bell, Trash2 } from "lucide-react";import {Badge,- Button,Card,- CardAction,CardContent,CardDescription,CardHeader,CardTitle,- DropdownMenu,- DropdownMenuContent,- DropdownMenuItem,- DropdownMenuTrigger,FilterableSelect,IconButton,Tooltip,@@ -154,6 +148,7 @@ const NotificationConfigCard = ({<div className="flex items-start gap-2"><div className="flex-1"><FilterableSelect+ isDisabledvalue={selectedIntegration}options={workspaceOptions}onChange={(opt) => {@@ -189,6 +184,7 @@ const NotificationConfigCard = ({<span className="text-sm font-medium">Slack channels</span><FilterableSelectisMulti+ isDisabledvalue={config.channels}options={channelOptions}onChange={(selected) => {@@ -215,6 +211,7 @@ const NotificationConfigCard = ({<span className="text-sm font-medium">Notify on</span><FilterableSelectisMulti+ isDisabledvalue={EVENT_OPTIONS.filter((opt) => config.events.includes(opt.value))}options={EVENT_OPTIONS}onChange={(selected) => {@@ -254,43 +251,23 @@ export const FolderNotificationsSection = ({ configs, integrationSlugById, onCha[workflowIntegrations]);- const addConfig = () => {- onChange([...configs, { workflowIntegrationId: "", channels: [], events: [] }]);- };-return (<Card><CardHeader className="border-b"><CardTitle className="text-base">Notifications+ <Badge variant="neutral">Legacy</Badge><Badge variant="pam">{configs.length}</Badge></CardTitle><CardDescription>- Notify external channels about access request activity for accounts in this folder.+ These Slack notifications keep posting, but they can no longer be added or edited. Add an+ alert instead to notify Slack, email, webhook, or PagerDuty channels.</CardDescription>- <CardAction>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button variant="outline" size="sm">- <Plus className="size-4" />- Add- <ChevronDown className="size-4 text-muted" />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end" sideOffset={2}>- <DropdownMenuItem onSelect={addConfig}>- <Slack className="size-4" />- Slack- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>- </CardAction></CardHeader><CardContent className="flex flex-col gap-4">{configs.length === 0 ? (<div className="rounded-md border border-border p-8 text-center text-sm text-muted">- No chat notifications yet. Add Slack to post this folder's approval activity to a- channel.+ All Slack notifications removed. Save changes to apply.</div>) : (configs.map((config, idx) => (diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertAction.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertAction.tsxindex 99414e8de7..d46fd21d55 100644--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertAction.tsx+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAlertAction.tsx@@ -12,7 +12,7 @@ type Props = {export const ProjectIdentityAlertAction = ({ identityId, projectId, readOnly = false }: Props) => (<AlertAction- identityId={identityId}+ resourceId={identityId}projectId={projectId}readOnly={readOnly}renderPermissionGate={(render) => (diff --git a/frontend/src/views/Alerts/AddAlertModal.tsx b/frontend/src/views/Alerts/AddAlertModal.tsxindex 52ccfa829c..d99e596169 100644--- a/frontend/src/views/Alerts/AddAlertModal.tsx+++ b/frontend/src/views/Alerts/AddAlertModal.tsx@@ -1,5 +1,10 @@import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@app/components/v3";-import { AlertEventType, TAlert } from "@app/hooks/api/alerts";+import {+ AlertEventType,+ AlertResourceType,+ TAlert,+ TAlertChannelPaywall+} from "@app/hooks/api/alerts";import { AlertForm } from "./AlertForm";@@ -7,7 +12,9 @@ type Props = {isOpen: boolean;onOpenChange: (isOpen: boolean) => void;projectId?: string;+ resourceType?: AlertResourceType;resourceId?: string;+ channelPaywall?: TAlertChannelPaywall;alert?: TAlert;unavailableEventTypes?: AlertEventType[];};@@ -16,7 +23,9 @@ export const AddAlertModal = ({isOpen,onOpenChange,projectId,+ resourceType,resourceId,+ channelPaywall,alert,unavailableEventTypes}: Props) => {@@ -35,7 +44,9 @@ export const AddAlertModal = ({<AlertFormkey={alert?.id ?? "new"}projectId={projectId}+ resourceType={resourceType}resourceId={resourceId}+ channelPaywall={channelPaywall}alert={alert}unavailableEventTypes={unavailableEventTypes}onComplete={() => onOpenChange(false)}diff --git a/frontend/src/views/Alerts/AlertAction.tsx b/frontend/src/views/Alerts/AlertAction.tsxindex 6da605aebb..9f324954b1 100644--- a/frontend/src/views/Alerts/AlertAction.tsx+++ b/frontend/src/views/Alerts/AlertAction.tsx@@ -31,10 +31,12 @@ import { usePopUp, useScopeVariant } from "@app/hooks";import {ALERT_CHANNEL_TYPE_LABELS,ALERT_EVENT_TYPE_LABELS,+ ALERT_RESOURCE_EVENT_TYPES,AlertChannelType,AlertEventType,AlertResourceType,TAlert,+ TAlertChannelPaywall,useDeleteAlert,useListAlerts,useUpdateAlert@@ -44,7 +46,9 @@ import { AddAlertModal } from "./AddAlertModal";import { getChannelIcon } from "./channelIcons";type Props = {- identityId: string;+ resourceType?: AlertResourceType;+ resourceId: string;+ channelPaywall?: TAlertChannelPaywall;// Org-scoped when omitted.projectId?: string;// Renders the alerts without any way to create, edit or remove them.@@ -60,14 +64,16 @@ const getEnabledChannelTypes = (alert: TAlert): AlertChannelType[] =>);export const AlertAction = ({- identityId,+ resourceType = AlertResourceType.IdentityAuthentication,+ resourceId,+ channelPaywall,projectId,readOnly = false,renderPermissionGate}: Props) => {const { data: alerts = [] } = useListAlerts({- resourceType: AlertResourceType.IdentityAuthentication,- resourceId: identityId,+ resourceType,+ resourceId,...(projectId ? { projectId } : {})});@@ -81,7 +87,7 @@ export const AlertAction = ({const enabledCount = alerts.filter((alert) => alert.enabled).length;const usedEventTypes = alerts.map((alert) => alert.eventType as AlertEventType);- const canAddAlert = Object.values(AlertEventType).some(+ const canAddAlert = ALERT_RESOURCE_EVENT_TYPES[resourceType].some((eventType) => !usedEventTypes.includes(eventType));@@ -258,7 +264,9 @@ export const AlertAction = ({isOpen={popUp.alert.isOpen}onOpenChange={(isOpen) => handlePopUpToggle("alert", isOpen)}projectId={projectId}- resourceId={identityId}+ resourceType={resourceType}+ resourceId={resourceId}+ channelPaywall={channelPaywall}alert={selectedAlert}unavailableEventTypes={usedEventTypes}/>diff --git a/frontend/src/views/Alerts/AlertForm.tsx b/frontend/src/views/Alerts/AlertForm.tsxindex 541f935d3c..ba6085da99 100644--- a/frontend/src/views/Alerts/AlertForm.tsx+++ b/frontend/src/views/Alerts/AlertForm.tsx@@ -26,6 +26,7 @@ import { useScopeVariant } from "@app/hooks";import {ALERT_EVENT_TYPE_DESCRIPTIONS,ALERT_EVENT_TYPE_LABELS,+ ALERT_RESOURCE_EVENT_TYPES,ALERT_RESOURCE_TYPE_LABELS,AlertEventType,alertFormSchema,@@ -34,6 +35,7 @@ import {MIN_ALERT_BEFORE_DAYS,parseAlertBeforeDays,TAlert,+ TAlertChannelPaywall,TAlertForm,TChannelForm,toAlertBefore,@@ -46,7 +48,9 @@ import { ChannelsField } from "./ChannelsField";type Props = {projectId?: string;+ resourceType?: AlertResourceType;resourceId?: string;+ channelPaywall?: TAlertChannelPaywall;alert?: TAlert;unavailableEventTypes?: AlertEventType[];onComplete: () => void;@@ -56,9 +60,13 @@ type Props = {const DEFAULT_ALERT_BEFORE_DAYS = 7;const DEFAULT_ALERT_NAMES: Record<AlertEventType, string> = {[AlertEventType.IdentityAuthenticationExpiry]: "Credential expiration alert",- [AlertEventType.IdentityAuthMethodChanged]: "Auth method change alert"+ [AlertEventType.IdentityAuthMethodChanged]: "Auth method change alert",+ [AlertEventType.PamAccessRequested]: "Access requested alert",+ [AlertEventType.PamAccessRequestApproved]: "Request approved alert",+ [AlertEventType.PamAccessRequestDenied]: "Request denied alert",+ [AlertEventType.PamAccessRequestBypassed]: "Break-glass alert"};-const AGENT_VAULT_ALERT_NAME_PLACEHOLDERS: Record<AlertEventType, string> = {+const AGENT_VAULT_ALERT_NAME_PLACEHOLDERS: Partial<Record<AlertEventType, string>> = {[AlertEventType.IdentityAuthenticationExpiry]: "Credential expiration alert",[AlertEventType.IdentityAuthMethodChanged]: "Auth method change alert"};@@ -81,6 +89,7 @@ const toChannelForm = (channel: TAlert["channels"][number]): TChannelForm => ({const buildFormDefaults = (alert: TAlert | undefined,+ resourceType: AlertResourceType,defaultEventType: AlertEventType,defaultName: string): TAlertForm => {@@ -88,7 +97,7 @@ const buildFormDefaults = (return {name: defaultName,description: "",- resourceType: AlertResourceType.IdentityAuthentication,+ resourceType,eventType: defaultEventType,alertBeforeDays: DEFAULT_ALERT_BEFORE_DAYS,dailyReminder: false,@@ -113,7 +122,9 @@ const buildFormDefaults = (export const AlertForm = ({projectId,+ resourceType: alertResourceType = AlertResourceType.IdentityAuthentication,resourceId,+ channelPaywall,alert,unavailableEventTypes = [],onComplete,@@ -124,14 +135,15 @@ export const AlertForm = ({const isAgentVault = scopeVariant === "av";const createAlert = useCreateAlert();const updateAlert = useUpdateAlert();+ const eventTypes = ALERT_RESOURCE_EVENT_TYPES[alertResourceType];const defaultEventType =- Object.values(AlertEventType).find((eventType) => !unavailableEventTypes.includes(eventType)) ??- DEFAULT_EVENT_TYPE;+ eventTypes.find((eventType) => !unavailableEventTypes.includes(eventType)) ?? eventTypes[0];const formMethods = useForm<TAlertForm>({resolver: zodResolver(alertFormSchema),defaultValues: buildFormDefaults(alert,+ alertResourceType,defaultEventType,isAgentVault ? "" : DEFAULT_ALERT_NAMES[defaultEventType])@@ -254,7 +266,7 @@ export const AlertForm = ({<SelectValue /></SelectTrigger><SelectContent position="popper">- {Object.values(AlertEventType).map((eventType) => (+ {eventTypes.map((eventType) => (<SelectItemkey={eventType}value={eventType}@@ -361,6 +373,7 @@ export const AlertForm = ({projectId={projectId}resourceType={resourceTypeValue}resourceId={resourceId ?? alert?.resourceId ?? null}+ channelPaywall={channelPaywall}/></div>diff --git a/frontend/src/views/Alerts/ChannelsField.tsx b/frontend/src/views/Alerts/ChannelsField.tsxindex f87fd4633e..bc074746da 100644--- a/frontend/src/views/Alerts/ChannelsField.tsx+++ b/frontend/src/views/Alerts/ChannelsField.tsx@@ -1,10 +1,13 @@+import { useState } from "react";import { useFieldArray, useFormContext } from "react-hook-form";+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";import { Label } from "@app/components/v3";import {ALERT_CHANNEL_TYPE_LABELS,AlertChannelType,AlertPrincipalType,+ TAlertChannelPaywall,TAlertForm,TChannelForm} from "@app/hooks/api/alerts";@@ -16,6 +19,7 @@ type Props = {projectId?: string;resourceType: string;resourceId?: string | null;+ channelPaywall?: TAlertChannelPaywall;};const buildNewChannel = (channelType: AlertChannelType, name: string): TChannelForm => ({@@ -39,7 +43,8 @@ export const buildNextChannel = (existing: { name: string }[], channelType: Alerreturn buildNewChannel(channelType, name);};-export const ChannelsField = ({ projectId, resourceType, resourceId }: Props) => {+export const ChannelsField = ({ projectId, resourceType, resourceId, channelPaywall }: Props) => {+ const [isUpgradeOpen, setIsUpgradeOpen] = useState(false);const {control,getValues,@@ -63,7 +68,21 @@ export const ChannelsField = ({ projectId, resourceType, resourceId }: Props) =></Label><span className="text-xs text-muted">Add at least one delivery channel.</span></div>- <AddChannelMenu onAdd={appendChannel} />+ <AddChannelMenu+ onAdd={appendChannel}+ lockedChannelTypes={channelPaywall?.lockedChannelTypes}+ onLockedSelect={() => setIsUpgradeOpen(true)}+ contentClassName={channelPaywall ? "min-w-56" : undefined}+ />+ {channelPaywall && (+ <UpgradePlanModal+ isOpen={isUpgradeOpen}+ onOpenChange={setIsUpgradeOpen}+ paywallKey={channelPaywall.paywallKey}+ text={channelPaywall.text}+ isEnterpriseFeature+ />+ )}</div>{rootError && <p className="text-xs text-danger">{rootError}</p>}