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
checkpoint
Daniel Hougaardc8a00e7e3fd6
diff --git a/backend/src/db/migrations/utils/env-config.ts b/backend/src/db/migrations/utils/env-config.tsindex de32f4db90..6da7044aa6 100644--- a/backend/src/db/migrations/utils/env-config.ts+++ b/backend/src/db/migrations/utils/env-config.ts@@ -1,6 +1,7 @@import { z } from "zod";import { crypto } from "@app/lib/crypto/cryptography";+import { removeTrailingSlash } from "@app/lib/fn";import { zpStr } from "@app/lib/zod";import { TSuperAdminDALFactory } from "@app/services/super-admin/super-admin-dal";@@ -22,13 +23,17 @@ const envSchema = zHSM_LIB_PATH: zpStr(z.string().optional()),HSM_PIN: zpStr(z.string().optional()),HSM_KEY_LABEL: zpStr(z.string().optional()),- HSM_SLOT: z.coerce.number().optional().default(0)+ HSM_SLOT: z.coerce.number().optional().default(0),++ LICENSE_SERVER_URL: zpStr(z.string().optional().default("https://portal.infisical.com")),+ LICENSE_SERVER_KEY: zpStr(z.string().optional()),+ LICENSE_KEY: zpStr(z.string().optional()),+ LICENSE_KEY_OFFLINE: zpStr(z.string().optional()),+ INTERNAL_REGION: zpStr(z.enum(["us", "eu"]).optional()),++ SITE_URL: zpStr(z.string().transform((val) => (val ? removeTrailingSlash(val) : val))).optional()})// To ensure that basic encryption is always possible.- .refine(- (data) => Boolean(data.ENCRYPTION_KEY) || Boolean(data.ROOT_ENCRYPTION_KEY),- "Either ENCRYPTION_KEY or ROOT_ENCRYPTION_KEY must be defined."- ).transform((data) => ({...data,isHsmConfigured:diff --git a/backend/src/db/migrations/utils/services.ts b/backend/src/db/migrations/utils/services.tsindex 1d61086fd2..26640e38e7 100644--- a/backend/src/db/migrations/utils/services.ts+++ b/backend/src/db/migrations/utils/services.ts@@ -61,7 +61,8 @@ export const getMigrationEncryptionServices = async ({ envConfig, db, keyStore }licenseDAL,keyStore,identityOrgMembershipDAL,- projectDAL+ projectDAL,+ envConfig});// ----- HSM startup -----diff --git a/backend/src/ee/services/license/license-service.ts b/backend/src/ee/services/license/license-service.tsindex c2e67908ff..3a5928713e 100644--- a/backend/src/ee/services/license/license-service.ts+++ b/backend/src/ee/services/license/license-service.ts@@ -10,7 +10,7 @@ import { CronJob } from "cron";import { Knex } from "knex";import { TKeyStoreFactory } from "@app/keystore/keystore";-import { getConfig } from "@app/lib/config/env";+import { TEnvConfig } from "@app/lib/config/env";import { verifyOfflineLicense } from "@app/lib/crypto";import { BadRequestError, NotFoundError } from "@app/lib/errors";import { logger } from "@app/lib/logger";@@ -45,6 +45,10 @@ import {} from "./license-types";type TLicenseServiceFactoryDep = {+ envConfig: Pick<+ TEnvConfig,+ "LICENSE_SERVER_URL" | "LICENSE_SERVER_KEY" | "LICENSE_KEY" | "LICENSE_KEY_OFFLINE" | "INTERNAL_REGION" | "SITE_URL"+ >;orgDAL: Pick<TOrgDALFactory, "findOrgById" | "countAllOrgMembers">;permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;licenseDAL: TLicenseDALFactory;@@ -67,26 +71,26 @@ export const licenseServiceFactory = ({licenseDAL,keyStore,identityOrgMembershipDAL,- projectDAL+ projectDAL,+ envConfig}: TLicenseServiceFactoryDep) => {let isValidLicense = false;let instanceType = InstanceType.OnPrem;let onPremFeatures: TFeatureSet = getDefaultOnPremFeatures();let selfHostedLicense: TOfflineLicense | null = null;- const appCfg = getConfig();const licenseServerCloudApi = setupLicenseRequestWithStore(- appCfg.LICENSE_SERVER_URL || "",+ envConfig.LICENSE_SERVER_URL || "",LICENSE_SERVER_CLOUD_LOGIN,- appCfg.LICENSE_SERVER_KEY || "",- appCfg.INTERNAL_REGION+ envConfig.LICENSE_SERVER_KEY || "",+ envConfig.INTERNAL_REGION);const licenseServerOnPremApi = setupLicenseRequestWithStore(- appCfg.LICENSE_SERVER_URL || "",+ envConfig.LICENSE_SERVER_URL || "",LICENSE_SERVER_ON_PREM_LOGIN,- appCfg.LICENSE_KEY || "",- appCfg.INTERNAL_REGION+ envConfig.LICENSE_KEY || "",+ envConfig.INTERNAL_REGION);const syncLicenseKeyOnPremFeatures = async (shouldThrow: boolean = false) => {@@ -120,7 +124,7 @@ export const licenseServiceFactory = ({const init = async () => {try {- if (appCfg.LICENSE_SERVER_KEY) {+ if (envConfig.LICENSE_SERVER_KEY) {const token = await licenseServerCloudApi.refreshLicense();if (token) instanceType = InstanceType.Cloud;logger.info(`Instance type: ${InstanceType.Cloud}`);@@ -128,7 +132,7 @@ export const licenseServiceFactory = ({return;}- if (appCfg.LICENSE_KEY) {+ if (envConfig.LICENSE_KEY) {const token = await licenseServerOnPremApi.refreshLicense();if (token) {await syncLicenseKeyOnPremFeatures(true);@@ -139,10 +143,10 @@ export const licenseServiceFactory = ({return;}- if (appCfg.LICENSE_KEY_OFFLINE) {+ if (envConfig.LICENSE_KEY_OFFLINE) {let isValidOfflineLicense = true;const contents: TOfflineLicenseContents = JSON.parse(- Buffer.from(appCfg.LICENSE_KEY_OFFLINE, "base64").toString("utf8")+ Buffer.from(envConfig.LICENSE_KEY_OFFLINE, "base64").toString("utf8"));const isVerified = await verifyOfflineLicense(JSON.stringify(contents.license), contents.signature);@@ -181,7 +185,7 @@ export const licenseServiceFactory = ({};const initializeBackgroundSync = async () => {- if (appCfg.LICENSE_KEY) {+ if (envConfig.LICENSE_KEY) {logger.info("Setting up background sync process for refresh onPremFeatures");const job = new CronJob("*/10 * * * *", syncLicenseKeyOnPremFeatures);job.start();@@ -397,8 +401,8 @@ export const licenseServiceFactory = ({} = await licenseServerCloudApi.request.post(`/api/license-server/v1/customers/${organization.customerId}/billing-details/payment-methods`,{- success_url: `${appCfg.SITE_URL}/organization/billing`,- cancel_url: `${appCfg.SITE_URL}/organization/billing`+ success_url: `${envConfig.SITE_URL}/organization/billing`,+ cancel_url: `${envConfig.SITE_URL}/organization/billing`});@@ -411,7 +415,7 @@ export const licenseServiceFactory = ({} = await licenseServerCloudApi.request.post(`/api/license-server/v1/customers/${organization.customerId}/billing-details/billing-portal`,{- return_url: `${appCfg.SITE_URL}/organization/billing`+ return_url: `${envConfig.SITE_URL}/organization/billing`});diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.tsindex 15f8783239..31e0eaeb4f 100644--- a/backend/src/lib/config/env.ts+++ b/backend/src/lib/config/env.ts@@ -363,11 +363,6 @@ const envSchema = z/* INTERNAL ----------------------------------------------------------------------------- */INTERNAL_REGION: zpStr(z.enum(["us", "eu"]).optional())})- // To ensure that basic encryption is always possible.- .refine(- (data) => Boolean(data.ENCRYPTION_KEY) || Boolean(data.ROOT_ENCRYPTION_KEY),- "Either ENCRYPTION_KEY or ROOT_ENCRYPTION_KEY must be defined."- ).refine((data) => Boolean(data.REDIS_URL) || Boolean(data.REDIS_SENTINEL_HOSTS) || Boolean(data.REDIS_CLUSTER_HOSTS),"Either REDIS_URL, REDIS_SENTINEL_HOSTS or REDIS_CLUSTER_HOSTS must be defined."diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex eb94afd4f1..bee447c361 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -559,7 +559,8 @@ export const registerRoutes = async (licenseDAL,keyStore,identityOrgMembershipDAL,- projectDAL+ projectDAL,+ envConfig});const tokenService = tokenServiceFactory({ tokenDAL: authTokenDAL, userDAL, membershipUserDAL });