Skip to content

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

fix(pam): address slack notification review feedback

bernie-g14386c5003c8
diff --git a/backend/src/db/migrations/20260708143943_pam-folder-notification-configs.ts b/backend/src/db/migrations/20260708143943_pam-folder-notification-configs.ts
index ae28f4c2a0..f91820afd0 100644
--- a/backend/src/db/migrations/20260708143943_pam-folder-notification-configs.ts
+++ b/backend/src/db/migrations/20260708143943_pam-folder-notification-configs.ts
@@ -15,8 +15,7 @@ export async function up(knex: Knex): Promise<void> {
t.foreign("workflowIntegrationId").references("id").inTable(TableName.WorkflowIntegrations).onDelete("CASCADE");
t.index(["workflowIntegrationId"]);
// [{ id, name }] channel objects; names are stored so the UI can render chips for viewers
- // who lack org Settings read (the Slack channel-list API), and so Teams can extend the
- // object shape (e.g. teamId) without a schema change.
+ // who lack org Settings read (the Slack channel-list API).
t.jsonb("channels").notNullable();
t.jsonb("events").notNullable();
t.timestamps(true, true, true);
diff --git a/backend/src/ee/routes/v1/pam-routers/pam-approval-configuration-router.ts b/backend/src/ee/routes/v1/pam-routers/pam-approval-configuration-router.ts
index 00d67e017e..caa5633335 100644
--- a/backend/src/ee/routes/v1/pam-routers/pam-approval-configuration-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-approval-configuration-router.ts
@@ -27,6 +27,17 @@ const NotificationConfigSchema = z.object({
events: z.array(z.nativeEnum(PamNotificationEvent)).min(1)
});
+// Responses describe stored data rather than constrain it, so a row whose jsonb fails parsing
+// (returned as an empty array) can't fail serialization and break the whole GET
+const NotificationConfigResponseSchema = z.object({
+ id: z.string().uuid(),
+ workflowIntegrationId: z.string().uuid(),
+ integration: z.string(),
+ integrationSlug: z.string(),
+ channels: z.object({ id: z.string(), name: z.string() }).array(),
+ events: z.nativeEnum(PamNotificationEvent).array()
+});
+
export const registerPamApprovalConfigurationRouter = async (server: FastifyZodProvider) => {
server.route({
method: "GET",
@@ -43,13 +54,7 @@ export const registerPamApprovalConfigurationRouter = async (server: FastifyZodP
approvers: z.array(ApproverSchema)
})
),
- notificationConfigs: z.array(
- NotificationConfigSchema.extend({
- id: z.string().uuid(),
- integration: z.string(),
- integrationSlug: z.string()
- })
- )
+ notificationConfigs: z.array(NotificationConfigResponseSchema)
})
}
},
diff --git a/backend/src/ee/services/pam-access-request/pam-access-request-fns.test.ts b/backend/src/ee/services/pam-access-request/pam-access-request-fns.test.ts
deleted file mode 100644
index 03bece775b..0000000000
--- a/backend/src/ee/services/pam-access-request/pam-access-request-fns.test.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-import { PamNotificationEvent } from "../pam/pam-enums";
-import { getSlackSendTargets, TFolderNotificationConfigRow } from "./pam-access-request-fns";
-
-const baseConfig = (overrides: Partial<TFolderNotificationConfigRow> = {}): TFolderNotificationConfigRow => ({
- workflowIntegrationId: "integration-1",
- integration: "slack",
- status: "installed",
- channels: [{ id: "C123", name: "access-requests" }],
- events: [PamNotificationEvent.AccessRequested],
- ...overrides
-});
-
-describe("getSlackSendTargets", () => {
- test("returns channel ids for a subscribed slack config", () => {
- const targets = getSlackSendTargets([baseConfig()], PamNotificationEvent.AccessRequested);
- expect(targets).toEqual([{ workflowIntegrationId: "integration-1", channelIds: ["C123"] }]);
- });
-
- test("skips configs not subscribed to the event", () => {
- const targets = getSlackSendTargets([baseConfig()], PamNotificationEvent.AccessRequestApproved);
- expect(targets).toEqual([]);
- });
-
- test("skips non-slack integrations", () => {
- const targets = getSlackSendTargets(
- [baseConfig({ integration: "microsoft-teams" })],
- PamNotificationEvent.AccessRequested
- );
- expect(targets).toEqual([]);
- });
-
- test("skips integrations that are not installed", () => {
- const targets = getSlackSendTargets([baseConfig({ status: "pending" })], PamNotificationEvent.AccessRequested);
- expect(targets).toEqual([]);
- });
-
- test("skips configs with no channels", () => {
- const targets = getSlackSendTargets([baseConfig({ channels: [] })], PamNotificationEvent.AccessRequested);
- expect(targets).toEqual([]);
- });
-
- test("tolerates malformed jsonb values", () => {
- const targets = getSlackSendTargets(
- [baseConfig({ channels: "not-an-array", events: { bogus: true } })],
- PamNotificationEvent.AccessRequested
- );
- expect(targets).toEqual([]);
- });
-
- test("fans out across multiple matching configs", () => {
- const targets = getSlackSendTargets(
- [
- baseConfig(),
- baseConfig({
- workflowIntegrationId: "integration-2",
- channels: [
- { id: "C456", name: "sre-oncall" },
- { id: "C789", name: "security" }
- ],
- events: [PamNotificationEvent.AccessRequested, PamNotificationEvent.AccessRequestDenied]
- })
- ],
- PamNotificationEvent.AccessRequested
- );
- expect(targets).toEqual([
- { workflowIntegrationId: "integration-1", channelIds: ["C123"] },
- { workflowIntegrationId: "integration-2", channelIds: ["C456", "C789"] }
- ]);
- });
-});
diff --git a/backend/src/ee/services/pam-access-request/pam-access-request-fns.ts b/backend/src/ee/services/pam-access-request/pam-access-request-fns.ts
index 9b9db3d54e..2bb20c1335 100644
--- a/backend/src/ee/services/pam-access-request/pam-access-request-fns.ts
+++ b/backend/src/ee/services/pam-access-request/pam-access-request-fns.ts
@@ -28,18 +28,27 @@ export type TFolderNotificationConfigRow = {
events: unknown;
};
-// Resolves which Slack sends a folder's configs call for on a given event. Pure so the
-// subscription/platform/status filtering is unit-testable without a DB.
-export const getSlackSendTargets = (configs: TFolderNotificationConfigRow[], event: PamNotificationEvent) =>
- configs
- .filter(
- (config) =>
- config.integration === WorkflowIntegration.SLACK &&
- config.status === WorkflowIntegrationStatus.INSTALLED &&
- parseNotificationEvents(config.events).includes(event)
- )
- .map((config) => ({
- workflowIntegrationId: config.workflowIntegrationId,
- channelIds: parseNotificationChannels(config.channels).map((channel) => channel.id)
- }))
- .filter((target) => target.channelIds.length > 0);
+// Channel ids are merged per integration so overlapping configs can't post the same message twice
+export const getSlackSendTargets = (configs: TFolderNotificationConfigRow[], event: PamNotificationEvent) => {
+ const channelIdsByIntegration = new Map<string, Set<string>>();
+
+ for (const config of configs) {
+ const isSubscribed =
+ config.integration === WorkflowIntegration.SLACK &&
+ config.status === WorkflowIntegrationStatus.INSTALLED &&
+ parseNotificationEvents(config.events).includes(event);
+ if (!isSubscribed) continue;
+
+ const channelIds = parseNotificationChannels(config.channels).map((channel) => channel.id);
+ if (!channelIds.length) continue;
+
+ const existing = channelIdsByIntegration.get(config.workflowIntegrationId) ?? new Set<string>();
+ channelIds.forEach((id) => existing.add(id));
+ channelIdsByIntegration.set(config.workflowIntegrationId, existing);
+ }
+
+ return [...channelIdsByIntegration.entries()].map(([workflowIntegrationId, channelIds]) => ({
+ workflowIntegrationId,
+ channelIds: [...channelIds]
+ }));
+};
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 778c45c97c..764d9af466 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
@@ -250,7 +250,9 @@ export const pamAccessRequestServiceFactory = ({
accountName: params.accountName ?? "a PAM account",
folderName: folder?.name ?? "",
comment: params.comment,
- approvalUrl: `${cfg.SITE_URL}/organizations/${params.orgId}/pam/approval-requests?requestId=${params.requestId}`
+ // Decided requests leave the approver inbox, so decision messages link to the
+ // requester-facing My Access page (same destination as the in-app notification)
+ approvalUrl: `${cfg.SITE_URL}/organizations/${params.orgId}/pam/access`
}
}
});
@@ -753,7 +755,7 @@ export const pamAccessRequestServiceFactory = ({
logger.error(err, `Failed to send approval emails for PAM access request [requestId=${request.id}]`);
}
- await triggerFolderSlackNotifications({
+ void triggerFolderSlackNotifications({
folderId: account.folderId,
event: PamNotificationEvent.AccessRequested,
orgId: ctx.actorOrgId,
@@ -1073,7 +1075,7 @@ export const pamAccessRequestServiceFactory = ({
);
if (folderId) {
- await notifyFolderChannelsOfDecision({
+ void notifyFolderChannelsOfDecision({
folderId,
decision: ApprovalRequestApprovalDecision.Rejected,
requesterName: request.requesterName,
@@ -1194,7 +1196,7 @@ export const pamAccessRequestServiceFactory = ({
);
if (folderId) {
- await notifyFolderChannelsOfDecision({
+ void notifyFolderChannelsOfDecision({
folderId,
decision: ApprovalRequestApprovalDecision.Approved,
requesterName: request.requesterName,
diff --git a/backend/src/ee/services/pam/CLAUDE.md b/backend/src/ee/services/pam/CLAUDE.md
index a90b54e975..417302ae80 100644
--- a/backend/src/ee/services/pam/CLAUDE.md
+++ b/backend/src/ee/services/pam/CLAUDE.md
@@ -171,7 +171,7 @@ No migration, no router or response-schema change (beyond `policyRules` for gate
Folder-level, not project-level: each folder's Approvals tab can attach org `workflow_integrations` (Slack only for now) with channels and subscribed events, stored in `pam_folder_notification_configs` (`channels` and `events` are jsonb; channel objects are `{ id, name }` so the UI renders names without needing the org-gated Slack channel-list API). This intentionally does NOT use `project_slack_configs` or `triggerWorkflowIntegrationNotification`, which resolve config by projectId (the single PAM project would make the config org-wide).
-Flow: `createRequest` and `reviewRequest` in `pam-access-request-service.ts` call `triggerFolderSlackNotifications`, which filters configs via the pure `getSlackSendTargets` (`pam-access-request-fns.ts`, unit-tested) and sends through the shared `sendSlackNotification` (`services/slack/slack-fns.ts`). Events are `PamNotificationEvent` in `pam/pam-enums.ts` (mirrored in the frontend enums file). New `TriggerFeature.PAM_*` variants carry the payloads; their Slack templates live in `buildSlackPayload`. All sends are fire-and-forget (never fail the request flow). Config writes ride the existing PUT approval-configuration endpoint (undefined `notificationConfigs` leaves configs unchanged; empty array deletes all). Microsoft Teams can be added later by branching on `integration` in the trigger helper, the table needs no change.
+Flow: `createRequest` and `reviewRequest` in `pam-access-request-service.ts` call `triggerFolderSlackNotifications`, which filters configs via the pure `getSlackSendTargets` (`pam-access-request-fns.ts`) and sends through the shared `sendSlackNotification` (`services/slack/slack-fns.ts`). Events are `PamNotificationEvent` in `pam/pam-enums.ts` (mirrored in the frontend enums file). New `TriggerFeature.PAM_*` variants carry the payloads; their Slack templates live in `buildSlackPayload`. All sends are fire-and-forget (never fail the request flow). Config writes ride the existing PUT approval-configuration endpoint (undefined `notificationConfigs` leaves configs unchanged; empty array deletes all). Additional chat platforms can be added later by branching on `integration` in the trigger helper, the table needs no change.
## Credential Rotation
diff --git a/backend/src/ee/services/pam/pam-enums.ts b/backend/src/ee/services/pam/pam-enums.ts
index 00eecb7e73..a077a790fb 100644
--- a/backend/src/ee/services/pam/pam-enums.ts
+++ b/backend/src/ee/services/pam/pam-enums.ts
@@ -54,7 +54,7 @@ export enum PamMemberKind {
Identity = "identity"
}
-// Events a folder's chat notification config (Slack, later Teams) can subscribe to
+// Events a folder's chat notification config can subscribe to
export enum PamNotificationEvent {
AccessRequested = "access-requested",
AccessRequestApproved = "access-request-approved",
diff --git a/backend/src/services/slack/slack-fns.ts b/backend/src/services/slack/slack-fns.ts
index 77f2e6c5d0..133e96d67c 100644
--- a/backend/src/services/slack/slack-fns.ts
+++ b/backend/src/services/slack/slack-fns.ts
@@ -345,7 +345,7 @@ const buildSlackPayload = (notification: TNotification) => {
type: "button",
text: {
type: "plain_text",
- text: "View request",
+ text: "View access",
emoji: true
},
style: "primary",
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx
index 61d8ed7ee2..e17926df83 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderApprovalsTab.tsx
@@ -151,6 +151,14 @@ export const FolderApprovalsTab = ({ folderId, onDirtyChange }: Props) => {
[config]
);
+ const integrationSlugById = useMemo(
+ () =>
+ Object.fromEntries(
+ (config?.notificationConfigs ?? []).map((c) => [c.workflowIntegrationId, c.integrationSlug])
+ ),
+ [config]
+ );
+
useEffect(() => {
setApprovers(savedApprovers);
setIsDirty(false);
@@ -369,7 +377,11 @@ export const FolderApprovalsTab = ({ folderId, onDirtyChange }: Props) => {
</CardContent>
</Card>
- <FolderNotificationsSection configs={notificationConfigs} onChange={setNotificationConfigs} />
+ <FolderNotificationsSection
+ configs={notificationConfigs}
+ integrationSlugById={integrationSlugById}
+ onChange={setNotificationConfigs}
+ />
<Card>
<CardHeader className="border-b">
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/FolderNotificationsSection.tsx b/frontend/src/pages/pam/PamAccountsPage/components/FolderNotificationsSection.tsx
index 12ef3fe77d..9c55d1ac1a 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/FolderNotificationsSection.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/FolderNotificationsSection.tsx
@@ -1,5 +1,5 @@
import { useMemo } from "react";
-import { Plus, Slack, Trash2 } from "lucide-react";
+import { ChevronDown, Plus, Slack, Trash2 } from "lucide-react";
import {
Badge,
@@ -42,6 +42,7 @@ type EventOption = (typeof EVENT_OPTIONS)[number];
type ConfigCardProps = {
config: TPamNotificationConfig;
integrationOptions: IntegrationOption[];
+ integrationSlugById: Record<string, string>;
onChange: (config: TPamNotificationConfig) => void;
onRemove: () => void;
};
@@ -49,6 +50,7 @@ type ConfigCardProps = {
const NotificationConfigCard = ({
config,
integrationOptions,
+ integrationSlugById,
onChange,
onRemove
}: ConfigCardProps) => {
@@ -64,8 +66,21 @@ const NotificationConfigCard = ({
[slackChannels]
);
+ // Viewers without org Settings read can't list integrations, so fall back to the slug the
+ // saved config was returned with to keep the selected workspace readable
+ const workspaceOptions = useMemo<IntegrationOption[]>(() => {
+ const { workflowIntegrationId } = config;
+ if (!workflowIntegrationId || integrationOptions.some((opt) => opt.value === workflowIntegrationId)) {
+ return integrationOptions;
+ }
+ const fallbackLabel = integrationSlugById[workflowIntegrationId];
+ return fallbackLabel
+ ? [...integrationOptions, { value: workflowIntegrationId, label: fallbackLabel }]
+ : integrationOptions;
+ }, [integrationOptions, config.workflowIntegrationId, integrationSlugById]);
+
const selectedIntegration =
- integrationOptions.find((opt) => opt.value === config.workflowIntegrationId) ?? null;
+ workspaceOptions.find((opt) => opt.value === config.workflowIntegrationId) ?? null;
return (
<div className="flex flex-col gap-4 rounded-md border border-border p-4">
@@ -73,7 +88,7 @@ const NotificationConfigCard = ({
<div className="flex-1">
<FilterableSelect
value={selectedIntegration}
- options={integrationOptions}
+ options={workspaceOptions}
onChange={(opt) => {
const next = opt as IntegrationOption | null;
if (!next || next.value === config.workflowIntegrationId) return;
@@ -150,10 +165,11 @@ const NotificationConfigCard = ({
type Props = {
configs: TPamNotificationConfig[];
+ integrationSlugById: Record<string, string>;
onChange: (configs: TPamNotificationConfig[]) => void;
};
-export const FolderNotificationsSection = ({ configs, onChange }: Props) => {
+export const FolderNotificationsSection = ({ configs, integrationSlugById, onChange }: Props) => {
const { currentOrg } = useOrganization();
const { data: workflowIntegrations } = useGetWorkflowIntegrations(currentOrg.id);
@@ -180,7 +196,7 @@ export const FolderNotificationsSection = ({ configs, onChange }: Props) => {
<Badge variant="pam">{configs.length}</Badge>
</CardTitle>
<CardDescription>
- Approvers always get in-app and email notifications. Add Slack to also post to a channel.
+ Notify external channels about access request activity for accounts in this folder.
</CardDescription>
<CardAction>
<DropdownMenu>
@@ -188,6 +204,7 @@ export const FolderNotificationsSection = ({ configs, onChange }: Props) => {
<Button variant="outline" size="sm">
<Plus className="size-4" />
Add
+ <ChevronDown className="size-4 text-muted" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" sideOffset={2}>
@@ -195,7 +212,6 @@ export const FolderNotificationsSection = ({ configs, onChange }: Props) => {
<Slack className="size-4" />
Slack
</DropdownMenuItem>
- <DropdownMenuItem disabled>Microsoft Teams (coming soon)</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</CardAction>
@@ -203,7 +219,8 @@ export const FolderNotificationsSection = ({ configs, onChange }: Props) => {
<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 configured.
+ No chat notifications yet. Add Slack to post this folder&apos;s approval activity to a
+ channel.
</div>
) : (
configs.map((config, idx) => (
@@ -212,6 +229,7 @@ export const FolderNotificationsSection = ({ configs, onChange }: Props) => {
key={idx}
config={config}
integrationOptions={integrationOptions}
+ integrationSlugById={integrationSlugById}
onChange={(next) => onChange(configs.map((c, i) => (i === idx ? next : c)))}
onRemove={() => onChange(configs.filter((_, i) => i !== idx))}
/>