mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 21:27:10 +00:00
feat: updated audit log to permission metadataw
This commit is contained in:
Vendored
+1
@@ -106,6 +106,7 @@ declare module "@fastify/request-context" {
|
|||||||
claims: Record<string, string>;
|
claims: Record<string, string>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
identityPermissionMetadata?: Record<string, unknown>; // filled by permission service
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { ForbiddenError } from "@casl/ability";
|
import { ForbiddenError } from "@casl/ability";
|
||||||
|
import { requestContext } from "@fastify/request-context";
|
||||||
|
|
||||||
import { ActionProjectType } from "@app/db/schemas";
|
import { ActionProjectType } from "@app/db/schemas";
|
||||||
import { getConfig } from "@app/lib/config/env";
|
import { getConfig } from "@app/lib/config/env";
|
||||||
import { BadRequestError } from "@app/lib/errors";
|
import { BadRequestError } from "@app/lib/errors";
|
||||||
|
import { ActorType } from "@app/services/auth/auth-type";
|
||||||
|
|
||||||
import { OrgPermissionActions, OrgPermissionSubjects } from "../permission/org-permission";
|
import { OrgPermissionActions, OrgPermissionSubjects } from "../permission/org-permission";
|
||||||
import { TPermissionServiceFactory } from "../permission/permission-service";
|
import { TPermissionServiceFactory } from "../permission/permission-service";
|
||||||
@@ -81,8 +83,12 @@ export const auditLogServiceFactory = ({
|
|||||||
if (!data.projectId && !data.orgId)
|
if (!data.projectId && !data.orgId)
|
||||||
throw new BadRequestError({ message: "Must specify either project id or org id" });
|
throw new BadRequestError({ message: "Must specify either project id or org id" });
|
||||||
}
|
}
|
||||||
|
const el = { ...data };
|
||||||
return auditLogQueue.pushToLog(data);
|
if (el.actor.type === ActorType.USER || el.actor.type === ActorType.IDENTITY) {
|
||||||
|
const permissionMetadata = requestContext.get("identityPermissionMetadata");
|
||||||
|
el.actor.metadata.permission = permissionMetadata;
|
||||||
|
}
|
||||||
|
return auditLogQueue.pushToLog(el);
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ interface UserActorMetadata {
|
|||||||
userId: string;
|
userId: string;
|
||||||
email?: string | null;
|
email?: string | null;
|
||||||
username: string;
|
username: string;
|
||||||
|
permission?: Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ServiceActorMetadata {
|
interface ServiceActorMetadata {
|
||||||
@@ -300,6 +301,7 @@ interface ServiceActorMetadata {
|
|||||||
interface IdentityActorMetadata {
|
interface IdentityActorMetadata {
|
||||||
identityId: string;
|
identityId: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
permission?: Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ScimClientActorMetadata {}
|
interface ScimClientActorMetadata {}
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ export const permissionServiceFactory = ({
|
|||||||
username: userProjectPermission.username,
|
username: userProjectPermission.username,
|
||||||
metadata: metadataKeyValuePair
|
metadata: metadataKeyValuePair
|
||||||
};
|
};
|
||||||
|
requestContext.set("identityPermissionMetadata", metadataKeyValuePair);
|
||||||
const interpolateRules = templatedRules(
|
const interpolateRules = templatedRules(
|
||||||
{
|
{
|
||||||
identity: templateValue
|
identity: templateValue
|
||||||
@@ -337,6 +338,8 @@ export const permissionServiceFactory = ({
|
|||||||
metadata: metadataKeyValuePair,
|
metadata: metadataKeyValuePair,
|
||||||
auth: identityAuthInfo
|
auth: identityAuthInfo
|
||||||
};
|
};
|
||||||
|
|
||||||
|
requestContext.set("identityPermissionMetadata", metadataKeyValuePair);
|
||||||
const interpolateRules = templatedRules(
|
const interpolateRules = templatedRules(
|
||||||
{
|
{
|
||||||
identity: templateValue
|
identity: templateValue
|
||||||
|
|||||||
Reference in New Issue
Block a user