diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2019-01-09 02:35:54 +0300 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2019-01-11 03:20:04 +0300 |
commit | 8b2fe985ddf29a490fef0fc2b76d6a6ac2d566fd (patch) | |
tree | f7eb12962d01b81fafa3e2450b90763f46f6b5b4 /lib | |
parent | a0f77090854b3510543dc42529d7353adab03da0 (diff) |
Restrict multiple clusters through API
Modifies authorize! method to accept a third param, and then use it in
combination with 'add_cluster' policy to appropriately restrict adding
multiple clusters
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56110
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/helpers.rb | 4 | ||||
-rw-r--r-- | lib/api/project_clusters.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 74927b4db81..fa6c9777824 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -235,8 +235,8 @@ module API forbidden! unless current_user.admin? end - def authorize!(action, subject = :global) - forbidden! unless can?(current_user, action, subject) + def authorize!(action, subject = :global, reason = nil) + forbidden!(reason) unless can?(current_user, action, subject) end def authorize_push_project diff --git a/lib/api/project_clusters.rb b/lib/api/project_clusters.rb index 7aada260297..c96261a7b57 100644 --- a/lib/api/project_clusters.rb +++ b/lib/api/project_clusters.rb @@ -63,7 +63,7 @@ module API use :create_params_ee end post ':id/clusters/user' do - authorize! :create_cluster, user_project + authorize! :add_cluster, user_project, 'Instance does not support multiple Kubernetes clusters' user_cluster = ::Clusters::CreateService .new(current_user, create_cluster_user_params) |