Skip to content

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

Improve self-hosted refresh logic

Carlos Monastyrski0c2ffc75f6a4
diff --git a/backend/src/ee/services/license/license-service.ts b/backend/src/ee/services/license/license-service.ts
index 23d8b06464..ca1615ce8d 100644
--- a/backend/src/ee/services/license/license-service.ts
+++ b/backend/src/ee/services/license/license-service.ts
@@ -99,6 +99,17 @@ export const licenseServiceFactory = ({
const workspacesUsed = await projectDAL.countOfOrgProjects(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) {
@@ -226,10 +237,13 @@ export const licenseServiceFactory = ({
};
const refreshPlan = async (orgId: string) => {
+ await keyStore.deleteItem(FEATURE_CACHE_KEY(orgId));
if (instanceType === InstanceType.Cloud) {
- await keyStore.deleteItem(FEATURE_CACHE_KEY(orgId));
await getPlan(orgId);
}
+ if (instanceType === InstanceType.EnterpriseOnPrem) {
+ await syncLicenseKeyOnPremFeatures(true);
+ }
};
const generateOrgCustomerId = async (orgName: string, email?: string | null) => {