Skip to content

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

Merge remote-tracking branch 'origin/main' into PAM-485

Andrey2f1912b61d6b
diff --cc backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
index 8b6c034d38,c803c32eaf..3465e2144c
--- a/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
+++ b/backend/src/ee/routes/v1/pam-routers/pam-account-router.ts
@@@ -2,7 -2,7 +2,7 @@@ import z from "zod"
import { PamAccountsSchema } from "@app/db/schemas";
import { EventType } from "@app/ee/services/audit-log/audit-log-types";
- import { PamAccountType, PamHeartbeatStatus } from "@app/ee/services/pam/pam-enums";
-import { PamAccessStatus, PamAccountType, PamAccountWarning, PamHeartbeatStatus } from "@app/ee/services/pam/pam-enums";
++import { PamAccountType, PamAccountWarning, PamHeartbeatStatus } from "@app/ee/services/pam/pam-enums";
import {
ACCOUNT_TYPE_CONFIGS,
buildPamAccountTypeMetadata,
diff --cc backend/src/ee/services/pam-account/pam-account-service.ts
index 34e94778a6,b5a6af9b90..c618fdd128
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@@ -30,7 -30,16 +31,15 @@@ import { TOrgDALFactory } from "@app/se
import { TUserDALFactory } from "@app/services/user/user-dal";
import { testConnectionWithGateway } from "../gateway-v2/gateway-v2-fns";
- import { PamAccessType, PamAccountType, PamHeartbeatStatus, PamProductRole, PamSessionStatus } from "../pam/pam-enums";
+ import {
+ accountTypeSupportsSessionLogMasking,
- PamAccessStatus,
+ PamAccessType,
+ PamAccountType,
+ PamAccountWarning,
+ PamHeartbeatStatus,
+ PamProductRole,
+ PamSessionStatus
+ } from "../pam/pam-enums";
import { enforceMfa } from "../pam/pam-mfa";
import {
accountAccessAllows,
diff --cc backend/src/ee/services/pam-session/pam-session-service.ts
index a476d5f1dd,2d5e3cb2d0..f174ddc9dd
--- a/backend/src/ee/services/pam-session/pam-session-service.ts
+++ b/backend/src/ee/services/pam-session/pam-session-service.ts
@@@ -20,7 -19,9 +20,8 @@@ import { TTelemetryServiceFactory } fro
import { TUserDALFactory } from "@app/services/user/user-dal";
import {
+ accountTypeSupportsSessionLogMasking,
PamAccessMethod,
- PamAccessStatus,
PamAccountType,
PamPostgresAuthMethod,
PamProductRole,
diff --cc backend/src/ee/services/pam/CLAUDE.md
index d08845818a,c43cc64410..0e20a2029d
--- a/backend/src/ee/services/pam/CLAUDE.md
+++ b/backend/src/ee/services/pam/CLAUDE.md
@@@ -138,24 -138,12 +138,30 @@@ live in a process-wide map keyed by th
test compares the login's `sessionInfo` against what was asked for, because Snowflake accepts a warehouse
or role the credential can't use and silently leaves it unset.
+ **ClickHouse is brokered over its HTTP interface (8123/8443), never the native protocol on 9000**, so the
+ gateway can read the statement as text to block and record it (CLI `packages/pam/handlers/clickhouse/`).
+ Only the first megabyte of a request body is inspected, so an account carrying a command-blocking policy
+ refuses a body longer than that rather than forward the remainder unread. Databases stand in for schemas, and the explorer grid is read-only for every table
+ (`supportsRowEditing`): `is_in_primary_key` is a sorting key, not a unique constraint.
+
+## Approvals
+
+**PAM approvals run on the shared approval system** (`backend/src/services/approval-policy/`), which
+owns the whole lifecycle. PAM's contribution is one `TApprovalResource`
+(`pam-access-request/pam-access-approval-resource.ts`), with its schemas under `approval-policy/pam-access/`.
+
+`pam-access-request-service.ts` is the product-facing entry point, not a second implementation: it
+resolves the account a CLI path names, delegates to `approvalPolicyService`, sends PAM's notifications,
+and owns the access read models (`checkGrant`, `getAccessStatusBatch`, …). **A new PAM approval rule
+belongs in the resource, never in that service**, or the CLI, the dashboard and the shared API stop
+agreeing about what is allowed.
+
+PAM is registered on the generic `/v1/approval-policies/pam-access/...` endpoints, which the dashboard
+uses for approve, reject and grant revocation; the resource's `buildAuditEvent` is what keeps those
+routes emitting PAM's own audit events, so folder and account auditors still see them. `/v1/pam/access-requests`
+keeps only what the generic API cannot express: the CLI's `folderName/accountName` create, the paginated
+folder list, the approver queue and count, the approver roster, and the folder notification configs.
+
## Policies & Settings
**Policies** are governance controls on a template (MFA, reason, session duration, command-blocking),
diff --cc backend/src/server/routes/index.ts
index f7b03a5d76,38d0799349..26c1aa7f06
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@@ -3562,123 -3740,10 +3607,122 @@@ export const registerRoutes = async
userGroupMembershipDAL,
notificationService,
approvalRequestGrantsDAL,
- certificateApprovalService,
- certificateRequestDAL,
smtpService,
userDAL,
+ groupDAL,
+ slackIntegrationDAL,
+ kmsService,
+ resources: approvalResources
+ });
+
+ const pkiApplicationEnrollmentService = pkiApplicationEnrollmentServiceFactory({
+ pkiApplicationDAL,
+ pkiApplicationProfileDAL,
+ apiEnrollmentConfigDAL,
+ estEnrollmentConfigDAL,
+ acmeEnrollmentConfigDAL,
+ scepEnrollmentConfigDAL,
+ appConnectionService,
+ licenseService,
+ approvalPolicyService,
+ certificateProfileDAL,
+ certificateAuthorityDAL,
+ certificateAuthoritySecretDAL,
+ certificateAuthorityCertDAL,
+ hsmConnectorService,
+ kmsService,
+ projectDAL,
+ permissionService
+ });
+
+ const pamAccessRequestService = pamAccessRequestServiceFactory({
+ approvalPolicyDAL,
+ approvalRequestDAL,
+ pamAccountDAL,
+ pamFolderDAL,
+ permissionService,
+ userDAL,
+ identityDAL,
+ pamFolderNotificationConfigDAL,
+ workflowIntegrationDAL,
+ licenseService,
+ approvalPolicyService,
+ pamAccessApprovalResource
+ });
+
+ const pamFolderService = pamFolderServiceFactory({
+ pamFolderDAL,
+ membershipDAL,
+ membershipRoleDAL,
+ permissionService,
+ pamAccessRequestService
+ });
+
+ const pamDiscoverySourceDAL = pamDiscoverySourceDALFactory(db);
+
+ const pamAccountService = pamAccountServiceFactory({
+ pamAccountDAL,
+ pamFolderDAL,
++ gatewayPoolMembershipDAL,
+ pamAccountTemplateDAL,
+ membershipDAL,
+ membershipRoleDAL,
+ pamSessionDAL,
+ pamDiscoverySourceDAL,
+ userDAL,
+ orgDAL,
+ mfaSessionService,
+ permissionService,
+ kmsService,
+ gatewayV2DAL,
+ gatewayV2Service,
+ gatewayPoolService,
+ appConnectionDAL,
+ pamAccessRequestService,
+ licenseService
+ });
+
+ const pamDiscoverySourceRunDAL = pamDiscoverySourceRunDALFactory(db);
+ const pamDiscoveredAccountDAL = pamDiscoveredAccountDALFactory(db);
+ const pamAccountDependencyDAL = pamAccountDependencyDALFactory(db);
+
+ const pamDiscoveryService = pamDiscoverySourceServiceFactory({
+ pamDiscoverySourceDAL,
+ pamDiscoverySourceRunDAL,
+ pamDiscoveredAccountDAL,
+ pamAccountDependencyDAL,
+ pamAccountDAL,
+ pamAccountService,
+ permissionService,
+ kmsService,
+ gatewayV2DAL,
+ gatewayV2Service,
+ gatewayPoolService,
+ queueService,
+ cronJob,
+ auditLogService
+ });
+
+ const pamAccountRotationService = pamAccountRotationServiceFactory({
+ pamAccountDAL,
+ permissionService,
+ membershipDAL,
+ membershipRoleDAL,
+ kmsService,
+ keyStore,
- gatewayService,
+ gatewayV2Service,
+ gatewayPoolService,
+ pamAccountDependencyDAL,
+ pamDiscoverySourceDAL,
+ projectDAL
+ });
+
+ const pamAccountHeartbeatService = pamAccountHeartbeatServiceFactory({
+ pamAccountDAL,
- gatewayService,
+ gatewayV2Service,
+ gatewayPoolService,
+ kmsService,
+ permissionService,
projectDAL
});