@@ -152,8 +152,10 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
152
152
}
153
153
}
154
154
155
- protected requireEELicense ( feature : Feature ) {
156
- if ( ! this . licenseEvaluator . isEnabled ( feature ) ) {
155
+ protected async requireEELicense ( feature : Feature ) {
156
+ const userCount = await this . userDB . getUserCount ( true ) ;
157
+
158
+ if ( ! this . licenseEvaluator . isEnabled ( feature , userCount ) ) {
157
159
throw new ResponseError ( ErrorCodes . EE_LICENSE_REQUIRED , "enterprise license required" ) ;
158
160
}
159
161
}
@@ -181,7 +183,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
181
183
traceAPIParams ( ctx , { workspaceId, duration } ) ;
182
184
traceWI ( ctx , { workspaceId } ) ;
183
185
184
- this . requireEELicense ( Feature . FeatureSetTimeout ) ;
186
+ await this . requireEELicense ( Feature . FeatureSetTimeout ) ;
185
187
const user = this . checkUser ( "setWorkspaceTimeout" ) ;
186
188
187
189
if ( ! WorkspaceTimeoutValues . includes ( duration ) ) {
@@ -281,7 +283,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
281
283
traceAPIParams ( ctx , { workspaceId, level } ) ;
282
284
traceWI ( ctx , { workspaceId } ) ;
283
285
284
- this . requireEELicense ( Feature . FeatureWorkspaceSharing ) ;
286
+ await this . requireEELicense ( Feature . FeatureWorkspaceSharing ) ;
285
287
this . checkAndBlockUser ( 'controlAdmission' ) ;
286
288
287
289
const lvlmap = new Map < string , AdmissionLevel > ( ) ;
@@ -317,7 +319,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
317
319
const { workspaceId, dontWait } = options ;
318
320
traceWI ( ctx , { workspaceId } ) ;
319
321
320
- this . requireEELicense ( Feature . FeatureSnapshot ) ;
322
+ await this . requireEELicense ( Feature . FeatureSnapshot ) ;
321
323
const user = this . checkAndBlockUser ( "takeSnapshot" ) ;
322
324
323
325
const workspace = await this . guardSnaphotAccess ( ctx , user . id , workspaceId ) ;
@@ -371,7 +373,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
371
373
async waitForSnapshot ( ctx : TraceContext , snapshotId : string ) : Promise < void > {
372
374
traceAPIParams ( ctx , { snapshotId } ) ;
373
375
374
- this . requireEELicense ( Feature . FeatureSnapshot ) ;
376
+ await this . requireEELicense ( Feature . FeatureSnapshot ) ;
375
377
const user = this . checkAndBlockUser ( "waitForSnapshot" ) ;
376
378
377
379
const snapshot = await this . workspaceDb . trace ( ctx ) . findSnapshotById ( snapshotId ) ;
@@ -415,7 +417,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
415
417
async adminGetUsers ( ctx : TraceContext , req : AdminGetListRequest < User > ) : Promise < AdminGetListResult < User > > {
416
418
traceAPIParams ( ctx , { req : censor ( req , "searchTerm" ) } ) ; // searchTerm may contain PII
417
419
418
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
420
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
419
421
420
422
await this . guardAdminAccess ( "adminGetUsers" , { req } , Permission . ADMIN_USERS ) ;
421
423
@@ -431,7 +433,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
431
433
async adminGetUser ( ctx : TraceContext , userId : string ) : Promise < User > {
432
434
traceAPIParams ( ctx , { userId } ) ;
433
435
434
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
436
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
435
437
436
438
await this . guardAdminAccess ( "adminGetUser" , { id : userId } , Permission . ADMIN_USERS ) ;
437
439
@@ -451,7 +453,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
451
453
async adminBlockUser ( ctx : TraceContext , req : AdminBlockUserRequest ) : Promise < User > {
452
454
traceAPIParams ( ctx , { req } ) ;
453
455
454
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
456
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
455
457
456
458
await this . guardAdminAccess ( "adminBlockUser" , { req } , Permission . ADMIN_USERS ) ;
457
459
@@ -478,7 +480,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
478
480
async adminDeleteUser ( ctx : TraceContext , userId : string ) : Promise < void > {
479
481
traceAPIParams ( ctx , { userId } ) ;
480
482
481
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
483
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
482
484
483
485
await this . guardAdminAccess ( "adminDeleteUser" , { id : userId } , Permission . ADMIN_USERS ) ;
484
486
@@ -492,7 +494,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
492
494
async adminModifyRoleOrPermission ( ctx : TraceContext , req : AdminModifyRoleOrPermissionRequest ) : Promise < User > {
493
495
traceAPIParams ( ctx , { req } ) ;
494
496
495
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
497
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
496
498
497
499
await this . guardAdminAccess ( "adminModifyRoleOrPermission" , { req } , Permission . ADMIN_USERS ) ;
498
500
@@ -521,7 +523,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
521
523
async adminModifyPermanentWorkspaceFeatureFlag ( ctx : TraceContext , req : AdminModifyPermanentWorkspaceFeatureFlagRequest ) : Promise < User > {
522
524
traceAPIParams ( ctx , { req } ) ;
523
525
524
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
526
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
525
527
526
528
await this . guardAdminAccess ( "adminModifyPermanentWorkspaceFeatureFlag" , { req } , Permission . ADMIN_USERS ) ;
527
529
const target = await this . userDB . findUserById ( req . id ) ;
@@ -549,7 +551,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
549
551
}
550
552
551
553
async adminGetTeamMembers ( ctx : TraceContext , teamId : string ) : Promise < TeamMemberInfo [ ] > {
552
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
554
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
553
555
await this . guardAdminAccess ( "adminGetTeamMembers" , { teamId } , Permission . ADMIN_WORKSPACES ) ;
554
556
555
557
const team = await this . teamDB . findTeamById ( teamId ) ;
@@ -561,28 +563,28 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
561
563
}
562
564
563
565
async adminGetTeams ( ctx : TraceContext , req : AdminGetListRequest < Team > ) : Promise < AdminGetListResult < Team > > {
564
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
566
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
565
567
await this . guardAdminAccess ( "adminGetTeams" , { req } , Permission . ADMIN_WORKSPACES ) ;
566
568
567
569
return await this . teamDB . findTeams ( req . offset , req . limit , req . orderBy , req . orderDir === "asc" ? "ASC" : "DESC" , req . searchTerm as string ) ;
568
570
}
569
571
570
572
async adminGetTeamById ( ctx : TraceContext , id : string ) : Promise < Team | undefined > {
571
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
573
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
572
574
await this . guardAdminAccess ( "adminGetTeamById" , { id } , Permission . ADMIN_WORKSPACES ) ;
573
575
return await this . teamDB . findTeamById ( id ) ;
574
576
}
575
577
576
578
async adminSetTeamMemberRole ( ctx : TraceContext , teamId : string , userId : string , role : TeamMemberRole ) : Promise < void > {
577
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
579
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
578
580
await this . guardAdminAccess ( "adminSetTeamMemberRole" , { teamId, userId, role } , Permission . ADMIN_WORKSPACES ) ;
579
581
return this . teamDB . setTeamMemberRole ( userId , teamId , role ) ;
580
582
}
581
583
582
584
async adminGetWorkspaces ( ctx : TraceContext , req : AdminGetWorkspacesRequest ) : Promise < AdminGetListResult < WorkspaceAndInstance > > {
583
585
traceAPIParams ( ctx , { req } ) ;
584
586
585
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
587
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
586
588
587
589
await this . guardAdminAccess ( "adminGetWorkspaces" , { req } , Permission . ADMIN_WORKSPACES ) ;
588
590
@@ -592,7 +594,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
592
594
async adminGetWorkspace ( ctx : TraceContext , workspaceId : string ) : Promise < WorkspaceAndInstance > {
593
595
traceAPIParams ( ctx , { workspaceId } ) ;
594
596
595
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
597
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
596
598
597
599
await this . guardAdminAccess ( "adminGetWorkspace" , { id : workspaceId } , Permission . ADMIN_WORKSPACES ) ;
598
600
@@ -606,7 +608,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
606
608
async adminForceStopWorkspace ( ctx : TraceContext , workspaceId : string ) : Promise < void > {
607
609
traceAPIParams ( ctx , { workspaceId } ) ;
608
610
609
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
611
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
610
612
611
613
await this . guardAdminAccess ( "adminForceStopWorkspace" , { id : workspaceId } , Permission . ADMIN_WORKSPACES ) ;
612
614
@@ -619,7 +621,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
619
621
async adminRestoreSoftDeletedWorkspace ( ctx : TraceContext , workspaceId : string ) : Promise < void > {
620
622
traceAPIParams ( ctx , { workspaceId } ) ;
621
623
622
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
624
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
623
625
624
626
await this . guardAdminAccess ( "adminRestoreSoftDeletedWorkspace" , { id : workspaceId } , Permission . ADMIN_WORKSPACES ) ;
625
627
@@ -643,13 +645,13 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
643
645
}
644
646
645
647
async adminGetProjectsBySearchTerm ( ctx : TraceContext , req : AdminGetListRequest < Project > ) : Promise < AdminGetListResult < Project > > {
646
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
648
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
647
649
await this . guardAdminAccess ( "adminGetProjectsBySearchTerm" , { req } , Permission . ADMIN_PROJECTS ) ;
648
650
return await this . projectDB . findProjectsBySearchTerm ( req . offset , req . limit , req . orderBy , req . orderDir === "asc" ? "ASC" : "DESC" , req . searchTerm as string ) ;
649
651
}
650
652
651
653
async adminGetProjectById ( ctx : TraceContext , id : string ) : Promise < Project | undefined > {
652
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
654
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
653
655
await this . guardAdminAccess ( "adminGetProjectById" , { id } , Permission . ADMIN_PROJECTS ) ;
654
656
return await this . projectDB . findProjectById ( id ) ;
655
657
}
@@ -800,7 +802,8 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
800
802
default :
801
803
}
802
804
if ( feature ) {
803
- return this . licenseEvaluator . isEnabled ( feature ) ;
805
+ const userCount = await this . userDB . getUserCount ( true ) ;
806
+ return this . licenseEvaluator . isEnabled ( feature , userCount ) ;
804
807
}
805
808
return false ;
806
809
}
@@ -1561,7 +1564,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl {
1561
1564
1562
1565
async adminFindPrebuilds ( ctx : TraceContext , params : FindPrebuildsParams ) : Promise < PrebuildWithStatus [ ] > {
1563
1566
traceAPIParams ( ctx , { params } ) ;
1564
- this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
1567
+ await this . requireEELicense ( Feature . FeatureAdminDashboard ) ;
1565
1568
await this . guardAdminAccess ( "adminFindPrebuilds" , { params } , Permission . ADMIN_PROJECTS ) ;
1566
1569
1567
1570
return this . projectsService . findPrebuilds ( params ) ;
0 commit comments