@@ -2934,12 +2934,11 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2934
2934
organizationId : entry . organizationId ,
2935
2935
} ;
2936
2936
2937
- let team = await this . getTeam ( ctx , newProvider . organizationId || "" ) ;
2938
- if ( ! team ) {
2937
+ if ( ! newProvider . organizationId || ! uuidValidate ( newProvider . organizationId ) ) {
2939
2938
throw new ResponseError ( ErrorCodes . BAD_REQUEST , "Invalid organizationId" ) ;
2940
2939
}
2941
2940
2942
- await this . guardWithFeatureFlag ( "orgGitAuthProviders" , team ) ;
2941
+ await this . guardWithFeatureFlag ( "orgGitAuthProviders" , newProvider . organizationId ) ;
2943
2942
2944
2943
if ( ! newProvider . host ) {
2945
2944
throw new ResponseError (
@@ -2948,6 +2947,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2948
2947
) ;
2949
2948
}
2950
2949
2950
+ // Ensure user can perform this operation on this organization
2951
2951
await this . guardTeamOperation ( newProvider . organizationId , "create" ) ;
2952
2952
2953
2953
try {
@@ -2991,12 +2991,11 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2991
2991
organizationId : entry . organizationId ,
2992
2992
} ;
2993
2993
2994
- const team = await this . getTeam ( ctx , providerUpdate . organizationId || "" ) ;
2995
- if ( ! team ) {
2994
+ if ( ! providerUpdate . organizationId || ! uuidValidate ( providerUpdate . organizationId ) ) {
2996
2995
throw new ResponseError ( ErrorCodes . BAD_REQUEST , "Invalid organizationId" ) ;
2997
2996
}
2998
2997
2999
- await this . guardWithFeatureFlag ( "orgGitAuthProviders" , team ) ;
2998
+ await this . guardWithFeatureFlag ( "orgGitAuthProviders" , providerUpdate . organizationId ) ;
3000
2999
3001
3000
await this . guardTeamOperation ( providerUpdate . organizationId , "update" ) ;
3002
3001
@@ -3017,17 +3016,12 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3017
3016
3018
3017
this . checkAndBlockUser ( "getOrgAuthProviders" ) ;
3019
3018
3020
- const team = await this . getTeam ( ctx , params . organizationId || "" ) ;
3021
- if ( ! team ) {
3022
- throw new ResponseError ( ErrorCodes . BAD_REQUEST , "Invalid organizationId" ) ;
3023
- }
3024
-
3025
- await this . guardWithFeatureFlag ( "orgGitAuthProviders" , team ) ;
3019
+ await this . guardWithFeatureFlag ( "orgGitAuthProviders" , params . organizationId ) ;
3026
3020
3027
- await this . guardTeamOperation ( team . id , "get" ) ;
3021
+ await this . guardTeamOperation ( params . organizationId , "get" ) ;
3028
3022
3029
3023
try {
3030
- const result = await this . authProviderService . getAuthProvidersOfOrg ( team . id ) ;
3024
+ const result = await this . authProviderService . getAuthProvidersOfOrg ( params . organizationId ) ;
3031
3025
return result . map ( AuthProviderEntry . redact . bind ( AuthProviderEntry ) ) ;
3032
3026
} catch ( error ) {
3033
3027
const message =
@@ -3046,7 +3040,7 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3046
3040
throw new ResponseError ( ErrorCodes . BAD_REQUEST , "Invalid organizationId" ) ;
3047
3041
}
3048
3042
3049
- await this . guardWithFeatureFlag ( "orgGitAuthProviders" , team ) ;
3043
+ await this . guardWithFeatureFlag ( "orgGitAuthProviders" , team . id ) ;
3050
3044
3051
3045
// Find the matching auth provider we're attempting to delete
3052
3046
const orgProviders = await this . authProviderService . getAuthProvidersOfOrg ( team . id ) ;
@@ -3065,12 +3059,11 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
3065
3059
}
3066
3060
}
3067
3061
3068
- protected async guardWithFeatureFlag ( flagName : string , team : Team ) {
3062
+ protected async guardWithFeatureFlag ( flagName : string , teamId : string ) {
3069
3063
// Guard method w/ a feature flag check
3070
3064
const isEnabled = await this . configCatClientFactory ( ) . getValueAsync ( flagName , false , {
3071
3065
user : this . user ,
3072
- teamId : team . id ,
3073
- teamName : team . name ,
3066
+ teamId,
3074
3067
} ) ;
3075
3068
if ( ! isEnabled ) {
3076
3069
throw new ResponseError ( ErrorCodes . NOT_FOUND , "Method not available" ) ;
0 commit comments