diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-06-22 13:03:24 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-07-05 16:54:22 -0500 |
commit | 8b14d1d2c20a5b8c7ef985007f90fd3aa12c3277 (patch) | |
tree | 8feea6564958e689d056ba5e483a1369c06f51cb /lib | |
parent | 7735ef86f0714a5b2a4cb4db8ec0471654563885 (diff) | |
download | gitlab-ce-8b14d1d2c20a5b8c7ef985007f90fd3aa12c3277.tar.gz |
Rename ENV['PROTOCOL'] to ENV['GL_PROTOCOL'] to conform to what GitLab Shell expects and make the `protocol` param in `GitAccess` mandatory.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/git/hook.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/git_access.rb | 14 |
2 files changed, 5 insertions, 11 deletions
diff --git a/lib/gitlab/git/hook.rb b/lib/gitlab/git/hook.rb index 0b61c8bf332..125240c8a8b 100644 --- a/lib/gitlab/git/hook.rb +++ b/lib/gitlab/git/hook.rb @@ -35,7 +35,7 @@ module Gitlab vars = { 'GL_ID' => gl_id, 'PWD' => repo_path, - 'PROTOCOL' => 'web' + 'GL_PROTOCOL' => 'web' } options = { diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 7aec650d1a1..d5f2713e935 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -5,7 +5,7 @@ module Gitlab attr_reader :actor, :project, :protocol - def initialize(actor, project, protocol = nil) + def initialize(actor, project, protocol) @actor = actor @project = project @protocol = protocol @@ -50,6 +50,8 @@ module Gitlab end def check(cmd, changes = nil) + return build_status_object(false, 'Access denied due to unspecified Git access protocol') unless protocol + return build_status_object(false, "Git access over #{protocol.upcase} is not allowed") unless protocol_allowed? unless actor @@ -75,8 +77,6 @@ module Gitlab end def download_access_check - return build_status_object(false, "Git access over #{protocol.upcase} is not allowed") unless protocol_allowed? - if user user_download_access_check elsif deploy_key @@ -87,8 +87,6 @@ module Gitlab end def push_access_check(changes) - return build_status_object(false, "Git access over #{protocol.upcase} is not allowed") unless protocol_allowed? - if user user_push_access_check(changes) elsif deploy_key @@ -99,8 +97,6 @@ module Gitlab end def user_download_access_check - return build_status_object(false, "Git access over #{protocol.upcase} is not allowed") unless protocol_allowed? - unless user.can?(:download_code, project) return build_status_object(false, "You are not allowed to download code from this project.") end @@ -109,8 +105,6 @@ module Gitlab end def user_push_access_check(changes) - return build_status_object(false, "Git access over #{protocol.upcase} is not allowed") unless protocol_allowed? - if changes.blank? return build_status_object(true) end @@ -200,7 +194,7 @@ module Gitlab end def protocol_allowed? - protocol ? Gitlab::ProtocolAccess.allowed?(protocol) : true + Gitlab::ProtocolAccess.allowed?(protocol) end def branch_name(ref) |