Skip to content

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

remove endpoint to store audit log details

adilsone939ee710d8e
diff --git a/backend/src/ee/services/audit-log/audit-log-clickhouse-dal.ts b/backend/src/ee/services/audit-log/audit-log-clickhouse-dal.ts
index bb7e391813..a11141db50 100644
--- a/backend/src/ee/services/audit-log/audit-log-clickhouse-dal.ts
+++ b/backend/src/ee/services/audit-log/audit-log-clickhouse-dal.ts
@@ -208,38 +208,5 @@ export const clickhouseAuditLogDALFactory = (clickhouseClient: ClickHouseClient,
}
};
- const findById = async (
- id: string,
- orgId: string
- ): Promise<{ id: string; orgId: string; projectId: string | null } | null> => {
- const query = `
- SELECT id, orgId, projectId
- FROM ${tableName}
- WHERE id = {id:UUID} AND orgId = {orgId:UUID}
- LIMIT 1
- `;
-
- try {
- const result = await clickhouseClient.query({
- query,
- query_params: { id, orgId },
- format: "JSONEachRow"
- });
-
- const rows = await result.json<{ id: string; orgId: string; projectId: string }>();
- if (rows.length === 0) return null;
-
- const row = rows[0];
- return {
- id: row.id,
- orgId: row.orgId,
- projectId: row.projectId || null
- };
- } catch (error) {
- logger.error(error, "Failed to find audit log by id from ClickHouse");
- throw new DatabaseError({ error });
- }
- };
-
- return { find, findById };
+ return { find };
};
diff --git a/backend/src/ee/services/audit-log/audit-log-service.ts b/backend/src/ee/services/audit-log/audit-log-service.ts
index f3212cd9bf..9c30f1838a 100644
--- a/backend/src/ee/services/audit-log/audit-log-service.ts
+++ b/backend/src/ee/services/audit-log/audit-log-service.ts
@@ -4,10 +4,9 @@ import { requestContext } from "@fastify/request-context";
import { ActionProjectType, OrganizationActionScope, TUsers } from "@app/db/schemas";
import { KeyStorePrefixes, KeyStoreTtls, TKeyStoreFactory } from "@app/keystore/keystore";
import { getConfig } from "@app/lib/config/env";
-import { BadRequestError, NotFoundError } from "@app/lib/errors";
+import { BadRequestError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { RequestContextKey } from "@app/lib/request-context/request-context-keys";
-import { TGenericPermission } from "@app/lib/types";
import { ActorType } from "@app/services/auth/auth-type";
import { TNotificationServiceFactory } from "@app/services/notification/notification-service";
import { NotificationType } from "@app/services/notification/notification-types";
@@ -146,90 +145,6 @@ export const auditLogServiceFactory = ({
return auditLogQueue.pushToLog(el);
};
- const checkAuditLogReadPermission = async ({
- actor,
- actorId,
- actorAuthMethod,
- actorOrgId,
- projectId
- }: TGenericPermission & { projectId?: string }) => {
- if (projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actor,
- actorId,
- projectId,
- actorAuthMethod,
- actorOrgId,
- actionProjectType: ActionProjectType.Any
- });
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionAuditLogsActions.Read,
- ProjectPermissionSub.AuditLogs
- );
- return;
- }
-
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: actorOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionAuditLogsActions.Read, OrgPermissionSubjects.AuditLogs);
- };
-
- const recordViewAuditLogDetails: TAuditLogServiceFactory["recordViewAuditLogDetails"] = async ({
- actor,
- actorId,
- actorAuthMethod,
- actorOrgId,
- projectId,
- auditLogId,
- auditLogInfo
- }) => {
- await checkAuditLogReadPermission({ actor, actorId, actorAuthMethod, actorOrgId, projectId });
- await createAuditLog({
- ...auditLogInfo,
- orgId: actorOrgId,
- projectId,
- event: {
- type: EventType.VIEW_AUDIT_LOG_DETAILS,
- metadata: { auditLogId }
- }
- });
- };
-
- const trackAuditLogDetailsViewForOrg: TAuditLogServiceFactory["trackAuditLogDetailsViewForOrg"] = async ({
- actor,
- actorId,
- actorAuthMethod,
- actorOrgId,
- auditLogId,
- auditLogInfo
- }) => {
- const appCfg = getConfig();
- const useClickHouse = appCfg.CLICKHOUSE_AUDIT_LOG_ENABLED && clickhouseAuditLogDAL;
-
- const row = useClickHouse
- ? await clickhouseAuditLogDAL.findById(auditLogId, actorOrgId)
- : await auditLogDAL.findById(auditLogId);
-
- if (!row || row.orgId !== actorOrgId) {
- throw new NotFoundError({ message: "Audit log not found" });
- }
- await recordViewAuditLogDetails({
- actor,
- actorId,
- actorAuthMethod,
- actorOrgId,
- projectId: row.projectId ?? undefined,
- auditLogId,
- auditLogInfo
- });
- };
-
const getAuditLogPostgresStorageStatus: TAuditLogServiceFactory["getAuditLogPostgresStorageStatus"] = async ({
actorAuthMethod,
actorId,
@@ -346,8 +261,6 @@ export const auditLogServiceFactory = ({
return {
createAuditLog,
- recordViewAuditLogDetails,
- trackAuditLogDetailsViewForOrg,
listAuditLogs,
getAuditLogPostgresStorageStatus,
checkPostgresAuditLogVolumeMigrationAlert
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index d617cc1017..62f468a127 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -30,7 +30,7 @@ import { SshCertTemplateStatus } from "@app/ee/services/ssh-certificate-template
import { TLoginMapping } from "@app/ee/services/ssh-host/ssh-host-types";
import { SymmetricKeyAlgorithm } from "@app/lib/crypto/cipher";
import { AsymmetricKeyAlgorithm, SigningAlgorithm } from "@app/lib/crypto/sign/types";
-import { TGenericPermission, TOrgPermission, TProjectPermission } from "@app/lib/types";
+import { TOrgPermission, TProjectPermission } from "@app/lib/types";
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
import { TCreateAppConnectionDTO, TUpdateAppConnectionDTO } from "@app/services/app-connection/app-connection-types";
import { ActorType } from "@app/services/auth/auth-type";
@@ -98,21 +98,8 @@ export type TCreateAuditLogDTO = {
export type AuditLogInfo = Pick<TCreateAuditLogDTO, "userAgent" | "userAgentType" | "ipAddress" | "actor">;
-export type TRecordViewAuditLogDetailsDTO = TGenericPermission & {
- projectId?: string;
- auditLogId: string;
- auditLogInfo: AuditLogInfo;
-};
-
-export type TTrackAuditLogDetailsViewForOrgDTO = TGenericPermission & {
- auditLogId: string;
- auditLogInfo: AuditLogInfo;
-};
-
export type TAuditLogServiceFactory = {
createAuditLog: (data: TCreateAuditLogDTO) => Promise<void>;
- recordViewAuditLogDetails: (arg: TRecordViewAuditLogDetailsDTO) => Promise<void>;
- trackAuditLogDetailsViewForOrg: (arg: TTrackAuditLogDetailsViewForOrgDTO) => Promise<void>;
listAuditLogs: (arg: TListProjectAuditLogDTO) => Promise<
{
event: {
@@ -695,7 +682,6 @@ export enum EventType {
ACCESS_APPROVAL_REQUEST_REVOKE = "access-approval-request-revoke",
ACCESS_APPROVAL_REQUEST_UPDATE = "access-approval-request-update",
VIEW_AUDIT_LOGS = "view-audit-logs",
- VIEW_AUDIT_LOG_DETAILS = "view-audit-log-details",
// PKI ACME
CREATE_ACME_ACCOUNT = "create-acme-account",
@@ -4817,13 +4803,6 @@ interface ViewAuditLogsEvent {
metadata?: Record<string, unknown>;
}
-interface ViewAuditLogDetailsEvent {
- type: EventType.VIEW_AUDIT_LOG_DETAILS;
- metadata: {
- auditLogId: string;
- };
-}
-
interface ProjectRoleCreateEvent {
type: EventType.CREATE_PROJECT_ROLE;
metadata: {
@@ -6639,7 +6618,6 @@ export type Event =
| ViewInsightsAuthMethodsEvent
| ViewSecretManagementInsightsSummaryEvent
| ViewAuditLogsEvent
- | ViewAuditLogDetailsEvent
| ProjectRoleCreateEvent
| ProjectRoleUpdateEvent
| ProjectRoleDeleteEvent
diff --git a/backend/src/server/routes/v1/organization-router.ts b/backend/src/server/routes/v1/organization-router.ts
index e6db0803e7..fb52971613 100644
--- a/backend/src/server/routes/v1/organization-router.ts
+++ b/backend/src/server/routes/v1/organization-router.ts
@@ -303,41 +303,6 @@ export const registerOrgRouter = async (server: FastifyZodProvider) => {
}
});
- server.route({
- method: "POST",
- url: "/audit-logs/:auditLogId/track-log-details-view",
- config: {
- rateLimit: writeLimit
- },
- schema: {
- operationId: "trackOrganizationAuditLogView",
- tags: [ApiDocsTags.AuditLogs],
- description:
- "Record that the current actor expanded a specific audit log entry. Emits a VIEW_AUDIT_LOG_DETAILS audit event. The frontend dedupes per-log within a session so this should be called at most once per (actor, log) per session.",
- params: z.object({
- auditLogId: z.string().trim().uuid()
- }),
- response: {
- 200: z.object({
- tracked: z.boolean()
- })
- }
- },
- onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
- handler: async (req) => {
- await server.services.auditLog.trackAuditLogDetailsViewForOrg({
- actor: req.permission.type,
- actorId: req.permission.id,
- actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId,
- auditLogId: req.params.auditLogId,
- auditLogInfo: req.auditLogInfo
- });
-
- return { tracked: true };
- }
- });
-
server.route({
method: "GET",
url: "/:organizationId/users",
diff --git a/frontend/src/hooks/api/auditLogs/index.tsx b/frontend/src/hooks/api/auditLogs/index.tsx
index 65254d74d3..15eb64c94a 100644
--- a/frontend/src/hooks/api/auditLogs/index.tsx
+++ b/frontend/src/hooks/api/auditLogs/index.tsx
@@ -1,3 +1,2 @@
-export * from "./mutations";
export * from "./queries";
export * from "./useAuditLogActorSuggestions";
diff --git a/frontend/src/hooks/api/auditLogs/mutations.tsx b/frontend/src/hooks/api/auditLogs/mutations.tsx
deleted file mode 100644
index 887b4238b9..0000000000
--- a/frontend/src/hooks/api/auditLogs/mutations.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import { useMutation } from "@tanstack/react-query";
-
-import { apiRequest } from "@app/config/request";
-
-type TrackAuditLogViewInput = { auditLogId: string };
-
-export const useTrackAuditLogView = () =>
- useMutation({
- mutationFn: async ({ auditLogId }: TrackAuditLogViewInput) => {
- const { data } = await apiRequest.post<{ tracked: boolean }>(
- `/api/v1/organization/audit-logs/${auditLogId}/track-log-details-view`
- );
- return data;
- }
- });
diff --git a/frontend/src/pages/organization/AuditLogsPage/components/LogsTableRow.tsx b/frontend/src/pages/organization/AuditLogsPage/components/LogsTableRow.tsx
index 86faf32555..a42847cc96 100644
--- a/frontend/src/pages/organization/AuditLogsPage/components/LogsTableRow.tsx
+++ b/frontend/src/pages/organization/AuditLogsPage/components/LogsTableRow.tsx
@@ -1,4 +1,3 @@
-import { useEffect, useRef } from "react";
import { faCaretDown, faCaretRight } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { InfoIcon } from "lucide-react";
@@ -7,7 +6,6 @@ import { Td, Tooltip, Tr } from "@app/components/v2";
import { formatDateTime, Timezone } from "@app/helpers/datetime";
import { useToggle } from "@app/hooks";
import { ActorType } from "@app/hooks/api/auditLogs/enums";
-import { useTrackAuditLogView } from "@app/hooks/api/auditLogs/mutations";
import { AuditLog } from "@app/hooks/api/auditLogs/types";
type Props = {
@@ -42,15 +40,6 @@ const Tag = ({ label, value }: TagProps) => {
export const LogsTableRow = ({ auditLog, rowNumber, timezone }: Props) => {
const [isOpen, setIsOpen] = useToggle();
- const { mutate: trackView } = useTrackAuditLogView();
- const hasTrackedRef = useRef(false);
-
- useEffect(() => {
- if (isOpen && !hasTrackedRef.current) {
- hasTrackedRef.current = true;
- trackView({ auditLogId: auditLog.id });
- }
- }, [isOpen, auditLog.id, trackView]);
return (
<>