Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
allow machine identity and store as actor
Thiago Araujo da Silva9225c5ea2e38
diff --git a/backend/src/db/migrations/20260714120000_add-alerts.ts b/backend/src/db/migrations/20260714120000_add-alerts.tsindex 3fc10c43ae..d65f0018e6 100644--- a/backend/src/db/migrations/20260714120000_add-alerts.ts+++ b/backend/src/db/migrations/20260714120000_add-alerts.ts@@ -17,15 +17,14 @@ export async function up(knex: Knex): Promise<void> {t.boolean("enabled").notNullable().defaultTo(true);t.uuid("orgId").notNullable();t.string("projectId").nullable();- t.uuid("createdByUserId").nullable();+ t.uuid("createdByActorId").notNullable();+ t.string("createdByActorType").notNullable();t.timestamps(true, true, true);t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE");- t.foreign("createdByUserId").references("id").inTable(TableName.Users).onDelete("SET NULL");t.index("orgId");t.index("projectId");- t.index("createdByUserId");t.index(["resourceType", "triggerType", "enabled"]);});@@ -49,15 +48,14 @@ export async function up(knex: Knex): Promise<void> {t.boolean("enabled").notNullable().defaultTo(true);t.uuid("orgId").notNullable();t.string("projectId").nullable();- t.uuid("createdByUserId").nullable();+ t.uuid("createdByActorId").notNullable();+ t.string("createdByActorType").notNullable();t.timestamps(true, true, true);t.foreign("orgId").references("id").inTable(TableName.Organization).onDelete("CASCADE");t.foreign("projectId").references("id").inTable(TableName.Project).onDelete("CASCADE");- t.foreign("createdByUserId").references("id").inTable(TableName.Users).onDelete("SET NULL");t.index("orgId");t.index("projectId");- t.index("createdByUserId");});await createOnUpdateTrigger(knex, TableName.AlertChannel);diff --git a/backend/src/db/schemas/alert-channels.ts b/backend/src/db/schemas/alert-channels.tsindex a3303def53..3c43ad2058 100644--- a/backend/src/db/schemas/alert-channels.ts+++ b/backend/src/db/schemas/alert-channels.ts@@ -17,7 +17,8 @@ export const AlertChannelsSchema = z.object({enabled: z.boolean().default(true),orgId: z.string().uuid(),projectId: z.string().nullable().optional(),- createdByUserId: z.string().uuid().nullable().optional(),+ createdByActorId: z.string().uuid(),+ createdByActorType: z.string(),createdAt: z.date(),updatedAt: z.date()});diff --git a/backend/src/db/schemas/alerts.ts b/backend/src/db/schemas/alerts.tsindex 757160d79c..8a7867fb44 100644--- a/backend/src/db/schemas/alerts.ts+++ b/backend/src/db/schemas/alerts.ts@@ -19,7 +19,8 @@ export const AlertsSchema = z.object({enabled: z.boolean().default(true),orgId: z.string().uuid(),projectId: z.string().nullable().optional(),- createdByUserId: z.string().uuid().nullable().optional(),+ createdByActorId: z.string().uuid(),+ createdByActorType: z.string(),createdAt: z.date(),updatedAt: z.date()});diff --git a/backend/src/server/routes/v1/alert-router.ts b/backend/src/server/routes/v1/alert-router.tsindex 72200c3986..b1b2ee6542 100644--- a/backend/src/server/routes/v1/alert-router.ts+++ b/backend/src/server/routes/v1/alert-router.ts@@ -78,7 +78,7 @@ export const registerAlertRouter = async (server: FastifyZodProvider) => {}),response: { 200: z.object({ alert: AlertResponseSchema }) }},- onRequest: verifyAuth([AuthMode.JWT]),+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),handler: async (req) => {const alert = await server.services.alert.createAlert({...req.body,@@ -108,7 +108,7 @@ export const registerAlertRouter = async (server: FastifyZodProvider) => {}),response: { 200: z.object({ alerts: AlertResponseSchema.array() }) }},- onRequest: verifyAuth([AuthMode.JWT]),+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),handler: async (req) => {const alerts = await server.services.alert.listAlerts({...req.query,@@ -130,7 +130,7 @@ export const registerAlertRouter = async (server: FastifyZodProvider) => {params: z.object({ alertId: z.string().uuid() }),response: { 200: z.object({ alert: AlertResponseSchema }) }},- onRequest: verifyAuth([AuthMode.JWT]),+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),handler: async (req) => {const alert = await server.services.alert.getAlertById({alertId: req.params.alertId,@@ -159,7 +159,7 @@ export const registerAlertRouter = async (server: FastifyZodProvider) => {}),response: { 200: z.object({ alert: AlertResponseSchema }) }},- onRequest: verifyAuth([AuthMode.JWT]),+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),handler: async (req) => {const alert = await server.services.alert.updateAlert({alertId: req.params.alertId,@@ -182,7 +182,7 @@ export const registerAlertRouter = async (server: FastifyZodProvider) => {params: z.object({ alertId: z.string().uuid() }),response: { 200: z.object({ alert: z.object({ id: z.string().uuid() }) }) }},- onRequest: verifyAuth([AuthMode.JWT]),+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),handler: async (req) => {const alert = await server.services.alert.deleteAlert({alertId: req.params.alertId,diff --git a/backend/src/services/alert/alert-channel-service.test.ts b/backend/src/services/alert/alert-channel-service.test.tsindex 279b8ffc0a..bcf6b9c33b 100644--- a/backend/src/services/alert/alert-channel-service.test.ts+++ b/backend/src/services/alert/alert-channel-service.test.ts@@ -10,6 +10,7 @@ const decryptor = ({ cipherTextBlob }: { cipherTextBlob: Buffer }) => cipherTextconst cipher = { encryptor, decryptor } as never;const encConfig = (config: unknown) => Buffer.from(JSON.stringify(config));const tx = {} as Knex;+const CREATOR = { createdByActorId: "11111111-1111-1111-1111-111111111111", createdByActorType: "user" };type TRow = {id: string;@@ -19,7 +20,8 @@ type TRow = {enabled: boolean;orgId: string;projectId: string | null;- createdByUserId: string | null;+ createdByActorId: string;+ createdByActorType: string;createdAt: Date;updatedAt: Date;};@@ -38,7 +40,7 @@ const buildService = (opts?: { seed?: TRow[] }) => {id: `ch-${counter}`,enabled: true,projectId: null,- createdByUserId: null,+ ...CREATOR,createdAt: new Date(),updatedAt: new Date(),...data@@ -96,7 +98,7 @@ const seedRow = (enabled: true,orgId: "org-1",projectId: null,- createdByUserId: null,+ ...CREATOR,createdAt: new Date(),updatedAt: new Date(),...over@@ -110,7 +112,8 @@ describe("alert channel service", () => {name: "Ops webhook",channelType: AlertChannelType.WEBHOOK,config: { url: "https://example.com/hook", signingSecret: "s3cr3t" },- orgId: "org-1"+ orgId: "org-1",+ ...CREATOR},encryptor as never,tx@@ -127,7 +130,7 @@ describe("alert channel service", () => {const { service } = buildService();await expect(service.createChannelInTx(- { name: "Team email", channelType: AlertChannelType.EMAIL, config: {}, orgId: "org-1" },+ { name: "Team email", channelType: AlertChannelType.EMAIL, config: {}, orgId: "org-1", ...CREATOR },encryptor as never,tx)@@ -140,7 +143,8 @@ describe("alert channel service", () => {channelType: AlertChannelType.WEBHOOK,config: { url: "https://example.com/hook" },recipients: [{ principalType: AlertPrincipalType.USER, principalId: "user-1" }],- orgId: "org-1"+ orgId: "org-1",+ ...CREATOR},encryptor as never,tx@@ -156,7 +160,8 @@ describe("alert channel service", () => {channelType: AlertChannelType.EMAIL,config: {},recipients: [{ principalType: AlertPrincipalType.USER, principalId: "user-1" }],- orgId: "org-1"+ orgId: "org-1",+ ...CREATOR},encryptor as never,txdiff --git a/backend/src/services/alert/alert-channel-service.ts b/backend/src/services/alert/alert-channel-service.tsindex 2184293b28..72c3e8b8d6 100644--- a/backend/src/services/alert/alert-channel-service.ts+++ b/backend/src/services/alert/alert-channel-service.ts@@ -40,7 +40,8 @@ export type TCreateChannelInTxInput = {recipients?: TChannelRecipientInput[];orgId: string;projectId?: string | null;- createdByUserId?: string | null;+ createdByActorId: string;+ createdByActorType: string;};export type TUpdateChannelInTxInput = {@@ -206,7 +207,8 @@ export const alertChannelServiceFactory = ({enabled: input.enabled ?? true,orgId: input.orgId,projectId: input.projectId ?? null,- createdByUserId: input.createdByUserId ?? null+ createdByActorId: input.createdByActorId,+ createdByActorType: input.createdByActorType},tx);diff --git a/backend/src/services/alert/alert-engine.test.ts b/backend/src/services/alert/alert-engine.test.tsindex 08b7bea7d8..869c59045b 100644--- a/backend/src/services/alert/alert-engine.test.ts+++ b/backend/src/services/alert/alert-engine.test.ts@@ -34,7 +34,8 @@ const makeAlert = () => ({enabled: true,orgId: "org-1",projectId: null,- createdByUserId: null,+ createdByActorId: "11111111-1111-1111-1111-111111111111",+ createdByActorType: "user",createdAt: new Date(),updatedAt: new Date()});diff --git a/backend/src/services/alert/alert-service.ts b/backend/src/services/alert/alert-service.tsindex 9df4c336dd..1cd2511c1a 100644--- a/backend/src/services/alert/alert-service.ts+++ b/backend/src/services/alert/alert-service.ts@@ -163,7 +163,8 @@ export const alertServiceFactory = ({enabled: dto.enabled ?? true,orgId: dto.actorOrgId,projectId: dto.projectId,- createdByUserId: dto.actorId+ createdByActorId: dto.actorId,+ createdByActorType: dto.actor},tx);@@ -179,7 +180,8 @@ export const alertServiceFactory = ({recipients: channelInput.recipients,orgId: dto.actorOrgId,projectId: dto.projectId ?? null,- createdByUserId: dto.actorId+ createdByActorId: dto.actorId,+ createdByActorType: dto.actor},cipher.encryptor,tx@@ -303,7 +305,8 @@ export const alertServiceFactory = ({recipients: channelInput.recipients,orgId: alert.orgId,projectId: alert.projectId,- createdByUserId: alert.createdByUserId+ createdByActorId: alert.createdByActorId,+ createdByActorType: alert.createdByActorType},cipher.encryptor,tx