Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: completed support for offlince license key

=872b12769250
diff --git a/backend/src/ee/services/license/license-service.ts b/backend/src/ee/services/license/license-service.ts
index f043c53204..6af04e4d87 100644
--- a/backend/src/ee/services/license/license-service.ts
+++ b/backend/src/ee/services/license/license-service.ts
@@ -78,7 +78,6 @@ type TLicenseServiceFactoryDep = {
export type TLicenseServiceFactory = ReturnType<typeof licenseServiceFactory>;
const LICENSE_SERVER_CLOUD_LOGIN = "/api/auth/v1/license-server-login";
-const LICENSE_SERVER_ON_PREM_LOGIN = "/api/auth/v1/license-login";
// A self-hosted v2 license is single-tenant: the license key identifies the tenant, so entitlement
// reads carry no real org id. This fixed id only keys the local entitlement cache for the instance.
@@ -109,51 +108,12 @@ export const licenseServiceFactory = ({
envConfig.INTERNAL_REGION
);
- const onlineLicenseKey =
- licenseKeyConfig.isValid && licenseKeyConfig.type === LicenseType.Online ? licenseKeyConfig.licenseKey : "";
-
- const licenseServerOnPremApi = setupLicenseRequestWithStore(
- envConfig.LICENSE_SERVER_URL || "",
- LICENSE_SERVER_ON_PREM_LOGIN,
- onlineLicenseKey,
- envConfig.INTERNAL_REGION
- );
-
const isV1CloudKey = () =>
instanceType === InstanceType.Cloud && envConfig.LICENSE_SERVER_KEY && envConfig.LICENSE_SERVER_V2_MODE !== "on";
- const syncLicenseKeyOnPremFeatures = async (shouldThrow: boolean = false) => {
- logger.info("Start syncing license key features");
- try {
- const {
- data: { currentPlan }
- } = await licenseServerOnPremApi.request.get<{ currentPlan: TFeatureSet }>("/api/license/v1/plan");
-
- const workspacesUsed = await projectDAL.countOfBillableOrgProjects(null);
- currentPlan.workspacesUsed = workspacesUsed;
-
- const usedIdentitySeats = await licenseDAL.countOrgUsersAndIdentities(null);
- if (usedIdentitySeats !== currentPlan.identitiesUsed) {
- const usedSeats = await licenseDAL.countOfOrgMembers(null);
- await licenseServerOnPremApi.request.patch(`/api/license/v1/license`, {
- usedSeats,
- usedIdentitySeats
- });
- currentPlan.identitiesUsed = usedIdentitySeats;
- currentPlan.membersUsed = usedSeats;
- }
-
- onPremFeatures = currentPlan;
- logger.info("Successfully synchronized license key features");
- } catch (error) {
- logger.error(error, "Failed to synchronize license key features");
- if (shouldThrow) throw error;
- }
- };
-
- // Self-hosted equivalent of syncLicenseKeyOnPremFeatures, but sourced from License Server v2: project
- // the license's entitlements into the v1 feature shape and refresh the instance-wide onPremFeatures.
- const syncSelfHostedV2Features = async (shouldThrow: boolean = false) => {
+ // Self-hosted online license: project the license's entitlements (from License Server v2) into the v1
+ // feature shape and refresh the instance-wide onPremFeatures.
+ const syncSelfHostedFeatures = async (shouldThrow: boolean = false) => {
logger.info("Start syncing self-hosted license features from License Server v2");
try {
if (!licenseClient) {
@@ -194,24 +154,13 @@ export const licenseServiceFactory = ({
return;
}
- // New self-hosted key (prefix "infisical_lk_") resolves features from License Server v2. The key
- // authenticates directly (no on-prem login handshake); a successful entitlements sync validates it.
- if (licenseKeyConfig.isValid && licenseKeyConfig.type === LicenseType.OnlineV2) {
- await syncSelfHostedV2Features(true);
- instanceType = InstanceType.EnterpriseOnPremV2;
- logger.info(`Instance type: ${InstanceType.EnterpriseOnPremV2}`);
- isValidLicense = true;
- return;
- }
-
+ // Self-hosted online license: features resolve from License Server v2. The key authenticates via
+ // the token endpoint (handled inside the license client); a successful entitlements sync validates it.
if (licenseKeyConfig.isValid && licenseKeyConfig.type === LicenseType.Online) {
- const token = await licenseServerOnPremApi.refreshLicense();
- if (token) {
- await syncLicenseKeyOnPremFeatures(true);
- instanceType = InstanceType.EnterpriseOnPrem;
- logger.info(`Instance type: ${InstanceType.EnterpriseOnPrem}`);
- isValidLicense = true;
- }
+ await syncSelfHostedFeatures(true);
+ instanceType = InstanceType.EnterpriseOnPrem;
+ logger.info(`Instance type: ${InstanceType.EnterpriseOnPrem}`);
+ isValidLicense = true;
return;
}
@@ -236,9 +185,17 @@ export const licenseServiceFactory = ({
}
if (isValidOfflineLicense) {
+ // v2 offline licenses carry License Server v2 entitlements; project them into the feature
+ // shape. v1 (or version-less) licenses carry the legacy feature set directly.
+ const features =
+ contents.license.version === 2 && contents.license.entitlements
+ ? projectV2ToFeatureSet(getDefaultOnPremFeatures(), contents.license.entitlements)
+ : contents.license.features;
+
onPremFeatures = {
- ...contents.license.features,
- slug: "enterprise"
+ ...features,
+ slug: "enterprise",
+ isOffline: true
};
instanceType = InstanceType.EnterpriseOnPremOffline;
logger.info(`Instance type: ${InstanceType.EnterpriseOnPremOffline}`);
@@ -258,14 +215,8 @@ export const licenseServiceFactory = ({
const initializeBackgroundSync = async () => {
if (licenseKeyConfig?.isValid && licenseKeyConfig?.type === LicenseType.Online) {
- logger.info("Setting up background sync process for refresh onPremFeatures");
- const job = new CronJob("*/10 * * * *", syncLicenseKeyOnPremFeatures);
- job.start();
- return job;
- }
- if (licenseKeyConfig?.isValid && licenseKeyConfig?.type === LicenseType.OnlineV2) {
- logger.info("Setting up background sync process for refresh onPremFeatures from License Server v2");
- const job = new CronJob("*/10 * * * *", () => syncSelfHostedV2Features());
+ logger.info("Setting up background sync process to refresh onPremFeatures from License Server v2");
+ const job = new CronJob("*/10 * * * *", () => syncSelfHostedFeatures());
job.start();
return job;
}
@@ -418,12 +369,9 @@ export const licenseServiceFactory = ({
await getPlan(orgId);
}
if (instanceType === InstanceType.EnterpriseOnPrem) {
- await syncLicenseKeyOnPremFeatures(true);
- }
- if (instanceType === InstanceType.EnterpriseOnPremV2) {
// Bust the license server's cached entitlements (e.g. after a license change), then re-sync.
await licenseClient?.refreshEntitlements({ id: SELF_HOSTED_LICENSE_ORG_ID });
- await syncSelfHostedV2Features(true);
+ await syncSelfHostedFeatures(true);
}
};
@@ -470,16 +418,7 @@ export const licenseServiceFactory = ({
}
await keyStore.deleteItem(KeyStorePrefixes.LicenseCloudPlan(rootOrgId));
} else if (instanceType === InstanceType.EnterpriseOnPrem) {
- // const usedSeats = await licenseDAL.countOfOrgMembers(null, tx);
- // const usedIdentitySeats = await licenseDAL.countOrgUsersAndIdentities(null, tx);
- // onPremFeatures.membersUsed = usedSeats;
- // onPremFeatures.identitiesUsed = usedIdentitySeats;
- // await licenseServerOnPremApi.request.patch(`/api/license/v1/license`, {
- // usedSeats,
- // usedIdentitySeats
- // });
- } else if (instanceType === InstanceType.EnterpriseOnPremV2) {
- // v2 self-hosted reports usage asynchronously via the usage-snapshot queue, not a synchronous seat
+ // Self-hosted reports usage asynchronously via the usage-snapshot queue, not a synchronous seat
// patch; keep the in-memory counts current so limit checks are accurate until the next sync.
onPremFeatures.membersUsed = await licenseDAL.countOfOrgMembers(null, tx);
onPremFeatures.identitiesUsed = await licenseDAL.countOrgUsersAndIdentities(null, tx);
@@ -736,14 +675,6 @@ export const licenseServiceFactory = ({
return data;
}
- if (instanceType === InstanceType.EnterpriseOnPrem) {
- const { data } = await licenseServerOnPremApi.request.get<{
- head: { name: string }[];
- rows: { name: string; allowed: boolean }[];
- }>(`${baseUrl}/on-prem-plan/table`);
- return data;
- }
-
throw new Error(`Unsupported instance type for server-based plan table: ${instanceType}`);
};
@@ -768,7 +699,7 @@ export const licenseServiceFactory = ({
const { projectCount, totalIdentities } = await getUsageMetrics(orgId);
- if (instanceType === InstanceType.Cloud || instanceType === InstanceType.EnterpriseOnPrem) {
+ if (instanceType === InstanceType.Cloud) {
const tableResponse = await fetchPlanTableFromServer(organization.customerId);
return {
diff --git a/backend/src/ee/services/license/license-types.ts b/backend/src/ee/services/license/license-types.ts
index 62aa9c0377..0dcd972035 100644
--- a/backend/src/ee/services/license/license-types.ts
+++ b/backend/src/ee/services/license/license-types.ts
@@ -1,11 +1,11 @@
import { TOrgPermission } from "@app/lib/types";
+import { TEntitlementsResponse } from "@app/services/license-client/license-client-types";
export enum InstanceType {
OnPrem = "self-hosted",
+ // Self-hosted online license: features are resolved from License Server v2.
EnterpriseOnPrem = "enterprise-self-hosted",
EnterpriseOnPremOffline = "enterprise-self-hosted-offline",
- // Self-hosted instance whose license is resolved from License Server v2 (new "infisical_lk_" key).
- EnterpriseOnPremV2 = "enterprise-self-hosted-v2",
Cloud = "cloud"
}
@@ -21,7 +21,11 @@ export type TOfflineLicense = {
issuedAt: string;
expiresAt: string | null;
terminatesAt: string | null;
+ // v1 (or absent) offline licenses carry the legacy feature-flag set directly; version 2 licenses
+ // carry License Server v2 entitlements, which we project into the same feature shape.
+ version?: number;
features: TFeatureSet;
+ entitlements?: TEntitlementsResponse;
};
export type TPlanBillingInfo = {
@@ -36,6 +40,9 @@ export type TPlanBillingInfo = {
export type TFeatureSet = {
_id: null;
slug: string | null;
+ // True when features are sourced from an offline (air-gapped) license; the billing UI renders a
+ // read-only offline banner instead of the live billing surface.
+ isOffline?: boolean;
tier: -1;
workspaceLimit: null;
workspacesUsed: number;
@@ -161,9 +168,8 @@ export type TOrgLicensesDTO = TOrgPermission;
export enum LicenseType {
Offline = "offline",
- Online = "online",
- // New self-hosted key (prefix "infisical_lk_") that resolves entitlements from License Server v2.
- OnlineV2 = "online-v2"
+ // Self-hosted online license key; resolves entitlements from License Server v2.
+ Online = "online"
}
export type TLicenseKeyConfig =
diff --git a/backend/src/services/license-client/license-client.test.ts b/backend/src/services/license-client/license-client.test.ts
index ba6b2b2f15..3583091a47 100644
--- a/backend/src/services/license-client/license-client.test.ts
+++ b/backend/src/services/license-client/license-client.test.ts
@@ -142,6 +142,7 @@ describe("licenseClientFactory (usage example)", () => {
LICENSE_SERVER_V2_MODE: "off",
LICENSE_SERVER_V2_URL: undefined,
LICENSE_SERVER_V2_SERVICE_KEY: undefined,
+ LICENSE_SERVER_URL: "https://license.example.com",
INTERNAL_REGION: undefined
},
keyStore: createFakeKeyStore()
diff --git a/backend/src/services/license-client/license-client.ts b/backend/src/services/license-client/license-client.ts
index e6d1e826fd..67e8ffafcb 100644
--- a/backend/src/services/license-client/license-client.ts
+++ b/backend/src/services/license-client/license-client.ts
@@ -47,9 +47,13 @@ const buildBackend = (envConfig: TLicenseClientFactoryDep["envConfig"]): TLicens
return licenseServerSelfHostedBackend(envConfig.LICENSE_SERVER_URL, tokenProvider, envConfig.INTERNAL_REGION);
}
- const serverUrl = envConfig.LICENSE_SERVER_V2_URL;
+ // Self-hosted sets only LICENSE_SERVER_URL (that one host now serves both the token endpoint and the
+ // v2 API after the DNS switch); cloud sets LICENSE_SERVER_V2_URL. Accept either as the v2 API base.
+ const serverUrl = envConfig.LICENSE_SERVER_V2_URL || envConfig.LICENSE_SERVER_URL;
if (!serverUrl) {
- logger.warn("license-client: enabled but LICENSE_SERVER_V2_URL is missing; serving feature fallbacks");
+ logger.warn(
+ "license-client: enabled but neither LICENSE_SERVER_V2_URL nor LICENSE_SERVER_URL is set; serving feature fallbacks"
+ );
return null;
}
diff --git a/backend/src/services/license-client/license-token-provider.test.ts b/backend/src/services/license-client/license-token-provider.test.ts
index 2818a51850..e894241e3f 100644
--- a/backend/src/services/license-client/license-token-provider.test.ts
+++ b/backend/src/services/license-client/license-token-provider.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
+import { afterEach, describe, expect, test, vi } from "vitest";
import { createSelfHostedTokenProvider } from "./license-token-provider";
diff --git a/backend/src/services/license-client/license-token-provider.ts b/backend/src/services/license-client/license-token-provider.ts
index e5d81fd915..6fc76dfd12 100644
--- a/backend/src/services/license-client/license-token-provider.ts
+++ b/backend/src/services/license-client/license-token-provider.ts
@@ -7,9 +7,6 @@ export type TLicenseTokenProvider = {
invalidate: () => void;
};
-// Both self-hosted license key formats (legacy and infisical_lk_) authenticate the same way: POST the
-// key to the license server's token endpoint and use the returned short-lived JWT as a bearer. The
-// endpoint lives on LICENSE_SERVER_URL (the same base the v1 on-prem login uses), not the v2 API base.
const LICENSE_LOGIN_PATH = "/api/auth/v1/license-login";
// Refresh this many seconds before the JWT's exp so an in-flight request never carries an expired token.
diff --git a/backend/src/services/license-client/usage/usage-event-queue.ts b/backend/src/services/license-client/usage/usage-event-queue.ts
index 0255f4bc19..96eab78505 100644
--- a/backend/src/services/license-client/usage/usage-event-queue.ts
+++ b/backend/src/services/license-client/usage/usage-event-queue.ts
@@ -161,13 +161,13 @@ export const usageEventQueueFactory = ({
const init = () => {
startWorker();
- // cronJob.register({
- // name: CronJobName.LicenseUsageFlush,
- // pattern: "0 0 * * *", // daily at midnight UTC
- // runHashTtlS: 60 * 60,
- // enabled: !isCloud && !isOffline,
- // handler: flushInstanceUsage
- // });
+ cronJob.register({
+ name: CronJobName.LicenseUsageFlush,
+ pattern: "0 0 * * *", // daily at midnight UTC
+ runHashTtlS: 60 * 60,
+ enabled: !isCloud && !isOffline,
+ handler: flushInstanceUsage
+ });
};
return { init, handleUsageEvent, flushInstanceUsage };
diff --git a/backend/src/services/license-client/usage/usage-metering.test.ts b/backend/src/services/license-client/usage/usage-metering.test.ts
index 486f5c5ea8..8b6714fd6a 100644
--- a/backend/src/services/license-client/usage/usage-metering.test.ts
+++ b/backend/src/services/license-client/usage/usage-metering.test.ts
@@ -203,18 +203,23 @@ describe("usageMeteringService.reconcile (demand-driven)", () => {
describe("buildUsageReporter", () => {
test("is null when disabled", () => {
- expect(buildUsageReporter({ LICENSE_SERVER_V2_MODE: "off" })).toBeNull();
+ expect(
+ buildUsageReporter({ LICENSE_SERVER_V2_MODE: "off", LICENSE_SERVER_URL: "https://license.example.com" })
+ ).toBeNull();
});
test("is null when enabled but unconfigured", () => {
- expect(buildUsageReporter({ LICENSE_SERVER_V2_MODE: "read-compare" })).toBeNull();
+ expect(
+ buildUsageReporter({ LICENSE_SERVER_V2_MODE: "read-compare", LICENSE_SERVER_URL: "https://license.example.com" })
+ ).toBeNull();
});
test("is a reporter when enabled and configured", () => {
const reporter = buildUsageReporter({
LICENSE_SERVER_V2_MODE: "read-compare",
LICENSE_SERVER_V2_URL: "https://license.example.com",
- LICENSE_SERVER_V2_SERVICE_KEY: "svc-key"
+ LICENSE_SERVER_V2_SERVICE_KEY: "svc-key",
+ LICENSE_SERVER_URL: "https://license.example.com"
});
expect(reporter).not.toBeNull();
expect(typeof reporter?.reportSnapshots).toBe("function");
diff --git a/backend/src/services/license-client/usage/usage-reporter.ts b/backend/src/services/license-client/usage/usage-reporter.ts
index c06cb7f2f5..7258f381e5 100644
--- a/backend/src/services/license-client/usage/usage-reporter.ts
+++ b/backend/src/services/license-client/usage/usage-reporter.ts
@@ -79,9 +79,13 @@ export const buildUsageReporter = (
return null;
}
- const serverUrl = envConfig.LICENSE_SERVER_V2_URL;
+ // Self-hosted sets only LICENSE_SERVER_URL (that one host now serves both the token endpoint and the
+ // v2 API after the DNS switch); cloud sets LICENSE_SERVER_V2_URL. Accept either as the v2 API base.
+ const serverUrl = envConfig.LICENSE_SERVER_V2_URL || envConfig.LICENSE_SERVER_URL;
if (!serverUrl) {
- logger.warn("usage-reporter: enabled but LICENSE_SERVER_V2_URL is missing; usage reporting disabled");
+ logger.warn(
+ "usage-reporter: enabled but neither LICENSE_SERVER_V2_URL nor LICENSE_SERVER_URL is set; usage reporting disabled"
+ );
return null;
}
@@ -90,11 +94,11 @@ export const buildUsageReporter = (
try {
parsedUrl = new URL(serverUrl);
} catch {
- logger.warn("usage-reporter: LICENSE_SERVER_V2_URL is not a valid URL; usage reporting disabled");
+ logger.warn("usage-reporter: license server URL is not a valid URL; usage reporting disabled");
return null;
}
if (parsedUrl.protocol !== "https:" && process.env.NODE_ENV !== "development") {
- logger.warn("usage-reporter: LICENSE_SERVER_V2_URL must use https; usage reporting disabled");
+ logger.warn("usage-reporter: license server URL must use https; usage reporting disabled");
return null;
}
diff --git a/frontend/src/hooks/api/subscriptions/types.ts b/frontend/src/hooks/api/subscriptions/types.ts
index bedb2ba017..a52d41a0fa 100644
--- a/frontend/src/hooks/api/subscriptions/types.ts
+++ b/frontend/src/hooks/api/subscriptions/types.ts
@@ -30,6 +30,7 @@ export type SubscriptionPlan = {
rbac: boolean;
secretVersioning: boolean;
slug: SubscriptionPlanTypes;
+ isOffline?: boolean;
secretApproval: boolean;
secretRotation: boolean;
tier: number;
diff --git a/frontend/src/pages/organization/BillingPage/BillingPage.tsx b/frontend/src/pages/organization/BillingPage/BillingPage.tsx
index c1c8794f35..d16656f8bc 100644
--- a/frontend/src/pages/organization/BillingPage/BillingPage.tsx
+++ b/frontend/src/pages/organization/BillingPage/BillingPage.tsx
@@ -3,14 +3,27 @@ import { useTranslation } from "react-i18next";
import { OrgPermissionCan } from "@app/components/permissions";
import { PageHeader } from "@app/components/v2";
-import { OrgPermissionBillingActions, OrgPermissionSubjects, useServerConfig } from "@app/context";
+import {
+ OrgPermissionBillingActions,
+ OrgPermissionSubjects,
+ useServerConfig,
+ useSubscription
+} from "@app/context";
import { BillingV2Page } from "../BillingV2Page";
import { BillingTabGroup } from "./components";
+import { OfflineBillingPage } from "./OfflineBillingPage";
export const BillingPage = () => {
const { t } = useTranslation();
const { config } = useServerConfig();
+ const { subscription } = useSubscription();
+
+ // Offline (air-gapped) licenses can't reach the license server, so neither billing surface can load;
+ // short-circuit to the offline page (no API calls) before mounting either.
+ if (subscription?.isOffline) {
+ return <OfflineBillingPage />;
+ }
if (config.licenseServerV2Enabled) {
return <BillingV2Page />;
diff --git a/frontend/src/pages/organization/BillingPage/OfflineBillingPage.tsx b/frontend/src/pages/organization/BillingPage/OfflineBillingPage.tsx
new file mode 100644
index 0000000000..4269a0db5d
--- /dev/null
+++ b/frontend/src/pages/organization/BillingPage/OfflineBillingPage.tsx
@@ -0,0 +1,49 @@
+import { Helmet } from "react-helmet";
+import { useTranslation } from "react-i18next";
+import { TriangleAlert } from "lucide-react";
+
+import { OrgPermissionCan } from "@app/components/permissions";
+import { PageHeader } from "@app/components/v2";
+import { Alert, AlertDescription, AlertTitle } from "@app/components/v3";
+import { OrgPermissionBillingActions, OrgPermissionSubjects } from "@app/context";
+
+// Standalone billing page for offline (air-gapped) licenses. It makes no API calls — the license
+// server is unreachable, so every billing/subscription request would fail — and just explains that
+// billing is managed out-of-band.
+export const OfflineBillingPage = () => {
+ const { t } = useTranslation();
+
+ return (
+ <div className="h-full bg-bunker-800">
+ <Helmet>
+ <title>{t("common.head-title", { title: t("billing.title") })}</title>
+ <link rel="icon" href="/infisical.ico" />
+ <meta property="og:image" content="/images/message.png" />
+ </Helmet>
+ <div className="flex h-full w-full justify-center bg-bunker-800 text-white">
+ <div className="w-full max-w-8xl">
+ <PageHeader
+ scope="org"
+ title={t("billing.title")}
+ description="Your plan is provisioned through an offline license."
+ />
+ <OrgPermissionCan
+ passThrough={false}
+ I={OrgPermissionBillingActions.Read}
+ a={OrgPermissionSubjects.Billing}
+ >
+ <Alert variant="info">
+ <TriangleAlert />
+ <AlertTitle>Offline license</AlertTitle>
+ <AlertDescription>
+ This instance runs on an offline license, so subscription and billing management
+ isn&apos;t available here. Contact your Infisical account manager to make changes to
+ your plan.
+ </AlertDescription>
+ </Alert>
+ </OrgPermissionCan>
+ </div>
+ </div>
+ </div>
+ );
+};