@@ -169,13 +169,7 @@ import {
169
169
ConfigCatClientFactory ,
170
170
getExperimentsClientForBackend ,
171
171
} from "@gitpod/gitpod-protocol/lib/experiments/configcat-server" ;
172
- import {
173
- Authorizer ,
174
- CheckResult ,
175
- OrganizationOperation ,
176
- NotPermitted ,
177
- PermissionChecker ,
178
- } from "../authorization/perms" ;
172
+ import { Authorizer , CheckResult , NotPermitted , PermissionChecker } from "../authorization/perms" ;
179
173
import {
180
174
ReadOrganizationMembers ,
181
175
ReadOrganizationInfo ,
@@ -210,6 +204,7 @@ import {
210
204
import { ClientError } from "nice-grpc-common" ;
211
205
import { BillingModes } from "../billing/billing-mode" ;
212
206
import { goDurationToHumanReadable } from "@gitpod/gitpod-protocol/lib/util/timeutil" ;
207
+ import { OrganizationPermission } from "../authorization/definitions" ;
213
208
214
209
// shortcut
215
210
export const traceWI = ( ctx : TraceContext , wi : Omit < LogContext , "userId" > ) => TraceContext . setOWI ( ctx , wi ) ; // userId is already taken care of in WebsocketConnectionManager
@@ -2662,7 +2657,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2662
2657
protected async guardTeamOperation (
2663
2658
teamId : string ,
2664
2659
op : ResourceAccessOp ,
2665
- fineGrainedOp : OrganizationOperation ,
2660
+ fineGrainedOp : OrganizationPermission | "not_implemented" ,
2666
2661
) : Promise < { team : Team ; members : TeamMemberInfo [ ] } > {
2667
2662
if ( ! uuidValidate ( teamId ) ) {
2668
2663
throw new ResponseError ( ErrorCodes . BAD_REQUEST , "organization ID must be a valid UUID" ) ;
@@ -2693,7 +2688,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2693
2688
} ;
2694
2689
2695
2690
const checkWithCentralizedPerms = async ( ) : Promise < CheckResult > => {
2696
- if ( centralizedPermissionsEnabled ) {
2691
+ if ( centralizedPermissionsEnabled && fineGrainedOp !== "not_implemented" ) {
2697
2692
log . info ( "[perms] Checking team operations." , {
2698
2693
org : teamId ,
2699
2694
operations : fineGrainedOp ,
@@ -2746,19 +2741,19 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2746
2741
2747
2742
protected async guardOrganizationOperationWithCentralizedPerms (
2748
2743
orgId : string ,
2749
- op : OrganizationOperation ,
2744
+ op : OrganizationPermission ,
2750
2745
) : Promise < CheckResult > {
2751
2746
const user = await this . checkUser ( ) ;
2752
2747
2753
2748
switch ( op ) {
2754
- case "org_metadata_read " :
2749
+ case "read_info " :
2755
2750
return await this . authorizer . check ( ReadOrganizationInfo ( user . id , orgId ) ) ;
2756
- case "org_metadata_write " :
2751
+ case "write_info " :
2757
2752
return await this . authorizer . check ( WriteOrganizationInfo ( user . id , orgId ) ) ;
2758
2753
2759
- case "org_members_read " :
2754
+ case "read_members " :
2760
2755
return await this . authorizer . check ( ReadOrganizationMembers ( user . id , orgId ) ) ;
2761
- case "org_members_write " :
2756
+ case "write_members " :
2762
2757
return await this . authorizer . check ( WriteOrganizationMembers ( user . id , orgId ) ) ;
2763
2758
2764
2759
default :
@@ -2777,15 +2772,15 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2777
2772
2778
2773
await this . checkAndBlockUser ( "getTeam" ) ;
2779
2774
2780
- const { team } = await this . guardTeamOperation ( teamId , "get" , "org_members_read " ) ;
2775
+ const { team } = await this . guardTeamOperation ( teamId , "get" , "read_info " ) ;
2781
2776
return team ;
2782
2777
}
2783
2778
2784
2779
public async updateTeam ( ctx : TraceContext , teamId : string , team : Pick < Team , "name" > ) : Promise < Team > {
2785
2780
traceAPIParams ( ctx , { teamId } ) ;
2786
2781
await this . checkUser ( "updateTeam" ) ;
2787
2782
2788
- await this . guardTeamOperation ( teamId , "update" , "org_metadata_write " ) ;
2783
+ await this . guardTeamOperation ( teamId , "update" , "write_info " ) ;
2789
2784
2790
2785
const updatedTeam = await this . teamDB . updateTeam ( teamId , team ) ;
2791
2786
return updatedTeam ;
@@ -2795,7 +2790,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2795
2790
traceAPIParams ( ctx , { teamId } ) ;
2796
2791
2797
2792
await this . checkUser ( "getTeamMembers" ) ;
2798
- const { members } = await this . guardTeamOperation ( teamId , "get" , "org_members_read " ) ;
2793
+ const { members } = await this . guardTeamOperation ( teamId , "get" , "read_members " ) ;
2799
2794
2800
2795
return members ;
2801
2796
}
@@ -2904,7 +2899,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2904
2899
}
2905
2900
2906
2901
await this . checkAndBlockUser ( "setTeamMemberRole" ) ;
2907
- await this . guardTeamOperation ( teamId , "update" , "org_members_write " ) ;
2902
+ await this . guardTeamOperation ( teamId , "update" , "write_members " ) ;
2908
2903
2909
2904
await this . teamDB . setTeamMemberRole ( userId , teamId , role ) ;
2910
2905
}
@@ -2923,7 +2918,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2923
2918
if ( ! currentUserLeavingTeam ) {
2924
2919
await this . guardTeamOperation ( teamId , "update" , "not_implemented" ) ;
2925
2920
} else {
2926
- await this . guardTeamOperation ( teamId , "get" , "org_members_write " ) ;
2921
+ await this . guardTeamOperation ( teamId , "get" , "write_members " ) ;
2927
2922
}
2928
2923
2929
2924
// Check for existing membership.
@@ -2957,7 +2952,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2957
2952
traceAPIParams ( ctx , { teamId } ) ;
2958
2953
2959
2954
await this . checkUser ( "getGenericInvite" ) ;
2960
- await this . guardTeamOperation ( teamId , "get" , "org_members_write " ) ;
2955
+ await this . guardTeamOperation ( teamId , "get" , "write_members " ) ;
2961
2956
2962
2957
if ( await this . teamDB . hasActiveSSO ( teamId ) ) {
2963
2958
throw new ResponseError ( ErrorCodes . NOT_FOUND , "Invites are disabled for SSO-enabled organizations." ) ;
@@ -2974,7 +2969,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2974
2969
traceAPIParams ( ctx , { teamId } ) ;
2975
2970
2976
2971
await this . checkAndBlockUser ( "resetGenericInvite" ) ;
2977
- await this . guardTeamOperation ( teamId , "update" , "org_members_write " ) ;
2972
+ await this . guardTeamOperation ( teamId , "update" , "write_members " ) ;
2978
2973
if ( await this . teamDB . hasActiveSSO ( teamId ) ) {
2979
2974
throw new ResponseError ( ErrorCodes . NOT_FOUND , "Invites are disabled for SSO-enabled organizations." ) ;
2980
2975
}
@@ -3017,7 +3012,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3017
3012
const user = await this . checkAndBlockUser ( "deleteTeam" ) ;
3018
3013
traceAPIParams ( ctx , { teamId, userId : user . id } ) ;
3019
3014
3020
- await this . guardTeamOperation ( teamId , "delete" , "org_write " ) ;
3015
+ await this . guardTeamOperation ( teamId , "delete" , "not_implemented " ) ;
3021
3016
3022
3017
const teamProjects = await this . projectsService . getTeamProjects ( teamId ) ;
3023
3018
teamProjects . forEach ( ( project ) => {
@@ -3048,7 +3043,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3048
3043
async getOrgSettings ( ctx : TraceContextWithSpan , orgId : string ) : Promise < OrganizationSettings > {
3049
3044
const user = await this . checkAndBlockUser ( "getOrgSettings" ) ;
3050
3045
traceAPIParams ( ctx , { orgId, userId : user . id } ) ;
3051
- await this . guardTeamOperation ( orgId , "get" , "org_write " ) ;
3046
+ await this . guardTeamOperation ( orgId , "get" , "not_implemented " ) ;
3052
3047
const settings = await this . teamDB . findOrgSettings ( orgId ) ;
3053
3048
// TODO: make a default in protocol
3054
3049
return settings ?? { workspaceSharingDisabled : false } ;
@@ -3061,7 +3056,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3061
3056
) : Promise < OrganizationSettings > {
3062
3057
const user = await this . checkAndBlockUser ( "updateOrgSettings" ) ;
3063
3058
traceAPIParams ( ctx , { orgId, userId : user . id } ) ;
3064
- await this . guardTeamOperation ( orgId , "update" , "org_write " ) ;
3059
+ await this . guardTeamOperation ( orgId , "update" , "not_implemented " ) ;
3065
3060
await this . teamDB . setOrgSettings ( orgId , settings ) ;
3066
3061
return ( await this . teamDB . findOrgSettings ( orgId ) ) ! ;
3067
3062
}
@@ -3757,7 +3752,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3757
3752
}
3758
3753
3759
3754
// Ensure user can perform this operation on this organization
3760
- await this . guardTeamOperation ( newProvider . organizationId , "update" , "org_authprovider_write " ) ;
3755
+ await this . guardTeamOperation ( newProvider . organizationId , "update" , "not_implemented " ) ;
3761
3756
3762
3757
try {
3763
3758
// on creating we're are checking for already existing runtime providers
@@ -3805,7 +3800,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3805
3800
3806
3801
await this . guardWithFeatureFlag ( "orgGitAuthProviders" , user , providerUpdate . organizationId ) ;
3807
3802
3808
- await this . guardTeamOperation ( providerUpdate . organizationId , "update" , "org_authprovider_write " ) ;
3803
+ await this . guardTeamOperation ( providerUpdate . organizationId , "update" , "not_implemented " ) ;
3809
3804
3810
3805
try {
3811
3806
const result = await this . authProviderService . updateOrgAuthProvider ( providerUpdate ) ;
@@ -3826,7 +3821,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3826
3821
3827
3822
await this . guardWithFeatureFlag ( "orgGitAuthProviders" , user , params . organizationId ) ;
3828
3823
3829
- await this . guardTeamOperation ( params . organizationId , "get" , "org_authprovider_read " ) ;
3824
+ await this . guardTeamOperation ( params . organizationId , "get" , "not_implemented " ) ;
3830
3825
3831
3826
try {
3832
3827
const result = await this . authProviderService . getAuthProvidersOfOrg ( params . organizationId ) ;
@@ -3857,7 +3852,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3857
3852
throw new ResponseError ( ErrorCodes . NOT_FOUND , "Provider resource not found." ) ;
3858
3853
}
3859
3854
3860
- await this . guardTeamOperation ( authProvider . organizationId || "" , "update" , "org_authprovider_write " ) ;
3855
+ await this . guardTeamOperation ( authProvider . organizationId || "" , "update" , "not_implemented " ) ;
3861
3856
3862
3857
try {
3863
3858
await this . authProviderService . deleteAuthProvider ( authProvider ) ;
0 commit comments