mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 12:27:28 +00:00
feat: added audit log for assume
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
|
||||||
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 { writeLimit } from "@app/server/config/rateLimiter";
|
import { writeLimit } from "@app/server/config/rateLimiter";
|
||||||
@@ -37,6 +38,7 @@ export const registerAssumePrivilegeRouter = async (server: FastifyZodProvider)
|
|||||||
projectPermission: req.permission,
|
projectPermission: req.permission,
|
||||||
tokenVersionId: req.auth.tokenVersionId
|
tokenVersionId: req.auth.tokenVersionId
|
||||||
});
|
});
|
||||||
|
|
||||||
const appCfg = getConfig();
|
const appCfg = getConfig();
|
||||||
void res.setCookie("infisical-project-assume-privileges", payload.assumePrivilegesToken, {
|
void res.setCookie("infisical-project-assume-privileges", payload.assumePrivilegesToken, {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
@@ -44,6 +46,22 @@ export const registerAssumePrivilegeRouter = async (server: FastifyZodProvider)
|
|||||||
sameSite: "strict",
|
sameSite: "strict",
|
||||||
secure: appCfg.HTTPS_ENABLED
|
secure: appCfg.HTTPS_ENABLED
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await server.services.auditLog.createAuditLog({
|
||||||
|
...req.auditLogInfo,
|
||||||
|
orgId: req.permission.orgId,
|
||||||
|
event: {
|
||||||
|
type: EventType.PROJECT_ASSUME_PRIVILEGE,
|
||||||
|
metadata: {
|
||||||
|
projectId: req.params.projectId,
|
||||||
|
requesterEmail: req.auth.user.username,
|
||||||
|
requesterId: req.auth.user.id,
|
||||||
|
targetActorType: req.body.actorType,
|
||||||
|
targetActorId: req.body.actorId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return { message: "Successfully assumed role" };
|
return { message: "Successfully assumed role" };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,6 +95,19 @@ export const registerAssumePrivilegeRouter = async (server: FastifyZodProvider)
|
|||||||
sameSite: "strict",
|
sameSite: "strict",
|
||||||
secure: appCfg.HTTPS_ENABLED
|
secure: appCfg.HTTPS_ENABLED
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await server.services.auditLog.createAuditLog({
|
||||||
|
...req.auditLogInfo,
|
||||||
|
orgId: req.permission.orgId,
|
||||||
|
event: {
|
||||||
|
type: EventType.PROJECT_ASSUME_PRIVILEGE_EXIT,
|
||||||
|
metadata: {
|
||||||
|
projectId: req.params.projectId,
|
||||||
|
requesterEmail: req.auth.user.username,
|
||||||
|
requesterId: req.auth.user.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
return { message: "Successfully exited assumed role" };
|
return { message: "Successfully exited assumed role" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -317,7 +317,9 @@ export enum EventType {
|
|||||||
DELETE_SECRET_ROTATION = "delete-secret-rotation",
|
DELETE_SECRET_ROTATION = "delete-secret-rotation",
|
||||||
SECRET_ROTATION_ROTATE_SECRETS = "secret-rotation-rotate-secrets",
|
SECRET_ROTATION_ROTATE_SECRETS = "secret-rotation-rotate-secrets",
|
||||||
|
|
||||||
PROJECT_ACCESS_REQUEST = "project-access-request"
|
PROJECT_ACCESS_REQUEST = "project-access-request",
|
||||||
|
PROJECT_ASSUME_PRIVILEGE = "project-assume-privileges",
|
||||||
|
PROJECT_ASSUME_PRIVILEGE_EXIT = "project-assume-privileges-exit"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const filterableSecretEvents: EventType[] = [
|
export const filterableSecretEvents: EventType[] = [
|
||||||
@@ -2425,6 +2427,26 @@ interface ProjectAccessRequestEvent {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ProjectAssumePrivilegesEvent {
|
||||||
|
type: EventType.PROJECT_ASSUME_PRIVILEGE;
|
||||||
|
metadata: {
|
||||||
|
projectId: string;
|
||||||
|
requesterId: string;
|
||||||
|
requesterEmail: string;
|
||||||
|
targetActorType: ActorType;
|
||||||
|
targetActorId: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ProjectAssumePrivilegesExitEvent {
|
||||||
|
type: EventType.PROJECT_ASSUME_PRIVILEGE_EXIT;
|
||||||
|
metadata: {
|
||||||
|
projectId: string;
|
||||||
|
requesterId: string;
|
||||||
|
requesterEmail: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
interface SetupKmipEvent {
|
interface SetupKmipEvent {
|
||||||
type: EventType.SETUP_KMIP;
|
type: EventType.SETUP_KMIP;
|
||||||
metadata: {
|
metadata: {
|
||||||
@@ -2727,6 +2749,8 @@ export type Event =
|
|||||||
| KmipOperationLocateEvent
|
| KmipOperationLocateEvent
|
||||||
| KmipOperationRegisterEvent
|
| KmipOperationRegisterEvent
|
||||||
| ProjectAccessRequestEvent
|
| ProjectAccessRequestEvent
|
||||||
|
| ProjectAssumePrivilegesEvent
|
||||||
|
| ProjectAssumePrivilegesExitEvent
|
||||||
| CreateSecretRequestEvent
|
| CreateSecretRequestEvent
|
||||||
| SecretApprovalRequestReview
|
| SecretApprovalRequestReview
|
||||||
| GetSecretRotationsEvent
|
| GetSecretRotationsEvent
|
||||||
|
|||||||
Reference in New Issue
Block a user