Skip to content

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

feat: add secrets.access-request.modified webhook event

InfisiCalvin413f4f266917
diff --git a/backend/src/services/webhook/webhook-fns.test.ts b/backend/src/services/webhook/webhook-fns.test.ts
index 5d3b20d849..025b4dc877 100644
--- a/backend/src/services/webhook/webhook-fns.test.ts
+++ b/backend/src/services/webhook/webhook-fns.test.ts
@@ -1,7 +1,7 @@
import { ActorType } from "@app/services/auth/auth-type";
import { getWebhookPayload } from "./webhook-fns";
-import { ChangeRequestWebhookAction, WebhookEvents, WebhookType } from "./webhook-types";
+import { AccessRequestWebhookAction, ChangeRequestWebhookAction, WebhookEvents, WebhookType } from "./webhook-types";
const projectFields = {
projectId: "proj-1",
@@ -210,3 +210,166 @@ describe("getWebhookPayload: secrets.change-request.modified", () => {
expect(result.attachments[0].content.body.map((b) => b.type)).toEqual(["TextBlock", "FactSet"]);
});
});
+
+const accessRequestPayload = {
+ projectId: "proj-1",
+ projectName: "Secrets management",
+ environment: "prod",
+ environmentName: "Production",
+ secretPath: "/api/*",
+ action: AccessRequestWebhookAction.Reviewed,
+ request: {
+ id: "areq-1",
+ url: "https://app.infisical.com/organizations/org-1/projects/secret-management/proj-1/approval?selectedTab=resource-requests&requestId=areq-1",
+ status: "approved",
+ isBypassed: false,
+ policy: {
+ id: "pol-2",
+ name: "Production access",
+ enforcementLevel: "soft",
+ hasSequencedApprovers: true
+ },
+ requestedAccess: {
+ isTemporary: true,
+ temporaryRange: "1h",
+ permissions: [
+ { subject: "secrets", actions: ["read", "edit"] },
+ { subject: "secret-folders", actions: ["create"] }
+ ]
+ },
+ requestedBy: { type: ActorType.USER as const, id: "user-1", name: "Ada Lovelace", email: "[email protected]" },
+ expiresAt: "2026-08-21T10:00:00.000Z",
+ approvedAt: "2026-08-20T10:42:00.000Z",
+ revokedAt: null,
+ createdAt: "2026-08-20T10:00:00.000Z",
+ updatedAt: "2026-08-20T10:42:00.000Z"
+ }
+};
+
+describe("getWebhookPayload: secrets.access-request.modified", () => {
+ test("general payload nests requested access under the request", () => {
+ const result = getWebhookPayload({
+ type: WebhookEvents.AccessRequestModified,
+ payload: { ...accessRequestPayload, type: WebhookType.GENERAL }
+ });
+
+ expect(result).toEqual({
+ event: "secrets.access-request.modified",
+ action: "reviewed",
+ project: { id: "proj-1", name: "Secrets management" },
+ request: {
+ id: "areq-1",
+ url: accessRequestPayload.request.url,
+ status: "approved",
+ isBypassed: false,
+ policy: {
+ id: "pol-2",
+ name: "Production access",
+ enforcementLevel: "soft",
+ hasSequencedApprovers: true
+ },
+ requestedAccess: {
+ target: {
+ environment: { name: "Production", slug: "prod" },
+ secretPath: "/api/*"
+ },
+ isTemporary: true,
+ temporaryRange: "1h",
+ permissions: [
+ { subject: "secrets", actions: ["read", "edit"] },
+ { subject: "secret-folders", actions: ["create"] }
+ ]
+ },
+ requestedBy: { type: "user", id: "user-1", name: "Ada Lovelace", email: "[email protected]" },
+ expiresAt: "2026-08-21T10:00:00.000Z",
+ approvedAt: "2026-08-20T10:42:00.000Z",
+ revokedAt: null,
+ createdAt: "2026-08-20T10:00:00.000Z",
+ updatedAt: "2026-08-20T10:42:00.000Z"
+ }
+ });
+ });
+
+ test("permissions use code identifiers, never prose", () => {
+ const result = getWebhookPayload({
+ type: WebhookEvents.AccessRequestModified,
+ payload: { ...accessRequestPayload, type: WebhookType.GENERAL }
+ }) as { request: { requestedAccess: { permissions: { subject: string }[] } } };
+
+ expect(result.request.requestedAccess.permissions[1].subject).toBe("secret-folders");
+ expect(JSON.stringify(result)).not.toContain("Secret Folders");
+ });
+
+ test("general payload strips free text fields present on the input", () => {
+ const eventWithFreeText = {
+ type: WebhookEvents.AccessRequestModified,
+ payload: {
+ ...accessRequestPayload,
+ type: WebhookType.GENERAL,
+ note: "Need temporary access to unblock incident-482",
+ editNote: "Narrowed scope to read-only after review",
+ bypassReason: "On-call approved during the outage",
+ request: {
+ ...accessRequestPayload.request,
+ note: "Need temporary access to unblock incident-482",
+ editNote: "Narrowed scope to read-only after review",
+ bypassReason: "On-call approved during the outage"
+ }
+ }
+ } as unknown as Parameters<typeof getWebhookPayload>[0];
+
+ const result = getWebhookPayload(eventWithFreeText);
+
+ const serialized = JSON.stringify(result);
+ expect(serialized).not.toContain("Need temporary access to unblock incident-482");
+ expect(serialized).not.toContain("Narrowed scope to read-only after review");
+ expect(serialized).not.toContain("On-call approved during the outage");
+ });
+
+ test("general payload excludes the packed CASL rule tuples, only the identifier list ships", () => {
+ const eventWithPackedRules = {
+ type: WebhookEvents.AccessRequestModified,
+ payload: {
+ ...accessRequestPayload,
+ type: WebhookType.GENERAL,
+ request: {
+ ...accessRequestPayload.request,
+ permissions: [
+ { subject: ["secrets"], action: ["read", "edit"], conditions: { environment: "prod" }, inverted: false }
+ ]
+ }
+ }
+ } as unknown as Parameters<typeof getWebhookPayload>[0];
+
+ const result = getWebhookPayload(eventWithPackedRules) as {
+ request: { requestedAccess: { permissions: unknown[] } };
+ };
+
+ const serialized = JSON.stringify(result);
+ expect(serialized).not.toContain("conditions");
+ expect(serialized).not.toContain("inverted");
+ expect(result.request.requestedAccess.permissions).toEqual(
+ accessRequestPayload.request.requestedAccess.permissions
+ );
+ });
+
+ test("slack payload renders permissions as a joined string", () => {
+ const result = getWebhookPayload({
+ type: WebhookEvents.AccessRequestModified,
+ payload: { ...accessRequestPayload, type: WebhookType.SLACK }
+ }) as { text: string; attachments: { fields: { title: string; value?: string }[] }[] };
+
+ expect(result.text).toBe("An access request was reviewed.");
+ const permissionField = result.attachments[0].fields.find((f) => f.title === "Requested Access");
+ expect(permissionField?.value).toBe("secrets (read, edit), secret-folders (create)");
+ });
+
+ test("teams payload is an adaptive card with a fact set", () => {
+ const result = getWebhookPayload({
+ type: WebhookEvents.AccessRequestModified,
+ payload: { ...accessRequestPayload, type: WebhookType.MICROSOFT_TEAMS }
+ }) as { attachments: { content: { body: { type: string }[] } }[] };
+
+ expect(result.attachments[0].content.body.map((b) => b.type)).toEqual(["TextBlock", "FactSet"]);
+ });
+});
diff --git a/backend/src/services/webhook/webhook-fns.ts b/backend/src/services/webhook/webhook-fns.ts
index 031d96d212..735593178d 100644
--- a/backend/src/services/webhook/webhook-fns.ts
+++ b/backend/src/services/webhook/webhook-fns.ts
@@ -472,6 +472,99 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
}
}
+ if (event.type === WebhookEvents.AccessRequestModified) {
+ const { projectId, projectName, environment, environmentName, secretPath, type, action, request } = event.payload;
+
+ const formattedPermissions = request.requestedAccess.permissions
+ .map(({ subject, actions }) => `${subject} (${actions.join(", ")})`)
+ .join(", ");
+
+ switch (type) {
+ case WebhookType.SLACK:
+ return {
+ text: `An access request was ${action}.`,
+ attachments: [
+ {
+ color: "#E7F256",
+ fields: [
+ { title: "Project", value: projectName, short: false },
+ { title: "Environment", value: environmentName || environment, short: false },
+ { title: "Secret Path", value: secretPath, short: false },
+ { title: "Policy", value: request.policy.name, short: false },
+ { title: "Status", value: request.status, short: false },
+ { title: "Requested By", value: request.requestedBy?.name || "Unknown", short: false },
+ { title: "Requested Access", value: formattedPermissions, short: false },
+ { title: "Bypassed", value: request.isBypassed ? "Yes" : "No", short: false }
+ ]
+ }
+ ]
+ };
+ case WebhookType.MICROSOFT_TEAMS:
+ return {
+ type: "message",
+ attachments: [
+ {
+ contentType: "application/vnd.microsoft.card.adaptive",
+ content: {
+ type: "AdaptiveCard",
+ version: "1.2",
+ body: [
+ {
+ type: "TextBlock",
+ size: "Medium",
+ weight: "Bolder",
+ text: `An access request was ${action}.`
+ },
+ {
+ type: "FactSet",
+ facts: [
+ { title: "Project", value: projectName || "" },
+ { title: "Environment", value: environmentName || environment },
+ { title: "Secret Path", value: secretPath || "" },
+ { title: "Policy", value: request.policy.name },
+ { title: "Status", value: request.status },
+ { title: "Requested By", value: request.requestedBy?.name || "Unknown" },
+ { title: "Requested Access", value: formattedPermissions },
+ { title: "Bypassed", value: request.isBypassed ? "Yes" : "No" }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ };
+ case WebhookType.GENERAL:
+ default:
+ return {
+ event: event.type,
+ action,
+ project: { id: projectId, name: projectName },
+ request: {
+ id: request.id,
+ url: request.url,
+ status: request.status,
+ isBypassed: request.isBypassed,
+ policy: request.policy,
+ requestedAccess: {
+ target: {
+ environment: { name: environmentName, slug: environment },
+ secretPath
+ },
+ isTemporary: request.requestedAccess.isTemporary,
+ temporaryRange: request.requestedAccess.temporaryRange,
+ permissions: request.requestedAccess.permissions
+ },
+ requestedBy: request.requestedBy,
+ expiresAt: request.expiresAt,
+ approvedAt: request.approvedAt,
+ revokedAt: request.revokedAt,
+ createdAt: request.createdAt,
+ updatedAt: request.updatedAt
+ }
+ };
+ }
+ }
+
if (event.type === WebhookEvents.TestEvent) {
const { projectName, projectId, environment, environmentName, secretPath } = event.payload;
return {
diff --git a/backend/src/services/webhook/webhook-types.ts b/backend/src/services/webhook/webhook-types.ts
index 6574b3d66b..44907fdf4c 100644
--- a/backend/src/services/webhook/webhook-types.ts
+++ b/backend/src/services/webhook/webhook-types.ts
@@ -45,6 +45,7 @@ export enum WebhookEvents {
SecretRotationFailed = "secrets.rotation-failed",
HoneyTokenTriggered = "honey-token.triggered",
ChangeRequestModified = "secrets.change-request.modified",
+ AccessRequestModified = "secrets.access-request.modified",
TestEvent = "test"
}
@@ -52,7 +53,8 @@ export const SUBSCRIBABLE_WEBHOOK_EVENTS = [
WebhookEvents.SecretModified,
WebhookEvents.SecretRotationFailed,
WebhookEvents.HoneyTokenTriggered,
- WebhookEvents.ChangeRequestModified
+ WebhookEvents.ChangeRequestModified,
+ WebhookEvents.AccessRequestModified
] as const;
export enum ChangeRequestWebhookAction {
@@ -63,6 +65,18 @@ export enum ChangeRequestWebhookAction {
Merged = "merged"
}
+export enum AccessRequestWebhookAction {
+ Created = "created",
+ Edited = "edited",
+ Reviewed = "reviewed",
+ Revoked = "revoked"
+}
+
+export type TWebhookRequestedPermission = {
+ subject: string;
+ actions: string[];
+};
+
export type TWebhookActor = {
type: ActorType.USER | ActorType.IDENTITY;
id: string;
@@ -155,9 +169,46 @@ type TWebhookChangeRequestModifiedEventPayload = {
};
};
+type TWebhookAccessRequestModifiedEventPayload = {
+ type: WebhookEvents.AccessRequestModified;
+ payload: {
+ projectId: string;
+ projectName?: string;
+ environment: string;
+ environmentName?: string;
+ secretPath?: string;
+ type?: string | null;
+ action: AccessRequestWebhookAction;
+ request: {
+ id: string;
+ url: string;
+ status: string;
+ isBypassed: boolean;
+ policy: {
+ id: string;
+ name: string;
+ enforcementLevel: string;
+ hasSequencedApprovers: boolean;
+ };
+ requestedAccess: {
+ isTemporary: boolean;
+ temporaryRange: string | null;
+ permissions: TWebhookRequestedPermission[];
+ };
+ requestedBy: TWebhookActor | null;
+ expiresAt: string | null;
+ approvedAt: string | null;
+ revokedAt: string | null;
+ createdAt: string;
+ updatedAt: string;
+ };
+ };
+};
+
export type TWebhookPayloads =
| TWebhookSecretModifiedEventPayload
| TWebhookSecretRotationFailedEventPayload
| TWebhookHoneyTokenTriggeredEventPayload
| TWebhookChangeRequestModifiedEventPayload
+ | TWebhookAccessRequestModifiedEventPayload
| TWebhookTestEventPayload;