This commit is contained in:
Philipinho
2026-03-13 23:06:19 +00:00
parent ff01355ec3
commit bf692e8b08
6 changed files with 35 additions and 13 deletions
@@ -1,5 +1,7 @@
import { atom } from "jotai";
import { atomWithStorage } from "jotai/utils";
import type { Entitlements } from "./entitlement.types";
const initialValue: Entitlements | null = null;
export const entitlementAtom = atom(initialValue);
export const entitlementAtom = atomWithStorage<Entitlements | null>(
"entitlements",
null,
);
@@ -60,7 +60,7 @@ export default function Security() {
</>
)}
{hasSecurityAccess && (
{(isCloud() || hasSecurityAccess) && (
<>
<AllowedDomains />
<Divider my="lg" />
@@ -139,7 +139,7 @@ export class SpaceService {
});
if (
!this.licenseCheckService.hasFeature(workspace.licenseKey, 'security:settings')
!this.licenseCheckService.hasFeature(workspace.licenseKey, 'security:settings', workspace.plan)
) {
throw new ForbiddenException(
'This feature requires a valid license',
@@ -329,7 +329,7 @@ export class WorkspaceService {
) {
const ws = await this.db
.selectFrom('workspaces')
.select(['id', 'licenseKey', 'trashRetentionDays'])
.select(['id', 'licenseKey', 'plan', 'trashRetentionDays'])
.where('id', '=', workspaceId)
.executeTakeFirst();
@@ -337,10 +337,24 @@ export class WorkspaceService {
throw new NotFoundException('Workspace not found');
}
if (!this.licenseCheckService.hasFeature(ws.licenseKey, 'security:settings')) {
throw new ForbiddenException(
'This feature requires a valid license',
);
if (typeof updateWorkspaceDto.mcpEnabled !== 'undefined') {
if (!this.licenseCheckService.hasFeature(ws.licenseKey, 'mcp', ws.plan)) {
throw new ForbiddenException(
'This feature requires a valid license',
);
}
}
if (
typeof updateWorkspaceDto.disablePublicSharing !== 'undefined' ||
typeof updateWorkspaceDto.trashRetentionDays !== 'undefined' ||
typeof updateWorkspaceDto.restrictApiToAdmins !== 'undefined'
) {
if (!this.licenseCheckService.hasFeature(ws.licenseKey, 'security:settings', ws.plan)) {
throw new ForbiddenException(
'This feature requires a valid license',
);
}
}
if (
@@ -26,9 +26,15 @@ export class LicenseCheckService {
}
}
hasFeature(licenseKey: string, feature: string): boolean {
hasFeature(licenseKey: string, feature: string, plan?: string): boolean {
if (this.environmentService.isCloud()) {
return true;
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { getFeaturesForCloudPlan } = require('../../ee/licence/feature-registry');
return getFeaturesForCloudPlan(plan).has(feature);
} catch {
return false;
}
}
try {