Skip to content

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

improvement: add environment name on webhook call

adilson50c39d61946b
diff --git a/backend/src/ee/services/honey-token/honey-token-service.ts b/backend/src/ee/services/honey-token/honey-token-service.ts
index 225d3ad542..c1d4b39f41 100644
--- a/backend/src/ee/services/honey-token/honey-token-service.ts
+++ b/backend/src/ee/services/honey-token/honey-token-service.ts
@@ -402,6 +402,7 @@ export const honeyTokenServiceFactory = ({
secretPath,
projectId,
environmentSlug: environment,
+ environmentName: folder.environment.name,
excludeReplication: true
});
@@ -585,6 +586,7 @@ export const honeyTokenServiceFactory = ({
secretPath: folderInfo.path,
projectId,
environmentSlug: folderInfo.environmentSlug,
+ environmentName: folderInfo.environmentName,
excludeReplication: true
});
}
@@ -707,6 +709,7 @@ export const honeyTokenServiceFactory = ({
secretPath: folderInfo.path,
projectId,
environmentSlug: folderInfo.environmentSlug,
+ environmentName: folderInfo.environmentName,
excludeReplication: true
});
}
diff --git a/backend/src/ee/services/pit/pit-service.ts b/backend/src/ee/services/pit/pit-service.ts
index 02beef3357..42aee7190c 100644
--- a/backend/src/ee/services/pit/pit-service.ts
+++ b/backend/src/ee/services/pit/pit-service.ts
@@ -420,6 +420,7 @@ export const pitServiceFactory = ({
projectId,
orgId: actorOrgId,
environmentSlug: fp.environmentSlug,
+ environmentName: fp.environmentName,
actorId,
actor
})
@@ -456,6 +457,7 @@ export const pitServiceFactory = ({
projectId,
orgId: actorOrgId,
environmentSlug: folderPath.environmentSlug,
+ environmentName: folderPath.environmentName,
actorId,
actor
});
@@ -504,6 +506,7 @@ export const pitServiceFactory = ({
projectId,
orgId: actorOrgId,
environmentSlug: folderPath.environmentSlug,
+ environmentName: folderPath.environmentName,
actorId,
actor
});
diff --git a/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts b/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts
index 457699a751..50a97e0cd2 100644
--- a/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts
+++ b/backend/src/ee/services/secret-approval-request/secret-approval-request-service.ts
@@ -1202,6 +1202,7 @@ export const secretApprovalRequestServiceFactory = ({
orgId: actorOrgId,
secretPath: folder.path,
environmentSlug: folder.environmentSlug,
+ environmentName: folder.environmentName,
actorId,
actor,
events
diff --git a/backend/src/ee/services/secret-replication/secret-replication-service.ts b/backend/src/ee/services/secret-replication/secret-replication-service.ts
index 8e7212597d..557dad9497 100644
--- a/backend/src/ee/services/secret-replication/secret-replication-service.ts
+++ b/backend/src/ee/services/secret-replication/secret-replication-service.ts
@@ -253,6 +253,7 @@ export const secretReplicationServiceFactory = ({
orgId,
secretPath: foldersGroupedById[folderId][0]?.path as string,
environmentSlug: foldersGroupedById[folderId][0]?.environmentSlug as string,
+ environmentName: foldersGroupedById[folderId][0]?.environmentName as string,
actorId,
actor,
_depth: depth + 1,
@@ -565,6 +566,7 @@ export const secretReplicationServiceFactory = ({
orgId,
secretPath: destinationFolder.path,
environmentSlug: destinationFolder.environmentSlug,
+ environmentName: destinationFolder.environmentName,
actorId,
actor,
_depth: depth + 1,
@@ -851,6 +853,7 @@ export const secretReplicationServiceFactory = ({
orgId,
secretPath: destinationFolder.path,
environmentSlug: destinationFolder.environmentSlug,
+ environmentName: destinationFolder.environmentName,
actorId,
actor,
_depth: depth + 1,
diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
index 40da430d80..75013cfbb8 100644
--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-service.ts
@@ -679,6 +679,7 @@ export const secretRotationV2ServiceFactory = ({
secretPath,
projectId,
environmentSlug: environment,
+ environmentName: folder.environment.name,
excludeReplication: true
});
@@ -819,6 +820,7 @@ export const secretRotationV2ServiceFactory = ({
secretPath: folder.path,
projectId,
environmentSlug: environment.slug,
+ environmentName: environment.name,
excludeReplication: true
});
}
@@ -955,6 +957,7 @@ export const secretRotationV2ServiceFactory = ({
secretPath: folder.path,
projectId,
environmentSlug: environment.slug,
+ environmentName: environment.name,
excludeReplication: true
});
}
@@ -1137,6 +1140,7 @@ export const secretRotationV2ServiceFactory = ({
secretPath: destinationSecretPath,
projectId,
environmentSlug: destinationEnvironment,
+ environmentName: destinationFolder.environment.name,
excludeReplication: true
});
@@ -1146,6 +1150,7 @@ export const secretRotationV2ServiceFactory = ({
secretPath: folder.path,
projectId,
environmentSlug: environment.slug,
+ environmentName: environment.name,
excludeReplication: true
});
@@ -1174,6 +1179,7 @@ export const secretRotationV2ServiceFactory = ({
payload: {
projectId,
environment: environment.slug,
+ environmentName: environment.name,
secretPath: folder.path,
rotationName: secretRotation.name,
triggeredManually: isManualRotation,
@@ -1362,6 +1368,7 @@ export const secretRotationV2ServiceFactory = ({
secretPath: folder.path,
projectId,
environmentSlug: environment.slug,
+ environmentName: environment.name,
excludeReplication: true
});
@@ -2005,6 +2012,7 @@ export const secretRotationV2ServiceFactory = ({
secretPath: folder.path,
projectId,
environmentSlug: environment.slug,
+ environmentName: environment.name,
excludeReplication: true
});
diff --git a/backend/src/services/secret-folder/secret-folder-dal.ts b/backend/src/services/secret-folder/secret-folder-dal.ts
index 076095f2fd..bd178e9387 100644
--- a/backend/src/services/secret-folder/secret-folder-dal.ts
+++ b/backend/src/services/secret-folder/secret-folder-dal.ts
@@ -218,7 +218,8 @@ export const secretFolderDALFactory = (db: TDbClient) => {
.where(`${TableName.Environment}.projectId`, projectId)
.select(
selectAllTableCols(TableName.SecretFolder),
- db.ref("slug").withSchema(TableName.Environment).as("environmentSlug")
+ db.ref("slug").withSchema(TableName.Environment).as("environmentSlug"),
+ db.ref("name").withSchema(TableName.Environment).as("environmentName")
);
if (!targetFolders.length) {
@@ -236,10 +237,13 @@ export const secretFolderDALFactory = (db: TDbClient) => {
const idMap = buildFolderIdMap(allEnvFolders);
- // Map environmentSlug by envId from target folders
+ // Map env slug/name by envId from target folders
const envSlugMap: Record<string, string> = {};
+ const envNameMap: Record<string, string> = {};
for (const f of targetFolders) {
- envSlugMap[f.envId] = (f as typeof f & { environmentSlug: string }).environmentSlug;
+ const typed = f as typeof f & { environmentSlug: string; environmentName: string };
+ envSlugMap[f.envId] = typed.environmentSlug;
+ envNameMap[f.envId] = typed.environmentName;
}
return folderIds.map((folderId) => {
@@ -247,7 +251,12 @@ export const secretFolderDALFactory = (db: TDbClient) => {
if (!folder) return undefined;
const path = buildFolderPath(folder, idMap);
- return { ...folder, path, environmentSlug: envSlugMap[folder.envId] };
+ return {
+ ...folder,
+ path,
+ environmentSlug: envSlugMap[folder.envId],
+ environmentName: envNameMap[folder.envId]
+ };
});
} catch (error) {
throw new DatabaseError({ error, name: "Find by secret path" });
diff --git a/backend/src/services/secret-import/secret-import-service.ts b/backend/src/services/secret-import/secret-import-service.ts
index 57b0e03e45..c0bc9ff874 100644
--- a/backend/src/services/secret-import/secret-import-service.ts
+++ b/backend/src/services/secret-import/secret-import-service.ts
@@ -175,6 +175,7 @@ export const secretImportServiceFactory = ({
orgId: actorOrgId,
projectId,
environmentSlug: importEnv.slug,
+ environmentName: importEnv.name,
pickOnlyImportIds: [secImport.id],
actorId,
actor
@@ -185,6 +186,7 @@ export const secretImportServiceFactory = ({
orgId: actorOrgId,
projectId,
environmentSlug: environment,
+ environmentName: folder.environment.name,
actorId,
actor,
events: [
@@ -416,6 +418,7 @@ export const secretImportServiceFactory = ({
orgId: actorOrgId,
projectId,
environmentSlug: environment,
+ environmentName: folder.environment.name,
actor,
actorId,
events: [
@@ -500,6 +503,7 @@ export const secretImportServiceFactory = ({
secretPath: secretImportDoc.importPath,
projectId,
environmentSlug: secretImportDoc.importEnv.slug,
+ environmentName: secretImportDoc.importEnv.name,
pickOnlyImportIds: [secretImportDoc.id],
actorId,
actor
diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts
index 91633eef81..0064a64d43 100644
--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts
+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-fns.ts
@@ -825,6 +825,7 @@ export const fnUpdateSecretLinkedReferences = async ({
projectId,
orgId,
environmentSlug: folder.environmentSlug,
+ environmentName: folder.environmentName,
secretPath: folder.path,
actor: ActorType.PLATFORM,
actorId: ""
@@ -1207,6 +1208,7 @@ export const fnUpdateMovedSecretReferences = async ({
projectId,
orgId,
environmentSlug: folder.environmentSlug,
+ environmentName: folder.environmentName,
secretPath: folder.path,
actor: ActorType.PLATFORM,
actorId: ""
diff --git a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts
index 8aa6e3f0c6..f962d4049e 100644
--- a/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts
+++ b/backend/src/services/secret-v2-bridge/secret-v2-bridge-service.ts
@@ -448,6 +448,7 @@ export const secretV2BridgeServiceFactory = ({
actor,
projectId,
environmentSlug: folder.environment.slug,
+ environmentName: folder.environment.name,
events: [
{
type: ProjectEvents.SecretCreate,
@@ -756,6 +757,7 @@ export const secretV2BridgeServiceFactory = ({
projectId,
orgId: actorOrgId,
environmentSlug: folder.environment.slug,
+ environmentName: folder.environment.name,
events: [
{
type: ProjectEvents.SecretUpdate,
@@ -885,6 +887,7 @@ export const secretV2BridgeServiceFactory = ({
projectId,
orgId: actorOrgId,
environmentSlug: folder.environment.slug,
+ environmentName: folder.environment.name,
events: [
{
type: ProjectEvents.SecretDelete,
@@ -2074,6 +2077,7 @@ export const secretV2BridgeServiceFactory = ({
projectId,
orgId: actorOrgId,
environmentSlug: folder.environment.slug,
+ environmentName: folder.environment.name,
events: [
{
type: ProjectEvents.SecretCreate,
@@ -2545,6 +2549,7 @@ export const secretV2BridgeServiceFactory = ({
projectId,
orgId: actorOrgId,
environmentSlug: environment,
+ environmentName: projectEnvironment.name,
events: [
{
type: ProjectEvents.SecretUpdate,
@@ -2682,6 +2687,7 @@ export const secretV2BridgeServiceFactory = ({
projectId,
orgId: actorOrgId,
environmentSlug: folder.environment.slug,
+ environmentName: folder.environment.name,
events: [
{
type: ProjectEvents.SecretDelete,
@@ -3356,6 +3362,7 @@ export const secretV2BridgeServiceFactory = ({
orgId: actorOrgId,
secretPath: destinationFolder.path,
environmentSlug: destinationFolder.environment.slug,
+ environmentName: destinationFolder.environment.name,
actorId,
actor,
events: [
@@ -3376,6 +3383,7 @@ export const secretV2BridgeServiceFactory = ({
orgId: actorOrgId,
secretPath: sourceFolder.path,
environmentSlug: sourceFolder.environment.slug,
+ environmentName: sourceFolder.environment.name,
actorId,
actor,
events: [
diff --git a/backend/src/services/secret/secret-queue.ts b/backend/src/services/secret/secret-queue.ts
index 39eccd7926..46b42e79ac 100644
--- a/backend/src/services/secret/secret-queue.ts
+++ b/backend/src/services/secret/secret-queue.ts
@@ -666,6 +666,7 @@ export const secretQueueFactory = ({
projectId,
orgId,
environmentSlug: environment,
+ environmentName,
excludeReplication,
actorId,
actor
@@ -678,6 +679,7 @@ export const secretQueueFactory = ({
type: WebhookEvents.SecretModified,
payload: {
environment,
+ environmentName,
projectId,
secretPath,
changedBy: actorId,
@@ -714,7 +716,8 @@ export const secretQueueFactory = ({
actorId,
actor,
excludeReplication,
- environmentSlug: environment
+ environmentSlug: environment,
+ environmentName
});
}
});
@@ -805,6 +808,7 @@ export const secretQueueFactory = ({
orgId: project.orgId,
secretPath: foldersGroupedById[folderId][0]?.path as string,
environmentSlug: foldersGroupedById[folderId][0]?.environmentSlug as string,
+ environmentName: foldersGroupedById[folderId][0]?.environmentName as string,
_deDupeQueue: deDupeQueue,
_depth: depth + 1,
excludeReplication: true,
@@ -866,6 +870,7 @@ export const secretQueueFactory = ({
orgId: project.orgId,
secretPath: referencedFoldersGroupedById[folderId][0]?.path as string,
environmentSlug: referencedFoldersGroupedById[folderId][0]?.environmentSlug as string,
+ environmentName: referencedFoldersGroupedById[folderId][0]?.environmentName as string,
_deDupeQueue: deDupeQueue,
_depth: depth + 1,
excludeReplication: true,
diff --git a/backend/src/services/secret/secret-service.ts b/backend/src/services/secret/secret-service.ts
index a8c4580ad7..98c0eaf538 100644
--- a/backend/src/services/secret/secret-service.ts
+++ b/backend/src/services/secret/secret-service.ts
@@ -329,7 +329,8 @@ export const secretServiceFactory = ({
actor,
projectId,
orgId: actorOrgId,
- environmentSlug: folder.environment.slug
+ environmentSlug: folder.environment.slug,
+ environmentName: folder.environment.name
});
}
return { ...secret[0], environment, workspace: projectId, tags, secretPath: path };
@@ -474,7 +475,8 @@ export const secretServiceFactory = ({
actorId,
actor,
projectId,
- environmentSlug: folder.environment.slug
+ environmentSlug: folder.environment.slug,
+ environmentName: folder.environment.name
});
}
@@ -589,7 +591,8 @@ export const secretServiceFactory = ({
actor,
projectId,
orgId: actorOrgId,
- environmentSlug: folder.environment.slug
+ environmentSlug: folder.environment.slug,
+ environmentName: folder.environment.name
});
}
@@ -916,7 +919,8 @@ export const secretServiceFactory = ({
secretPath: path,
projectId,
orgId: actorOrgId,
- environmentSlug: folder.environment.slug
+ environmentSlug: folder.environment.slug,
+ environmentName: folder.environment.name
});
return newSecrets;
@@ -1039,7 +1043,8 @@ export const secretServiceFactory = ({
secretPath: path,
projectId,
orgId: actorOrgId,
- environmentSlug: folder.environment.slug
+ environmentSlug: folder.environment.slug,
+ environmentName: folder.environment.name
});
return secrets;
@@ -1141,7 +1146,8 @@ export const secretServiceFactory = ({
secretPath: path,
projectId,
orgId: actorOrgId,
- environmentSlug: folder.environment.slug
+ environmentSlug: folder.environment.slug,
+ environmentName: folder.environment.name
});
return secretsDeleted;
@@ -2855,6 +2861,7 @@ export const secretServiceFactory = ({
projectId: project.id,
orgId: project.orgId,
environmentSlug: environment,
+ environmentName: folder.environment.name,
excludeReplication: true
});
await secretV2BridgeDAL.invalidateSecretCacheByProjectId(project.id);
@@ -2966,6 +2973,7 @@ export const secretServiceFactory = ({
projectId: project.id,
orgId: project.orgId,
environmentSlug: environment,
+ environmentName: folder.environment.name,
excludeReplication: true
});
await secretV2BridgeDAL.invalidateSecretCacheByProjectId(project.id);
@@ -3461,6 +3469,7 @@ export const secretServiceFactory = ({
orgId: project.orgId,
secretPath: destinationFolder.path,
environmentSlug: destinationFolder.environment.slug,
+ environmentName: destinationFolder.environment.name,
actorId,
actor
});
@@ -3473,6 +3482,7 @@ export const secretServiceFactory = ({
orgId: project.orgId,
secretPath: sourceFolder.path,
environmentSlug: sourceFolder.environment.slug,
+ environmentName: sourceFolder.environment.name,
actorId,
actor
});
diff --git a/backend/src/services/secret/secret-types.ts b/backend/src/services/secret/secret-types.ts
index 6698b4c956..10b157cc26 100644
--- a/backend/src/services/secret/secret-types.ts
+++ b/backend/src/services/secret/secret-types.ts
@@ -541,6 +541,7 @@ export type TSyncSecretsDTO<T extends boolean = false> = {
projectId: string;
orgId: string;
environmentSlug: string;
+ environmentName: string;
// cases for just doing sync integration and webhook
excludeReplication?: T;
} & (T extends true
diff --git a/backend/src/services/webhook/webhook-fns.ts b/backend/src/services/webhook/webhook-fns.ts
index 57fd7d464d..309c07b628 100644
--- a/backend/src/services/webhook/webhook-fns.ts
+++ b/backend/src/services/webhook/webhook-fns.ts
@@ -64,7 +64,8 @@ export const triggerWebhookRequest = async (
export const getWebhookPayload = (event: TWebhookPayloads) => {
if (event.type === WebhookEvents.SecretModified) {
- const { projectName, projectId, environment, secretPath, type, changedBy, changedByActorType } = event.payload;
+ const { projectName, projectId, environment, environmentName, secretPath, type, changedBy, changedByActorType } =
+ event.payload;
switch (type) {
case WebhookType.SLACK:
@@ -84,6 +85,11 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
value: environment,
short: false
},
+ {
+ title: "Environment Name",
+ value: environmentName,
+ short: false
+ },
{
title: "Secret Path",
value: secretPath,
@@ -124,6 +130,7 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
facts: [
{ title: "Project", value: projectName || "" },
{ title: "Environment", value: environment },
+ { title: "Environment Name", value: environmentName || "" },
{ title: "Secret Path", value: secretPath || "" },
{ title: "Modified By", value: changedBy || "" },
{
@@ -146,6 +153,7 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
projectId,
projectName,
environment,
+ environmentName,
secretPath,
changedBy,
changedByActorType
@@ -155,8 +163,17 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
}
if (event.type === WebhookEvents.SecretRotationFailed) {
- const { projectName, projectId, environment, secretPath, type, rotationName, errorMessage, triggeredManually } =
- event.payload;
+ const {
+ projectName,
+ projectId,
+ environment,
+ environmentName,
+ secretPath,
+ type,
+ rotationName,
+ errorMessage,
+ triggeredManually
+ } = event.payload;
switch (type) {
case WebhookType.SLACK:
@@ -181,6 +198,11 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
value: environment,
short: false
},
+ {
+ title: "Environment Name",
+ value: environmentName,
+ short: false
+ },
{
title: "Secret Path",
value: secretPath,
@@ -223,6 +245,7 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
{ title: "Rotation Name", value: rotationName || "" },
{ title: "Project", value: projectName || "" },
{ title: "Environment", value: environment },
+ { title: "Environment Name", value: environmentName || "" },
{ title: "Secret Path", value: secretPath || "" },
{ title: "Error Message", value: errorMessage || "" },
{ title: "Triggered Manually", value: triggeredManually ? "Yes" : "No" }
@@ -241,6 +264,7 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
projectId,
projectName,
environment,
+ environmentName,
secretPath,
rotationName,
errorMessage,
@@ -251,7 +275,7 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
}
if (event.type === WebhookEvents.TestEvent) {
- const { projectName, projectId, environment, secretPath } = event.payload;
+ const { projectName, projectId, environment, environmentName, secretPath } = event.payload;
return {
event: event.type,
project: {
@@ -259,6 +283,7 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
projectId,
projectName,
environment,
+ environmentName,
secretPath
}
};
@@ -308,12 +333,13 @@ export const fnTriggerWebhook = async ({
);
projectName = project.name;
}
+ const { environmentName } = event.payload;
const webhooksTriggered = await Promise.allSettled(
toBeTriggeredHooks.map((hook) => {
const formattedEvent = {
type: event.type,
- payload: { ...event.payload, type: hook.type, projectName }
+ payload: { ...event.payload, type: hook.type, projectName, environmentName }
} as TWebhookPayloads;
const payload = getWebhookPayload(formattedEvent);
if (!payload) return;
@@ -332,7 +358,8 @@ export const fnTriggerWebhook = async ({
payload: {
type: toBeTriggeredHooks[i].type!,
...event.payload,
- projectName
+ projectName,
+ environmentName
},
status: "success"
} as WebhookTriggeredEvent["metadata"]);
@@ -348,7 +375,8 @@ export const fnTriggerWebhook = async ({
payload: {
type: toBeTriggeredHooks[i].type!,
...event.payload,
- projectName
+ projectName,
+ environmentName
},
status: "failed"
} as WebhookTriggeredEvent["metadata"]);
diff --git a/backend/src/services/webhook/webhook-service.ts b/backend/src/services/webhook/webhook-service.ts
index e603f3872f..996bd09c82 100644
--- a/backend/src/services/webhook/webhook-service.ts
+++ b/backend/src/services/webhook/webhook-service.ts
@@ -188,6 +188,7 @@ export const webhookServiceFactory = ({
projectName: project.name,
projectId: webhook.projectId,
environment: webhook.environment.slug,
+ environmentName: webhook.environment.name,
secretPath: webhook.secretPath,
type: webhook.type
}
diff --git a/backend/src/services/webhook/webhook-types.ts b/backend/src/services/webhook/webhook-types.ts
index 16ccdc44e7..9791e895c5 100644
--- a/backend/src/services/webhook/webhook-types.ts
+++ b/backend/src/services/webhook/webhook-types.ts
@@ -52,6 +52,7 @@ type TWebhookSecretModifiedEventPayload = {
projectName?: string;
projectId: string;
environment: string;
+ environmentName: string;
secretPath?: string;
type?: string | null;
changedBy?: string;
@@ -67,6 +68,7 @@ type TWebhookSecretRotationFailedEventPayload = {
projectName?: string;
projectId: string;
environment: string;
+ environmentName: string;
secretPath?: string;
triggeredManually?: boolean;
errorMessage?: string;
@@ -80,6 +82,7 @@ type TWebhookTestEventPayload = {
projectName?: string;
projectId: string;
environment: string;
+ environmentName: string;
secretPath?: string;
type?: string | null;
};