diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-12-01 16:25:10 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-12-01 16:25:10 +0200 |
commit | 06b7907c2afe0cb0fa25f4cdef0ff470710de2f9 (patch) | |
tree | 18a11195038b46f15671eee254e88664fb5a36d6 /lib | |
parent | 30e28a7e0c458395b7a205e72a89e7d1b68571eb (diff) | |
download | gitlab-ce-06b7907c2afe0cb0fa25f4cdef0ff470710de2f9.tar.gz |
Fix deploy keys permission check in internal api
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git_access.rb | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 3452240dad8..5f8cb19efdf 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -8,15 +8,7 @@ module Gitlab def check(actor, cmd, project, changes = nil) case cmd when *DOWNLOAD_COMMANDS - if actor.is_a? User - download_access_check(actor, project) - elsif actor.is_a? DeployKey - actor.projects.include?(project) - elsif actor.is_a? Key - download_access_check(actor.user, project) - else - raise 'Wrong actor' - end + download_access_check(actor, project) when *PUSH_COMMANDS if actor.is_a? User push_access_check(actor, project, changes) @@ -32,7 +24,23 @@ module Gitlab end end - def download_access_check(user, project) + def download_access_check(actor, project) + if actor.is_a?(User) + user_download_access_check(actor, project) + elsif actor.is_a?(DeployKey) + if actor.projects.include?(project) + build_status_object(true) + else + build_status_object(false, "Deploy key not allowed to access this project") + end + elsif actor.is_a? Key + user_download_access_check(actor.user, project) + else + raise 'Wrong actor' + end + end + + def user_download_access_check(user, project) if user && user_allowed?(user) && user.can?(:download_code, project) build_status_object(true) else |