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
refactor(billing): drop issuer/audience env vars for fixed constants
Tre Dubravab149b5282697
diff --git a/backend/src/lib/config/env.ts b/backend/src/lib/config/env.tsindex a23c2e3845..f66ad05043 100644--- a/backend/src/lib/config/env.ts+++ b/backend/src/lib/config/env.ts@@ -321,8 +321,6 @@ const envSchema = zLICENSE_SERVER_V2_ENABLED: zodStrBool.default("false"),LICENSE_SERVER_V2_URL: zpStr(z.string().optional()),LICENSE_SERVER_V2_SERVICE_KEY: zpStr(z.string().optional()),- LICENSE_SERVER_V2_ISSUER: zpStr(z.string().optional()),- LICENSE_SERVER_V2_AUDIENCE: zpStr(z.string().optional()),// GENERICSTANDALONE_MODE: zdiff --git a/backend/src/services/license-client/license-client-backends.ts b/backend/src/services/license-client/license-client-backends.tsindex 08b2e7ee4f..de73eb62c2 100644--- a/backend/src/services/license-client/license-client-backends.ts+++ b/backend/src/services/license-client/license-client-backends.ts@@ -20,30 +20,30 @@ const SUBSCRIPTION_PATH = "/v1/subscription";const CHECKOUT_SESSION_PATH = "/v1/billing/checkout-session";const PORTAL_SESSION_PATH = "/v1/billing/portal-session";-export type TLicenseServerAuth = {- hmacSecret: string;- issuer: string;- audience: string;-};+// Issuer/audience/subject are a fixed contract with the license server (it validates them against+// its own configured values), not per-deployment config, so they live here rather than in env.+const SERVICE_TOKEN_ISSUER = "infisical";+const SERVICE_TOKEN_AUDIENCE = "license-server";+const SERVICE_TOKEN_SUBJECT = "infisical-cloud";-// The license server validates a short-lived HS256 service JWT (iss/aud/exp/sub), not the raw secret.-// Mint a fresh token per request; signing is cheap and entitlement results are cached upstream.-const mintServiceToken = (auth: TLicenseServerAuth): string =>- jwt.sign({}, auth.hmacSecret, {+// The license server validates a short-lived HS256 service JWT (iss/aud/exp/sub) signed with the+// shared service key. Mint a fresh token per request; signing is cheap and results are cached upstream.+const mintServiceToken = (hmacSecret: string): string =>+ jwt.sign({}, hmacSecret, {algorithm: "HS256",- issuer: auth.issuer,- audience: auth.audience,- subject: "infisical-cloud",+ issuer: SERVICE_TOKEN_ISSUER,+ audience: SERVICE_TOKEN_AUDIENCE,+ subject: SERVICE_TOKEN_SUBJECT,expiresIn: "2m"});-export const licenseServerBackend = (serverUrl: string, auth: TLicenseServerAuth): TLicenseClientBackend => ({+export const licenseServerBackend = (serverUrl: string, hmacSecret: string): TLicenseClientBackend => ({fetchEntitlements: async (orgId: string): Promise<TEntitlementsResponse> => {const url = new URL(ENTITLEMENTS_PATH, serverUrl);url.searchParams.set("org_id", orgId);const res = await fetch(url, {method: "GET",- headers: { Authorization: `Bearer ${mintServiceToken(auth)}` },+ headers: { Authorization: `Bearer ${mintServiceToken(hmacSecret)}` },redirect: "manual"});if (!res.ok) {@@ -57,7 +57,7 @@ export const licenseServerBackend = (serverUrl: string, auth: TLicenseServerAuthconst url = new URL(PRODUCTS_PATH, serverUrl);const res = await fetch(url, {method: "GET",- headers: { Authorization: `Bearer ${mintServiceToken(auth)}` },+ headers: { Authorization: `Bearer ${mintServiceToken(hmacSecret)}` },redirect: "manual"});if (!res.ok) {@@ -75,7 +75,7 @@ export const licenseServerBackend = (serverUrl: string, auth: TLicenseServerAuthurl.searchParams.set("org_id", orgId);const res = await fetch(url, {method: "GET",- headers: { Authorization: `Bearer ${mintServiceToken(auth)}` },+ headers: { Authorization: `Bearer ${mintServiceToken(hmacSecret)}` },redirect: "manual"});if (res.status === 404) {@@ -101,7 +101,7 @@ export const licenseServerBackend = (serverUrl: string, auth: TLicenseServerAuthurl.searchParams.set("org_id", orgId);const res = await fetch(url, {method: "POST",- headers: { Authorization: `Bearer ${mintServiceToken(auth)}`, "Content-Type": "application/json" },+ headers: { Authorization: `Bearer ${mintServiceToken(hmacSecret)}`, "Content-Type": "application/json" },body: JSON.stringify(payload),redirect: "manual"});@@ -117,7 +117,7 @@ export const licenseServerBackend = (serverUrl: string, auth: TLicenseServerAuthurl.searchParams.set("org_id", orgId);const res = await fetch(url, {method: "POST",- headers: { Authorization: `Bearer ${mintServiceToken(auth)}`, "Content-Type": "application/json" },+ headers: { Authorization: `Bearer ${mintServiceToken(hmacSecret)}`, "Content-Type": "application/json" },body: JSON.stringify(payload),redirect: "manual"});diff --git a/backend/src/services/license-client/license-client.ts b/backend/src/services/license-client/license-client.tsindex 476c8b1651..7bfe28badc 100644--- a/backend/src/services/license-client/license-client.ts+++ b/backend/src/services/license-client/license-client.ts@@ -8,14 +8,7 @@ import { entitlementResolverFactory } from "./license-client-cache";import { TCreateCheckoutPayload, TCreatePortalPayload, TLicenseClientBackend } from "./license-client-types";type TLicenseClientFactoryDep = {- envConfig: Pick<- TEnvConfig,- | "LICENSE_SERVER_V2_ENABLED"- | "LICENSE_SERVER_V2_URL"- | "LICENSE_SERVER_V2_SERVICE_KEY"- | "LICENSE_SERVER_V2_ISSUER"- | "LICENSE_SERVER_V2_AUDIENCE"- >;+ envConfig: Pick<TEnvConfig, "LICENSE_SERVER_V2_ENABLED" | "LICENSE_SERVER_V2_URL" | "LICENSE_SERVER_V2_SERVICE_KEY">;keyStore: Pick<TKeyStoreFactory, "getItem" | "setItemWithExpiry">;};@@ -30,11 +23,9 @@ const buildBackend = (envConfig: TLicenseClientFactoryDep["envConfig"]): TLicensconst serverUrl = envConfig.LICENSE_SERVER_V2_URL;const hmacSecret = envConfig.LICENSE_SERVER_V2_SERVICE_KEY;- const issuer = envConfig.LICENSE_SERVER_V2_ISSUER;- const audience = envConfig.LICENSE_SERVER_V2_AUDIENCE;- if (!serverUrl || !hmacSecret || !issuer || !audience) {+ if (!serverUrl || !hmacSecret) {logger.warn(- "license-client: enabled but LICENSE_SERVER_V2_URL / _SERVICE_KEY / _ISSUER / _AUDIENCE is missing; serving feature fallbacks"+ "license-client: enabled but LICENSE_SERVER_V2_URL / _SERVICE_KEY is missing; serving feature fallbacks");return null;}@@ -52,7 +43,7 @@ const buildBackend = (envConfig: TLicenseClientFactoryDep["envConfig"]): TLicensreturn null;}- return licenseServerBackend(serverUrl, { hmacSecret, issuer, audience });+ return licenseServerBackend(serverUrl, hmacSecret);};export const licenseClientFactory = ({ envConfig, keyStore }: TLicenseClientFactoryDep) => {