Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Merge pull request #8332 from Infisical/bernie/pam-509-add-native-protocol-support-for-clickhouse-pam
Bernie Gcf12b26426e4
diff --cc backend/src/ee/services/pam-account/pam-account-service.tsindex c618fdd128,edeac3dc3b..00bf060585--- a/backend/src/ee/services/pam-account/pam-account-service.ts+++ b/backend/src/ee/services/pam-account/pam-account-service.ts@@@ -30,9 -29,10 +30,9 @@@ import { TMfaSessionServiceFactory } frimport { TOrgDALFactory } from "@app/services/org/org-dal";import { TUserDALFactory } from "@app/services/user/user-dal";- import { testConnectionWithGateway } from "../gateway-v2/gateway-v2-fns";+ import { testBuiltConnectionWithGateway } from "../gateway-v2/gateway-v2-fns";import {accountTypeSupportsSessionLogMasking,- PamAccessStatus,PamAccessType,PamAccountType,PamAccountWarning,diff --cc backend/src/ee/services/pam-web-access/pam-web-access-service.tsindex 67e9e38fc9,0e62af9e95..db9ec4f0e9--- a/backend/src/ee/services/pam-web-access/pam-web-access-service.ts+++ b/backend/src/ee/services/pam-web-access/pam-web-access-service.ts@@@ -39,9 -38,9 +39,10 @@@ importextractGatewayTarget,getAccountAccessibilityIssues,PamAccountAccessibilityIssue,- resolveSelectedHost+ resolveSelectedHost,+ webAccessUnavailableReason} from "../pam-account/pam-account-schemas";+import { assertUserStillActiveInOrg } from "../pam-session/pam-session-access-fns";import { TPamSessionDALFactory } from "../pam-session/pam-session-dal";import { reportPamSessionEnded } from "../pam-session/pam-session-fns";import { SESSION_HANDLERS } from "./pam-session-handlers";diff --cc backend/src/ee/services/pam/CLAUDE.mdindex b4224b2844,287be02f7f..c78323537d--- a/backend/src/ee/services/pam/CLAUDE.md+++ b/backend/src/ee/services/pam/CLAUDE.md@@@ -138,30 -138,18 +138,36 @@@ live in a process-wide map keyed by thtest compares the login's `sessionInfo` against what was asked for, because Snowflake accepts a warehouseor 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.+ **ClickHouse is brokered over both its interfaces, HTTP (8123/8443) and the native TCP protocol+ (9000/9440)**, and an account may carry either port or both. One local port serves both: the gateway+ routes a connection by its first byte (CLI `packages/pam/handlers/clickhouse/`). Over HTTP the statement+ is read as text, and only the first megabyte of a request body is inspected, so an account carrying a+ command-blocking policy refuses a longer body rather than forward the remainder unread. Over native the+ statement arrives in its own Query packet; a packet the gateway cannot parse ends the session rather than+ being relayed uninspected. Two consequences worth knowing: **Web Access needs the HTTP port**, because the+ browser client speaks HTTP and nothing translates for it (`webAccessUnavailableReason`), and a native port+ may only be saved against a gateway advertising the `clickhouseNativeProtocol` capability. 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),