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
docs(pam-clickhouse): cut what the gateway does down to what a user needs
bernie-ga13e739ce603
diff --git a/docs/documentation/platform/pam/accounts/clickhouse.mdx b/docs/documentation/platform/pam/accounts/clickhouse.mdxindex 5e61d5637e..0ce87f5139 100644--- a/docs/documentation/platform/pam/accounts/clickhouse.mdx+++ b/docs/documentation/platform/pam/accounts/clickhouse.mdx@@ -6,16 +6,16 @@ description: "Add and connect to ClickHouse databases."ClickHouse accounts let you manage access to a ClickHouse database. Users connect through Web Access or the CLI, and every statement they run is recorded in the [session](/documentation/platform/pam/sessions/overview).-Sessions reach ClickHouse over both of its interfaces: the HTTP interface on port 8123 or 8443, and the native protocol on port 9000 or 9440. A session hands out one local port and detects which one a client is speaking, so you don't have to pick a protocol or run two sessions. Every request passes through the [gateway](/documentation/platform/gateways/overview) in your own network, and the credential never reaches the client.+Sessions can use either of ClickHouse's interfaces: HTTP on port 8123 (8443 with TLS) and the native protocol on port 9000 (9440 with TLS). Each session gets one local port that works with both, and the credential never reaches the client.-Either interface can be turned off on the server. Set whichever ports it serves and leave the other empty. An account needs at least one of them.+Set the ports your server serves and leave the other empty. An account needs at least one.## Prerequisites- A ClickHouse user for Infisical to connect as.-- At least one of the two interfaces enabled on the target. Both are on by default in a stock ClickHouse configuration: `http_port` is 8123 and `tcp_port` is 9000. The TLS ports are `https_port` 8443 and `tcp_port_secure` 9440, and ClickHouse Cloud exposes both.-- Both interfaces share the same `<openSSL><server>` certificate, so one SSL setting covers them. A server with TLS on one interface and not the other isn't supported.-- A [gateway](/documentation/platform/gateways/overview) that can reach those ports. Saving the account fails if the gateway predates ClickHouse support, and setting a **Native Port** fails if it predates native-protocol support. Update the gateway, or leave the native port empty to use HTTP only.+- At least one interface enabled on the server. Both are on by default, and ClickHouse Cloud serves both.+- TLS on both interfaces or neither, since **SSL Enabled** applies to both.+- A [gateway](/documentation/platform/gateways/overview) that can reach those ports. A **Native Port** needs a gateway recent enough to support the native protocol.## Creating an account@@ -45,13 +45,13 @@ Either interface can be turned off on the server. Set whichever ports it serves| **Password** | The user's password. Leave blank for a user created with `no_password` |</Step><Step title="Save">- Select **Create**. Infisical signs in to ClickHouse through the gateway and confirms the credential works before saving the account. Each port you set is checked, and the error names the one that failed. An edit that leaves the password blank can't sign in. With a native port set, each port is checked for the right ClickHouse interface without a credential. With only an HTTP port, the check is that the port accepts a connection.+ Select **Create**. Infisical checks the connection through the gateway before saving, and an error names the port that failed.</Step></Steps>## Permissions-What a session can do comes from the ClickHouse grants on the account's user, so grant that user only what the people using the account need. Web Access reads the database, table and column lists from `system.databases`, `system.tables` and `system.columns`, which every user can read for the objects they already have access to.+What a session can do comes from the ClickHouse grants on the account's user, so grant that user only what the people using the account need.```sqlCREATE USER pam_service IDENTIFIED WITH sha256_password BY '<password>';@@ -60,7 +60,7 @@ GRANT SELECT ON analytics.* TO pam_service;Every session opens on the account's **Database**, whatever a client asks for. That is a starting point, not a limit: a session can still read any database the user has a grant on, and Web Access lists them all. Scope the grants, not the **Database** field.-Sessions connect with the user's default roles. Over HTTP the gateway drops the `role` URL parameter, which would otherwise activate a role with no statement to record, so use `SET ROLE` instead and it's recorded like any other statement.+Sessions connect with the user's default roles. To use another role, run `SET ROLE` in the session.Command blocking matches the text of each statement, so a statement that builds SQL at runtime can run something a pattern would otherwise reject. Use ClickHouse grants for restrictions that have to hold.@@ -85,20 +85,20 @@ Command blocking matches the text of each statement, so a statement that builds</Tab><Tab title="CLI">- The CLI starts a local proxy on `127.0.0.1` that serves both of ClickHouse's interfaces on one port. Connect with TLS off and no certificate to trust, since the hop to the gateway is already an encrypted tunnel. The username and password a client sends are ignored, because the gateway authenticates for you.+ The CLI starts a local proxy on `127.0.0.1` that serves both interfaces on one port. Connect with TLS off. The username and password a client sends are ignored, since the gateway signs in for you.```bashinfisical pam access analytics/clickhouse-prod```- The command prints the port and a ready-made connection string. Point any client at that port and the protocol is detected from the first bytes it sends. Native drivers such as `clickhouse-client`, Python's `clickhouse-driver` and `clickhouse-go` work alongside HTTP clients such as JDBC (DBeaver, DataGrip), `clickhouse-connect`, `@clickhouse/client` and `curl`.+ The command prints the port and a connection string. Native clients such as `clickhouse-client`, `clickhouse-driver` and `clickhouse-go`, and HTTP clients such as JDBC tools, `clickhouse-connect` and `curl`, all work on that port.```bashclickhouse-client --host 127.0.0.1 --port <port>curl 'http://127.0.0.1:<port>/?query=SELECT+1'```- A native client needs the account to have a **Native Port** set. Without one, it is turned away with a message saying so.+ Native clients need the account to have a **Native Port**.**Flags:**- `--port <port>`: use a specific local port (otherwise one is assigned automatically)@@ -119,21 +119,15 @@ Every statement a session runs is recorded, along with the outcome of each one,The template's **Command Blocking** policy applies to ClickHouse as well: a statement matching one of its patterns is rejected before it reaches ClickHouse, and the rejection is recorded. **Session Log Masking** patterns are applied to the recording before it's written.-On the HTTP interface, applying that policy means reading the statement first, so on an account that blocks commands a request body over one megabyte is refused, and one compressed with anything other than `gzip` or `deflate` is rejected outright. Send large inserts in smaller batches, or use an account without the policy, where the body streams through and only its first megabyte is recorded.--The native protocol has no such limit. A statement arrives in its own packet, separate from any rows that follow, so it's always read in full and an insert's data never counts against the policy or fills the recording.+On an account with command blocking, an HTTP request body over 1 MB is refused, as is one compressed with anything other than `gzip` or `deflate`. Send large inserts in smaller batches.<Note>- Over the native protocol, an `INSERT` that pushes rows from the client is read so that later statements on the same connection stay covered by the policy. A few column types can't be read yet, including `Tuple`, `JSON`, `Nested`, `Point`, `LowCardinality(Nullable(...))`, a `Map` other than `Map(String, String)`, an array of arrays such as `Array(Array(Int16))`, and a `FixedString` whose length isn't 8, 16, 32, 64, 128, 256 or 512. Inserting into a table that has one of those columns is refused with a message naming the type. Inserting over the HTTP interface is unaffected. Reading those columns works too, but the session can't read the results either, so from then on every statement on that connection is recorded as sent, without an outcome. A single block is also capped at 64 MB, so a client sending larger batches is asked to split them.+ Over the native protocol, inserting into a table with one of these column types is refused: `Tuple`, `JSON`, `Nested`, `Point`, `LowCardinality(Nullable(...))`, a `Map` other than `Map(String, String)`, nested arrays, and a `FixedString` whose length isn't 8, 16, 32, 64, 128, 256 or 512. Use the HTTP interface for those tables. Reading those columns works, but later statements on that connection are recorded without their outcome. Batches over 64 MB are refused too.</Note>## Servers with HTTP turned off-A server that serves only the native protocol works with native clients. Set the **Native Port** and leave **HTTP Port** empty.--`clickhouse-client`, Python's `clickhouse-driver` and `clickhouse-go` speak to the session's port directly and need nothing special.--Nothing translates HTTP into the native protocol, so every HTTP client needs the server to have an HTTP port. That includes Web Access, JDBC tools such as DBeaver and DataGrip, `clickhouse-connect` and ODBC. Web Access is greyed out on such an account, and the other clients fail when they connect. Give the account an HTTP port if you need any of them.+Set the **Native Port** and leave **HTTP Port** empty. Native clients work as usual. Web Access and HTTP clients such as JDBC tools, `clickhouse-connect` and ODBC need an HTTP port, so Web Access is greyed out on such an account.## Next steps