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
feat(secrets-17): Fix https connection for clickhouse connections
Tre Dubravad8969785db00
diff --git a/backend/src/ee/services/dynamic-secret/providers/clickhouse.ts b/backend/src/ee/services/dynamic-secret/providers/clickhouse.tsindex fc4f0d41cb..c8313ceb14 100644--- a/backend/src/ee/services/dynamic-secret/providers/clickhouse.ts+++ b/backend/src/ee/services/dynamic-secret/providers/clickhouse.ts@@ -109,18 +109,10 @@ export const ClickhouseProvider = ({const validateProviderInputs = async (inputs: unknown) => {const providerInputs = await DynamicSecretClickhouseSchema.parseAsync(inputs);- let { host } = providerInputs;- let hostProtocol: string | undefined;- if (host.startsWith("https://")) {- host = host.slice("https://".length);- hostProtocol = "https";- } else if (host.startsWith("http://")) {- host = host.slice("http://".length);- hostProtocol = "http";- }+ const sanitizedHost = providerInputs.host.replace(/^https?:\/\//, "");const [hostIp] = await verifyHostInputValidity({- host,+ host: sanitizedHost,isGateway: Boolean(providerInputs.gatewayId),isDynamicSecret: true});@@ -139,14 +131,15 @@ export const ClickhouseProvider = ({allowedExpressions: (val) => ["username", "database"].includes(val)});- return { ...providerInputs, host, hostIp, hostProtocol };+ return { ...providerInputs, hostIp };};- const $getClient = async (- providerInputs: z.infer<typeof DynamicSecretClickhouseSchema> & { hostIp: string; hostProtocol?: string }- ) => {- const protocol = providerInputs.hostProtocol ?? (providerInputs.ca ? "https" : "http");- const url = `${protocol}://${providerInputs.host}:${providerInputs.port}`;+ const $getClient = async (providerInputs: z.infer<typeof DynamicSecretClickhouseSchema> & { hostIp: string }) => {+ let url = `${providerInputs.host}:${providerInputs.port}`;++ if (!url.includes("://")) {+ url = `http${providerInputs.ca ? "s" : ""}://${url}`;+ }const client = createClient({url,diff --git a/docs/documentation/platform/dynamic-secrets/clickhouse.mdx b/docs/documentation/platform/dynamic-secrets/clickhouse.mdxindex 42ca6a6e62..d0899cc743 100644--- a/docs/documentation/platform/dynamic-secrets/clickhouse.mdx+++ b/docs/documentation/platform/dynamic-secrets/clickhouse.mdx@@ -11,6 +11,15 @@ The Infisical ClickHouse dynamic secret allows you to generate ClickHouse databaCreate a user with the required permissions in your ClickHouse instance. This user will be used to create new accounts on-demand.+```sql+CREATE USER 'infisical' IDENTIFIED WITH sha256_password BY '<strong-password>';+GRANT CREATE USER, DROP USER, GRANT OPTION ON *.* TO 'infisical';+```++<Note>+ The `GRANT OPTION` privilege is required so that the service user can grant permissions to the dynamically created users.+</Note>+## Set up Dynamic Secrets with ClickHouse<Steps>