Skip to content

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

add user name for secrets modified

adilson4aae30c0fd34
diff --git a/backend/src/services/secret/secret-queue.ts b/backend/src/services/secret/secret-queue.ts
index e799103df3..00fb704115 100644
--- a/backend/src/services/secret/secret-queue.ts
+++ b/backend/src/services/secret/secret-queue.ts
@@ -230,19 +230,35 @@ export const secretQueueFactory = ({
};
const resolveChangedByDisplayName = async (changedBy: string, changedByActorType: ActorType) => {
- switch (changedByActorType) {
- case ActorType.USER: {
- const user = await userDAL.findById(changedBy);
- return user?.email || user?.username || changedBy;
- }
- case ActorType.IDENTITY: {
- const identity = await identityDAL.findById(changedBy);
- return identity?.name || changedBy;
+ try {
+ switch (changedByActorType) {
+ case ActorType.USER: {
+ const user = await userDAL.findById(changedBy);
+ return user?.email || user?.username || changedBy;
+ }
+ case ActorType.IDENTITY: {
+ const identity = await identityDAL.findById(changedBy);
+ return identity?.name || changedBy;
+ }
+ case ActorType.PLATFORM:
+ return "Platform";
+ case ActorType.KMIP_CLIENT:
+ return "KMIP Client";
+ case ActorType.SERVICE:
+ return "Service";
+ case ActorType.ACME_PROFILE:
+ return "ACME Profile";
+ case ActorType.ACME_ACCOUNT:
+ return "ACME Account";
+ default:
+ return `Unknown Actor [${changedByActorType}]`;
}
- case ActorType.PLATFORM:
- return "Platform";
- default:
- return changedBy;
+ } catch (error) {
+ logger.error(
+ error,
+ `Failed to resolve changed by display name for [changedBy=${changedBy}] [changedByActorType=${changedByActorType}]`
+ );
+ return `Failed to resolve display name`;
}
};
@@ -1576,12 +1592,15 @@ export const secretQueueFactory = ({
});
// Resolve changedBy from UUID to human-readable display name
+ let webhookEvent = job.data;
if (job.data.type === WebhookEvents.SecretModified) {
const { changedBy, changedByActorType } = job.data.payload;
if (changedBy && changedByActorType) {
const resolvedName = await resolveChangedByDisplayName(changedBy, changedByActorType as ActorType);
- // eslint-disable-next-line no-param-reassign
- job.data.payload.changedBy = resolvedName;
+ webhookEvent = {
+ ...job.data,
+ payload: { ...job.data.payload, changedBy: resolvedName }
+ };
}
}
@@ -1592,7 +1611,7 @@ export const secretQueueFactory = ({
projectEnvDAL,
projectDAL,
webhookDAL,
- event: job.data,
+ event: webhookEvent,
auditLogService,
secretManagerDecryptor: (value) => secretManagerDecryptor({ cipherTextBlob: value }).toString()
});
diff --git a/backend/src/services/webhook/webhook-fns.ts b/backend/src/services/webhook/webhook-fns.ts
index 9e2503733c..c72861d7de 100644
--- a/backend/src/services/webhook/webhook-fns.ts
+++ b/backend/src/services/webhook/webhook-fns.ts
@@ -87,9 +87,14 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
short: false
},
{
- title: " Modified By",
+ title: "Modified By",
value: changedBy,
short: false
+ },
+ {
+ title: "Modified By Actor Type",
+ value: changedByActorType?.toString() || "Unknown Actor Type",
+ short: false
}
]
}
diff --git a/docs/documentation/platform/webhooks.mdx b/docs/documentation/platform/webhooks.mdx
index d142df586a..713ec05f57 100644
--- a/docs/documentation/platform/webhooks.mdx
+++ b/docs/documentation/platform/webhooks.mdx
@@ -32,7 +32,7 @@ If the signature in the header matches the signature that you generated, then yo
"workspaceId": "the workspace id",
"environment": "project environment",
"secretPath": "project folder path",
- "changeBy": "Actor that changed the secret",
+ "changedBy": "Actor that changed the secret",
"changedByActorType": "type of the actor that changed the secret"
},
"timestamp": ""