@@ -2922,29 +2922,25 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2922
2922
) : Promise < AuthProviderEntry > {
2923
2923
traceAPIParams ( ctx , { } ) ; // entry contains PII
2924
2924
2925
+ let user = this . checkAndBlockUser ( "createOrgAuthProvider" ) ;
2926
+
2925
2927
// map params to a new provider
2926
2928
const newProvider = < AuthProviderEntry . NewEntry > {
2927
2929
host : entry . host ,
2928
2930
type : entry . type ,
2929
2931
clientId : entry . clientId ,
2930
2932
clientSecret : entry . clientSecret ,
2931
- ownerId : entry . ownerId ,
2933
+ ownerId : user . id ,
2932
2934
organizationId : entry . organizationId ,
2933
2935
} ;
2934
2936
2935
- let user = this . checkAndBlockUser ( "createOrgAuthProvider" ) ;
2936
2937
let team = await this . getTeam ( ctx , newProvider . organizationId || "" ) ;
2937
2938
if ( ! team ) {
2938
2939
throw new ResponseError ( ErrorCodes . BAD_REQUEST , "Invalid organizationId" ) ;
2939
2940
}
2940
2941
2941
2942
await this . guardWithFeatureFlag ( "orgGitAuthProviders" , team ) ;
2942
2943
2943
- // Since this is a create, ensure they're not creating it as someone else
2944
- if ( user . id !== newProvider . ownerId ) {
2945
- throw new ResponseError ( ErrorCodes . BAD_REQUEST , "Cannot create an auth provider for another owner." ) ;
2946
- }
2947
-
2948
2944
if ( ! newProvider . host ) {
2949
2945
throw new ResponseError (
2950
2946
ErrorCodes . BAD_REQUEST ,
@@ -2984,28 +2980,24 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable {
2984
2980
) : Promise < AuthProviderEntry > {
2985
2981
traceAPIParams ( ctx , { } ) ; // entry contains PII
2986
2982
2983
+ const user = this . checkAndBlockUser ( "updateOrgAuthProvider" ) ;
2984
+
2987
2985
// map params to a provider update
2988
2986
const providerUpdate : AuthProviderEntry . UpdateEntry = {
2989
2987
id : entry . id ,
2988
+ ownerId : user . id ,
2990
2989
clientId : entry . clientId ,
2991
2990
clientSecret : entry . clientSecret ,
2992
- ownerId : entry . ownerId ,
2993
2991
organizationId : entry . organizationId ,
2994
2992
} ;
2995
2993
2996
- const user = this . checkAndBlockUser ( "updateOrgAuthProvider" ) ;
2997
2994
const team = await this . getTeam ( ctx , providerUpdate . organizationId || "" ) ;
2998
2995
if ( ! team ) {
2999
2996
throw new ResponseError ( ErrorCodes . BAD_REQUEST , "Invalid organizationId" ) ;
3000
2997
}
3001
2998
3002
2999
await this . guardWithFeatureFlag ( "orgGitAuthProviders" , team ) ;
3003
3000
3004
- // TODO: What do we want to enforce here for updates? That ownerId is set to last user who updated it, or creator?
3005
- if ( user . id !== providerUpdate . ownerId ) {
3006
- throw new ResponseError ( ErrorCodes . BAD_REQUEST , "Cannot update an auth provider for another owner." ) ;
3007
- }
3008
-
3009
3001
await this . guardTeamOperation ( providerUpdate . organizationId , "update" ) ;
3010
3002
3011
3003
try {
0 commit comments