Skip to content

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

Merge branch 'main' into PAM-189

x0322052b8601d5276d
diff --cc backend/src/@types/fastify.d.ts
index fa270535b1,8ffcc2378f..4eaea07507
--- a/backend/src/@types/fastify.d.ts
+++ b/backend/src/@types/fastify.d.ts
@@@ -36,10 -36,9 +36,11 @@@ import { TPamAccountPolicyServiceFactor
import { TPamDiscoverySourceServiceFactory } from "@app/ee/services/pam-discovery/pam-discovery-source-service";
import { TPamDomainServiceFactory } from "@app/ee/services/pam-domain/pam-domain-service";
import { TPamFolderServiceFactory } from "@app/ee/services/pam-folder/pam-folder-service";
+import { TPamProjectRecordingConfigServiceFactory } from "@app/ee/services/pam-project-recording-config/pam-project-recording-config-service";
+ import { TPamInsightsServiceFactory } from "@app/ee/services/pam-insights/pam-insights-service";
import { TPamResourceRotationRulesServiceFactory } from "@app/ee/services/pam-resource/pam-resource-rotation-rules-service";
import { TPamResourceServiceFactory } from "@app/ee/services/pam-resource/pam-resource-service";
+import { TPamSessionChunkServiceFactory } from "@app/ee/services/pam-session/pam-session-chunk-service";
import { TPamSessionServiceFactory } from "@app/ee/services/pam-session/pam-session-service";
import { TPamWebAccessServiceFactory } from "@app/ee/services/pam-web-access/pam-web-access-service";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
diff --cc backend/src/ee/routes/v1/index.ts
index 279d857ea8,daa1ab69e5..3a60321de4
--- a/backend/src/ee/routes/v1/index.ts
+++ b/backend/src/ee/routes/v1/index.ts
@@@ -41,7 -41,7 +41,8 @@@ import
registerPamDomainRouter
} from "./pam-domain-routers";
import { registerPamFolderRouter } from "./pam-folder-router";
+import { registerPamRecordingConfigRouter } from "./pam-recording-config-router";
+ import { registerPamInsightsRouter } from "./pam-insights-router";
import { PAM_RESOURCE_REGISTER_ROUTER_MAP } from "./pam-resource-routers";
import { registerPamResourceRotationRulesRouter } from "./pam-resource-routers/pam-resource-rotation-rules-router";
import { registerPamResourceRouter } from "./pam-resource-routers/pam-resource-router";
diff --cc backend/src/ee/services/pam-session/pam-session-dal.ts
index 7a82c85ec0,7c376e4c64..77c88a693d
--- a/backend/src/ee/services/pam-session/pam-session-dal.ts
+++ b/backend/src/ee/services/pam-session/pam-session-dal.ts
@@@ -92,35 -82,80 +92,91 @@@ export const pamSessionDALFactory = (db
return updated;
};
- const countActiveByProject = async (projectId: string, tx?: Knex): Promise<number> => {
- const result = await (tx || db.replicaNode())(TableName.PamSession)
- .where("projectId", projectId)
- .whereIn("status", [PamSessionStatus.Starting, PamSessionStatus.Active])
- .count("id as count")
- .first();
-
- return Number((result as { count?: string | number })?.count ?? 0);
+ const startSession = async (
+ sessionId: string,
+ patch: {
+ encryptedSessionKey: Buffer;
+ gatewayUploadTokenHash: Buffer;
+ },
+ tx?: Knex
+ ) => {
+ const [updated] = await (tx || db)(TableName.PamSession)
+ .where("id", sessionId)
+ .where("status", PamSessionStatus.Starting)
+ .update({
+ status: PamSessionStatus.Active,
+ startedAt: new Date(),
+ ...patch
+ })
+ .returning("*");
+ return updated;
};
- const countDailyByProject = async (
++ const countDailyByProjectId = async (
+ projectId: string,
+ startDate: Date,
+ tx?: Knex
+ ): Promise<{ date: string; count: number }[]> => {
+ const rows = (await (tx || db.replicaNode())(TableName.PamSession)
+ .select(db.raw(`to_char(("createdAt" AT TIME ZONE 'UTC')::date, 'YYYY-MM-DD') as date`))
+ .count("id as count")
+ .where("projectId", projectId)
+ .where("createdAt", ">=", startDate)
+ .groupByRaw(`("createdAt" AT TIME ZONE 'UTC')::date`)
+ .orderByRaw(`("createdAt" AT TIME ZONE 'UTC')::date asc`)) as unknown as {
+ date: string;
+ count: string | number;
+ }[];
+
+ return rows.map((row) => ({ date: String(row.date), count: Number(row.count) }));
+ };
+
- const findTopActorsByProject = async (
++ const findTopActorsByProjectId = async (
+ projectId: string,
+ startDate: Date,
+ limit: number,
+ tx?: Knex
+ ): Promise<
+ {
+ actorName: string;
+ actorEmail: string;
+ userId: string | null;
+ sessionCount: number;
+ }[]
+ > => {
+ const rows = (await (tx || db.replicaNode())(TableName.PamSession)
+ .select("actorName", "actorEmail", "userId")
+ .count("id as count")
+ .where("projectId", projectId)
+ .where("createdAt", ">=", startDate)
+ .groupBy("actorName", "actorEmail", "userId")
+ .orderBy("count", "desc")
+ .limit(limit)) as unknown as {
+ actorName: string;
+ actorEmail: string;
+ userId: string | null;
+ count: string | number;
+ }[];
+
+ return rows.map((row) => ({
+ actorName: row.actorName,
+ actorEmail: row.actorEmail,
+ userId: row.userId,
+ sessionCount: Number(row.count)
+ }));
+ };
+
return {
...orm,
findById,
findByProjectId,
expireSessionById,
countActiveWebSessions,
- countActiveByProject,
- countDailyByProject,
- findTopActorsByProject,
+ countActiveByProjectId,
++ countDailyByProjectId,
++ findTopActorsByProjectId,
endSessionById,
- terminateSessionById
+ terminateSessionById,
+ startSession
};
};
diff --cc backend/src/server/routes/index.ts
index 2a2fa5a863,e47f083a5a..a90bd19f26
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@@ -106,8 -106,7 +106,9 @@@ import { pamDomainDALFactory } from "@a
import { pamDomainServiceFactory } from "@app/ee/services/pam-domain/pam-domain-service";
import { pamFolderDALFactory } from "@app/ee/services/pam-folder/pam-folder-dal";
import { pamFolderServiceFactory } from "@app/ee/services/pam-folder/pam-folder-service";
+import { pamProjectRecordingConfigDALFactory } from "@app/ee/services/pam-project-recording-config/pam-project-recording-config-dal";
+import { pamProjectRecordingConfigServiceFactory } from "@app/ee/services/pam-project-recording-config/pam-project-recording-config-service";
+ import { pamInsightsServiceFactory } from "@app/ee/services/pam-insights/pam-insights-service";
import { pamResourceDALFactory } from "@app/ee/services/pam-resource/pam-resource-dal";
import { pamResourceFavoriteDALFactory } from "@app/ee/services/pam-resource/pam-resource-favorite-dal";
import { pamResourceRotationRulesDALFactory } from "@app/ee/services/pam-resource/pam-resource-rotation-rules-dal";
diff --cc frontend/src/layouts/OrganizationLayout/components/OrgSidebar/PamNav.tsx
index e6031de665,d84a236f75..24b9b08c33
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/PamNav.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/PamNav.tsx
@@@ -39,13 -36,9 +40,14 @@@ export const PamNav = ({ onSubmenuOpen
activeMatch: /\/groups\/|\/identities\/|\/members\/|\/roles\//,
submenu: PROJECT_ACCESS_CONTROL_SUBMENU
},
+ { label: "Insights", icon: ActivityIcon, pathSuffix: "insights" },
{ label: "Audit Logs", icon: FileText, pathSuffix: "audit-logs" },
- { label: "Settings", icon: Settings, pathSuffix: "settings" }
+ {
+ label: "Settings",
+ icon: Settings,
+ pathSuffix: "settings",
+ submenu: PAM_SETTINGS_SUBMENU
+ }
];
return <ProjectNavList items={items} onSubmenuOpen={onSubmenuOpen} />;
};