Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorDylan Griffith <dyl.griffith@gmail.com>2018-05-09 17:41:15 +0300
committerDylan Griffith <dyl.griffith@gmail.com>2018-05-16 11:52:28 +0300
commit7320684c00ada153c0a9b102f8cf2db38367129a (patch)
tree919384d543fa667fa7ee29c368d8c5e043c34426 /lib/api
parent846f73b53b8a6d3bc1f18607630d7a7853cb9d13 (diff)
Use can? policies for lib/api/runners.rb
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/runners.rb14
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb
index 1b528a8490c..db9cff80cf9 100644
--- a/lib/api/runners.rb
+++ b/lib/api/runners.rb
@@ -184,14 +184,14 @@ module API
def authenticate_show_runner!(runner)
return if runner.is_shared || current_user.admin?
- forbidden!("No access granted") unless user_can_access_runner?(runner)
+ forbidden!("No access granted") unless can?(current_user, :read_runner, runner)
end
def authenticate_update_runner!(runner)
return if current_user.admin?
forbidden!("Runner is shared") if runner.is_shared?
- forbidden!("No access granted") unless user_can_access_runner?(runner)
+ forbidden!("No access granted") unless can?(current_user, :update_runner, runner)
end
def authenticate_delete_runner!(runner)
@@ -199,7 +199,7 @@ module API
forbidden!("Runner is shared") if runner.is_shared?
forbidden!("Runner associated with more than one project") if runner.projects.count > 1
- forbidden!("No access granted") unless user_can_access_runner?(runner)
+ forbidden!("No access granted") unless can?(current_user, :delete_runner, runner)
end
def authenticate_enable_runner!(runner)
@@ -208,17 +208,13 @@ module API
forbidden!("Runner is a group runner") if runner.group_type?
return if current_user.admin?
- forbidden!("No access granted") unless user_can_access_runner?(runner)
+ forbidden!("No access granted") unless can?(current_user, :assign_runner, runner)
end
def authenticate_list_runners_jobs!(runner)
return if current_user.admin?
- forbidden!("No access granted") unless user_can_access_runner?(runner)
- end
-
- def user_can_access_runner?(runner)
- current_user.ci_authorized_runners.exists?(runner.id)
+ forbidden!("No access granted") unless can?(current_user, :list_runner_jobs, runner)
end
end
end