Skip to content

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

feat(platfor-416): data-driven product presentation + cloud-plan limits

Tre Dubravac6197e5cc7d6
diff --git a/backend/src/ee/services/license-v2/license-v2-service.ts b/backend/src/ee/services/license-v2/license-v2-service.ts
index d1f5ed6312..221cc2a407 100644
--- a/backend/src/ee/services/license-v2/license-v2-service.ts
+++ b/backend/src/ee/services/license-v2/license-v2-service.ts
@@ -35,22 +35,16 @@ type TLicenseV2ServiceFactoryDep = {
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
licenseClient: Pick<
TLicenseClientFactory,
- "getEntitlements" | "getCatalog" | "getSubscription" | "createCheckout" | "createPortal"
+ "getEntitlements" | "getCatalog" | "getSubscription" | "getCloudPlan" | "createCheckout" | "createPortal"
>;
};
export type TLicenseV2ServiceFactory = ReturnType<typeof licenseV2ServiceFactory>;
-// Presentation metadata the license server does not provide, keyed by the server's real product ids.
-const PRODUCT_PRESENTATION: Record<string, { icon: string; color: string }> = {
- secrets_management: { icon: "IconKey", color: "#457d91" },
- cert_management: { icon: "IconShieldCheck", color: "#4c6081" },
- pam: { icon: "IconLock", color: "#694c81" },
- secrets_scanning: { icon: "IconScan", color: "#a6702b" },
- boost: { icon: "IconZap", color: "#a4873e" }
-};
-
-const DEFAULT_PRESENTATION = { icon: "IconBox", color: "#6b7280" };
+// Used only when the catalog omits presentation for a product; the icon name resolves to a generic
+// glyph on the client.
+const FALLBACK_ICON = "box";
+const FALLBACK_COLOR = "#6b7280";
const CATALOG_MODELS: BillingV2Model[] = ["seat", "usage", "limit", "flat"];
@@ -118,8 +112,6 @@ const findPaidSelfServePlan = (product: TCatalogProduct) =>
product.plans.find((plan) => plan.selfServe === true && plan.tier !== "free" && plan.prices.length > 0);
const toCatalogProduct = (product: TCatalogProduct): BillingV2CatalogProduct => {
- const presentation = PRODUCT_PRESENTATION[product.id] ?? DEFAULT_PRESENTATION;
-
const paidSelfServePlan = findPaidSelfServePlan(product);
const salesLedPlan = product.plans.find((plan) => plan.salesLed === true);
@@ -187,8 +179,8 @@ const toCatalogProduct = (product: TCatalogProduct): BillingV2CatalogProduct =>
return {
id: product.id,
name: product.name,
- icon: presentation.icon,
- color: presentation.color,
+ icon: product.icon || FALLBACK_ICON,
+ color: product.color || FALLBACK_COLOR,
model: toModel(product.model),
addon: product.addon,
desc: product.description ?? "",
@@ -337,6 +329,18 @@ export const licenseV2ServiceFactory = ({
const members = await orgDAL.countAllOrgMembers(orgId);
+ // Plan caps come from the license server (a null limit means genuinely unlimited). Used counts
+ // are overlaid here; a missing plan leaves limits unknown.
+ let memberLimit: number | null = null;
+ let identityLimit: number | null = null;
+ try {
+ const cloudPlan = await licenseClient.getCloudPlan(orgId);
+ memberLimit = cloudPlan?.currentPlan.memberLimit ?? null;
+ identityLimit = cloudPlan?.currentPlan.identityLimit ?? null;
+ } catch (error) {
+ logger.error(error, `billing-v2: failed to read cloud plan [orgId=${orgId}]`);
+ }
+
// Name the plan from the subscription's tier so enterprise/trial orgs aren't all labelled "Pro".
let planName = "Free";
if (subState !== "no-subscription") {
@@ -358,9 +362,9 @@ export const licenseV2ServiceFactory = ({
interval,
usage: {
members,
- memberLimit: null,
+ memberLimit,
identities: 0,
- identityLimit: null
+ identityLimit
},
payment: null,
billingDetails: null,
diff --git a/backend/src/services/license-client/license-client-backends.ts b/backend/src/services/license-client/license-client-backends.ts
index a8d4530a27..ae72aad618 100644
--- a/backend/src/services/license-client/license-client-backends.ts
+++ b/backend/src/services/license-client/license-client-backends.ts
@@ -2,10 +2,12 @@ import jwt from "jsonwebtoken";
import {
catalogResponseSchema,
+ cloudPlanResponseSchema,
entitlementsResponseSchema,
sessionResponseSchema,
subscriptionResponseSchema,
TCatalogResponse,
+ TCloudPlanResponse,
TCreateCheckoutPayload,
TCreatePortalPayload,
TEntitlementsResponse,
@@ -17,6 +19,7 @@ import {
const ENTITLEMENTS_PATH = "/v1/entitlements";
const PRODUCTS_PATH = "/v1/products";
const SUBSCRIPTION_PATH = "/v1/subscription";
+const CLOUD_PLAN_PATH = "/v1/cloud-plan";
const CHECKOUT_SESSION_PATH = "/v1/billing/checkout-session";
const PORTAL_SESSION_PATH = "/v1/billing/portal-session";
@@ -96,6 +99,26 @@ export const licenseServerBackend = (serverUrl: string, signingKey: string): TLi
return parsed.data;
},
+ // 404 means the org has no license/plan yet; treat as "no plan" so the usage meter falls back to
+ // unknown limits. Other non-2xx statuses are real errors and surface.
+ fetchCloudPlan: async (orgId: string): Promise<TCloudPlanResponse | null> => {
+ const url = new URL(CLOUD_PLAN_PATH, serverUrl);
+ url.searchParams.set("org_id", orgId);
+ const res = await fetch(url, {
+ method: "GET",
+ headers: { Authorization: `Bearer ${mintServiceToken(signingKey)}` },
+ redirect: "manual"
+ });
+ if (res.status === 404) {
+ return null;
+ }
+ if (!res.ok) {
+ throw new Error(`license server responded with ${res.status}`);
+ }
+ const body: unknown = await res.json();
+ return cloudPlanResponseSchema.parse(body);
+ },
+
createCheckoutSession: async (orgId: string, payload: TCreateCheckoutPayload): Promise<TSessionResponse> => {
const url = new URL(CHECKOUT_SESSION_PATH, serverUrl);
url.searchParams.set("org_id", orgId);
diff --git a/backend/src/services/license-client/license-client-types.ts b/backend/src/services/license-client/license-client-types.ts
index 5ffc65317b..b7e1ce5bce 100644
--- a/backend/src/services/license-client/license-client-types.ts
+++ b/backend/src/services/license-client/license-client-types.ts
@@ -66,6 +66,8 @@ const catalogProductSchema = z
name: z.string(),
description: z.string().optional(),
tagline: z.string().optional(),
+ icon: z.string().optional(),
+ color: z.string().optional(),
model: z.string(),
addon: z.boolean(),
dimensions: z.array(catalogDimensionSchema),
@@ -107,6 +109,19 @@ export const sessionResponseSchema = z
})
.passthrough();
+// The cloud-plan FeatureSet carries plan caps; the server nulls a limit when it is effectively
+// unlimited. Used counts come back zeroed and are overlaid by this app, so we ignore them.
+export const cloudPlanResponseSchema = z
+ .object({
+ currentPlan: z
+ .object({
+ memberLimit: z.number().nullish(),
+ identityLimit: z.number().nullish()
+ })
+ .passthrough()
+ })
+ .passthrough();
+
export type TEntitlementFeature = z.infer<typeof entitlementFeatureSchema>;
export type TEntitlementsResponse = z.infer<typeof entitlementsResponseSchema>;
export type TCatalogProduct = z.infer<typeof catalogProductSchema>;
@@ -114,6 +129,7 @@ export type TCatalogResponse = z.infer<typeof catalogResponseSchema>;
export type TSubscriptionItem = z.infer<typeof subscriptionItemSchema>;
export type TSubscriptionResponse = z.infer<typeof subscriptionResponseSchema>;
export type TSessionResponse = z.infer<typeof sessionResponseSchema>;
+export type TCloudPlanResponse = z.infer<typeof cloudPlanResponseSchema>;
export type TCheckoutLineItem = {
productId: string;
@@ -136,6 +152,7 @@ export type TLicenseClientBackend = {
fetchEntitlements: (orgId: string) => Promise<TEntitlementsResponse>;
fetchCatalog: () => Promise<TCatalogResponse>;
fetchSubscription: (orgId: string) => Promise<TSubscriptionResponse | null>;
+ fetchCloudPlan: (orgId: string) => Promise<TCloudPlanResponse | null>;
createCheckoutSession: (orgId: string, payload: TCreateCheckoutPayload) => Promise<TSessionResponse>;
createPortalSession: (orgId: string, payload: TCreatePortalPayload) => Promise<TSessionResponse>;
};
diff --git a/backend/src/services/license-client/license-client.ts b/backend/src/services/license-client/license-client.ts
index 02028ec823..f03f2b56bd 100644
--- a/backend/src/services/license-client/license-client.ts
+++ b/backend/src/services/license-client/license-client.ts
@@ -72,6 +72,13 @@ export const licenseClientFactory = ({ envConfig, keyStore }: TLicenseClientFact
return backend.fetchSubscription(orgId);
};
+ const getCloudPlan = async (orgId: string) => {
+ if (!backend) {
+ return null;
+ }
+ return backend.fetchCloudPlan(orgId);
+ };
+
const createCheckout = async (orgId: string, payload: TCreateCheckoutPayload) => {
if (!backend) {
throw new Error("license client backend is not configured");
@@ -91,6 +98,7 @@ export const licenseClientFactory = ({ envConfig, keyStore }: TLicenseClientFact
getEntitlements,
getCatalog,
getSubscription,
+ getCloudPlan,
createCheckout,
createPortal
};
diff --git a/frontend/src/pages/organization/BillingV2Page/components/shared.tsx b/frontend/src/pages/organization/BillingV2Page/components/shared.tsx
index 81738cc1d8..3606791379 100644
--- a/frontend/src/pages/organization/BillingV2Page/components/shared.tsx
+++ b/frontend/src/pages/organization/BillingV2Page/components/shared.tsx
@@ -1,4 +1,5 @@
import {
+ faAward,
faBolt,
faBox,
faKey,
@@ -12,14 +13,16 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Badge } from "@app/components/v3";
import { BillingV2CatalogProduct } from "@app/hooks/api";
-// Maps the catalog icon name (license-server presentation metadata) to a FontAwesome glyph.
+// Maps the catalog icon token (license-server presentation metadata) to a FontAwesome glyph.
+// Tokens mirror the license server's icon vocabulary; unknown tokens fall back to faBox.
const ICON_BY_NAME: Record<string, IconDefinition> = {
- IconKey: faKey,
- IconShieldCheck: faShieldHalved,
- IconLock: faLock,
- IconScan: faMagnifyingGlass,
- IconZap: faBolt,
- IconBox: faBox
+ lock: faLock,
+ shield: faShieldHalved,
+ award: faAward,
+ scan_line: faMagnifyingGlass,
+ zap: faBolt,
+ key: faKey,
+ box: faBox
};
type MeterTone = "ok" | "near" | "full";