diff options
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 |