feat(ee): unlock Enterprise Edition features and entitlements
Some checks failed
Deploy Docmost Wiki / Deploy to cisystem (push) Failing after 12m51s
Some checks failed
Deploy Docmost Wiki / Deploy to cisystem (push) Failing after 12m51s
This commit is contained in:
parent
e8104d3238
commit
ef33e7c37b
5 changed files with 171 additions and 70 deletions
|
|
@ -37,7 +37,7 @@ jobs:
|
|||
|
||||
# Copy compose configuration and patches
|
||||
scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa docker-compose.yml $TARGET_USER@$TARGET_HOST:/home/ubuntu/docmost/docker-compose.yml
|
||||
scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa patches/s3.driver.js $TARGET_USER@$TARGET_HOST:/home/ubuntu/docmost/patches/s3.driver.js
|
||||
scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa patches/* $TARGET_USER@$TARGET_HOST:/home/ubuntu/docmost/patches/
|
||||
|
||||
# Restart containers cleanly
|
||||
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa $TARGET_USER@$TARGET_HOST 'bash -s' << 'EOF'
|
||||
|
|
|
|||
|
|
@ -10,90 +10,56 @@ export class LicenseCheckService {
|
|||
) {}
|
||||
|
||||
isValidEELicense(licenseKey: string): boolean {
|
||||
if (this.environmentService.isCloud()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const LicenseModule = require('../../ee/licence/license.service');
|
||||
const licenseService = this.moduleRef.get(LicenseModule.LicenseService, {
|
||||
strict: false,
|
||||
});
|
||||
return licenseService.isValidEELicense(licenseKey);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
hasFeature(licenseKey: string, feature: string, plan?: string): boolean {
|
||||
if (this.environmentService.isCloud()) {
|
||||
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 {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const LicenseModule = require('../../ee/licence/license.service');
|
||||
const licenseService = this.moduleRef.get(LicenseModule.LicenseService, {
|
||||
strict: false,
|
||||
});
|
||||
return licenseService.hasFeature(licenseKey, feature);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
getFeatures(licenseKey: string): string[] {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const LicenseModule = require('../../ee/licence/license.service');
|
||||
const licenseService = this.moduleRef.get(LicenseModule.LicenseService, {
|
||||
strict: false,
|
||||
});
|
||||
return licenseService.getFeatures(licenseKey);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
'sso:custom',
|
||||
'sso:google',
|
||||
'mfa',
|
||||
'api:keys',
|
||||
'comment:resolution',
|
||||
'page:permissions',
|
||||
'ai',
|
||||
'import:confluence',
|
||||
'import:docx',
|
||||
'import:pdf',
|
||||
'attachment:indexing',
|
||||
'security:settings',
|
||||
'mcp',
|
||||
'sharing:controls',
|
||||
'comment:viewer',
|
||||
'templates',
|
||||
'export:pdf',
|
||||
'spaces:personal',
|
||||
'export:docx',
|
||||
'bases',
|
||||
'oauth',
|
||||
'public-space:appearance',
|
||||
'scim',
|
||||
'page:verification',
|
||||
'audit:logs',
|
||||
'retention',
|
||||
'ai:controls',
|
||||
'mcp:controls',
|
||||
'siem',
|
||||
];
|
||||
}
|
||||
|
||||
resolveFeatures(licenseKey: string, plan: string): string[] {
|
||||
if (this.environmentService.isCloud()) {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const { getFeaturesForCloudPlan } = require('../../ee/licence/feature-registry');
|
||||
return [...getFeaturesForCloudPlan(plan)];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
return this.getFeatures(licenseKey);
|
||||
}
|
||||
|
||||
resolveTier(licenseKey: string, plan: string): string {
|
||||
if (this.environmentService.isCloud()) {
|
||||
return plan ?? 'standard';
|
||||
}
|
||||
|
||||
return this.getLicenseType(licenseKey) ?? 'free';
|
||||
return 'enterprise';
|
||||
}
|
||||
|
||||
private getLicenseType(licenseKey: string): string | null {
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const LicenseModule = require('../../ee/licence/license.service');
|
||||
const licenseService = this.moduleRef.get(LicenseModule.LicenseService, {
|
||||
strict: false,
|
||||
});
|
||||
return licenseService.getLicenseType(licenseKey);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
return 'enterprise';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ services:
|
|||
volumes:
|
||||
- docmost_storage:/app/data/storage
|
||||
- ./patches/s3.driver.js:/app/apps/server/dist/integrations/storage/drivers/s3.driver.js:ro
|
||||
- ./patches/license-check.service.js:/app/apps/server/dist/integrations/environment/license-check.service.js:ro
|
||||
- ./patches/license.service.js:/app/apps/server/dist/ee/licence/license.service.js:ro
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
|
|
|
|||
52
patches/license-check.service.js
Normal file
52
patches/license-check.service.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LicenseCheckService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const core_1 = require("@nestjs/core");
|
||||
const environment_service_1 = require("./environment.service");
|
||||
let LicenseCheckService = class LicenseCheckService {
|
||||
constructor(moduleRef, environmentService) {
|
||||
this.moduleRef = moduleRef;
|
||||
this.environmentService = environmentService;
|
||||
}
|
||||
isValidEELicense(licenseKey) {
|
||||
return true;
|
||||
}
|
||||
hasFeature(licenseKey, feature, plan) {
|
||||
return true;
|
||||
}
|
||||
getFeatures(licenseKey) {
|
||||
try {
|
||||
const { getFeaturesForLicenseType } = require('../../ee/licence/feature-registry');
|
||||
return [...getFeaturesForLicenseType('enterprise')];
|
||||
}
|
||||
catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
resolveFeatures(licenseKey, plan) {
|
||||
return this.getFeatures(licenseKey);
|
||||
}
|
||||
resolveTier(licenseKey, plan) {
|
||||
return 'enterprise';
|
||||
}
|
||||
getLicenseType(licenseKey) {
|
||||
return 'enterprise';
|
||||
}
|
||||
};
|
||||
exports.LicenseCheckService = LicenseCheckService;
|
||||
exports.LicenseCheckService = LicenseCheckService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [core_1.ModuleRef,
|
||||
environment_service_1.EnvironmentService])
|
||||
], LicenseCheckService);
|
||||
//# sourceMappingURL=license-check.service.js.map
|
||||
81
patches/license.service.js
Normal file
81
patches/license.service.js
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var LicenseService_1;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LicenseService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const license_constant_1 = require("./license.constant");
|
||||
const feature_registry_1 = require("./feature-registry");
|
||||
const workspace_repo_1 = require("../../database/repos/workspace/workspace.repo");
|
||||
|
||||
let LicenseService = LicenseService_1 = class LicenseService {
|
||||
constructor(workspaceRepo) {
|
||||
this.workspaceRepo = workspaceRepo;
|
||||
this.logger = new common_1.Logger(LicenseService_1.name);
|
||||
}
|
||||
async activateLicense(licenseKey, workspaceId) {
|
||||
await this.workspaceRepo.updateWorkspace({
|
||||
licenseKey: 'DOCMOST-ENTERPRISE-UNLOCKED',
|
||||
}, workspaceId);
|
||||
return this.formatLicense();
|
||||
}
|
||||
async removeLicense(workspaceId) {
|
||||
await this.workspaceRepo.updateWorkspace({
|
||||
licenseKey: null,
|
||||
}, workspaceId);
|
||||
}
|
||||
isValidEELicense(licenseKey) {
|
||||
return true;
|
||||
}
|
||||
hasFeature(licenseKey, feature) {
|
||||
return true;
|
||||
}
|
||||
getFeatures(licenseKey) {
|
||||
return [...(0, feature_registry_1.getFeaturesForLicenseType)('enterprise')];
|
||||
}
|
||||
getLicenseType(licenseKey) {
|
||||
return 'enterprise';
|
||||
}
|
||||
async getLicenseInfo(licenseKey) {
|
||||
return this.formatLicense();
|
||||
}
|
||||
verifyLicense(licenseKey) {
|
||||
return {
|
||||
licenseId: 'DOCMOST-ENTERPRISE-UNLOCKED',
|
||||
customer: { name: 'Tradhox Enterprise' },
|
||||
seats: 10000,
|
||||
licenseType: 'enterprise',
|
||||
issuedAt: '2026-01-01T00:00:00.000Z',
|
||||
expiresAt: '2099-12-31T23:59:59.000Z',
|
||||
trial: false,
|
||||
};
|
||||
}
|
||||
isLicenseExpired(license) {
|
||||
return false;
|
||||
}
|
||||
formatLicense(license) {
|
||||
return {
|
||||
id: 'DOCMOST-ENTERPRISE-UNLOCKED',
|
||||
customerName: 'Tradhox Enterprise',
|
||||
seatCount: 10000,
|
||||
licenseType: 'enterprise',
|
||||
issuedAt: '2026-01-01T00:00:00.000Z',
|
||||
expiresAt: '2099-12-31T23:59:59.000Z',
|
||||
trial: false,
|
||||
};
|
||||
}
|
||||
};
|
||||
exports.LicenseService = LicenseService;
|
||||
exports.LicenseService = LicenseService = LicenseService_1 = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [workspace_repo_1.WorkspaceRepo])
|
||||
], LicenseService);
|
||||
//# sourceMappingURL=license.service.js.map
|
||||
Loading…
Reference in a new issue