Skip to content

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

address reviews

Andrey80283e00db97
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.ts
index 096f995c82..3588ee17df 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
@@ -227,6 +227,7 @@ export const pamAccessRequestServiceFactory = ({
bypassers: dedupedBreakGlassUsers
});
+ let removedNotificationConfigIds: string[] = [];
if (notificationConfigs !== undefined) {
if (notificationConfigs.length > 0) {
const integrationIds = [...new Set(notificationConfigs.map((c) => c.workflowIntegrationId))];
@@ -247,32 +248,28 @@ export const pamAccessRequestServiceFactory = ({
}
// Legacy Slack configs can only be removed, so every config sent back must match a stored one.
- await pamFolderNotificationConfigDAL.transaction(async (tx) => {
- const unmatchedKeyById = new Map(
- (await pamFolderNotificationConfigDAL.findByFolderIdWithIntegration(folderId, tx)).map((row) => [
- row.id,
- toNotificationConfigKey({
- workflowIntegrationId: row.workflowIntegrationId,
- channels: parseNotificationChannels(row.channels),
- events: parseNotificationEvents(row.events)
- })
- ])
- );
- for (const config of notificationConfigs) {
- const key = toNotificationConfigKey(config);
- const matchedId = [...unmatchedKeyById.keys()].find((id) => unmatchedKeyById.get(id) === key);
- if (!matchedId) {
- 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."
- });
- }
- unmatchedKeyById.delete(matchedId);
- }
- if (unmatchedKeyById.size > 0) {
- await pamFolderNotificationConfigDAL.delete({ $in: { id: [...unmatchedKeyById.keys()] } }, tx);
+ const unmatchedKeyById = new Map<string, string>(
+ (await pamFolderNotificationConfigDAL.findByFolderIdWithIntegration(folderId)).map((row) => [
+ row.id,
+ toNotificationConfigKey({
+ workflowIntegrationId: row.workflowIntegrationId,
+ channels: parseNotificationChannels(row.channels),
+ events: parseNotificationEvents(row.events)
+ })
+ ])
+ );
+ for (const config of notificationConfigs) {
+ const key = toNotificationConfigKey(config);
+ const matchedId = [...unmatchedKeyById.keys()].find((id) => unmatchedKeyById.get(id) === key);
+ if (!matchedId) {
+ 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."
+ });
}
- });
+ unmatchedKeyById.delete(matchedId);
+ }
+ removedNotificationConfigIds = [...unmatchedKeyById.keys()];
}
const { policyId } = await approvalPolicyService.setScopeConfiguration(
@@ -289,6 +286,11 @@ export const pamAccessRequestServiceFactory = ({
toApprovalActor(ctx)
);
+ // Removed only once the policy saves, so a failed save keeps the Slack configs.
+ if (removedNotificationConfigIds.length > 0) {
+ await pamFolderNotificationConfigDAL.delete({ $in: { id: removedNotificationConfigIds } });
+ }
+
return {
policyId,
folderId,
diff --git a/backend/src/services/alert/providers/pam-folder-alert-provider.ts b/backend/src/services/alert/providers/pam-folder-alert-provider.ts
index 602f0a8167..fe98f7a8f2 100644
--- a/backend/src/services/alert/providers/pam-folder-alert-provider.ts
+++ b/backend/src/services/alert/providers/pam-folder-alert-provider.ts
@@ -305,7 +305,8 @@ export const pamFolderAlertProviderFactory = ({
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.`
+ message:
+ "Your plan only allows email channels for PAM alerts. Upgrade to the Enterprise plan to use Slack, webhook, or PagerDuty channels."
});
}
};
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx
index 76d2a81a3e..aaa2eebc48 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx
@@ -548,7 +548,6 @@ export const FolderApprovalsTab = ({ folderId, onDirtyChange }: Props) => {
resourceType={AlertResourceType.PamFolder}
resourceId={folderId}
projectId={currentProject.id}
- renderPermissionGate={(render) => render(true)}
channelPaywall={
subscription?.pamEnterpriseAlerting
? undefined
diff --git a/frontend/src/views/Alerts/AlertAction.tsx b/frontend/src/views/Alerts/AlertAction.tsx
index 9f324954b1..bddf79087a 100644
--- a/frontend/src/views/Alerts/AlertAction.tsx
+++ b/frontend/src/views/Alerts/AlertAction.tsx
@@ -53,9 +53,8 @@ type Props = {
projectId?: string;
// Renders the alerts without any way to create, edit or remove them.
readOnly?: boolean;
- // Wraps the mutating actions in the caller's permission gate (org- or project-scoped), which is the
- // only thing that differs between the org and project entry points.
- renderPermissionGate: (render: (isAllowed: boolean) => ReactNode) => ReactNode;
+ // The caller's permission gate for mutating actions; omit it when the view is already gated.
+ renderPermissionGate?: (render: (isAllowed: boolean) => ReactNode) => ReactNode;
};
const getEnabledChannelTypes = (alert: TAlert): AlertChannelType[] =>
@@ -69,7 +68,7 @@ export const AlertAction = ({
channelPaywall,
projectId,
readOnly = false,
- renderPermissionGate
+ renderPermissionGate = (render) => render(true)
}: Props) => {
const { data: alerts = [] } = useListAlerts({
resourceType,