summaryrefslogtreecommitdiff
path: root/lib/gitlab/git_access.rb
diff options
context:
space:
mode:
authorPatricio Cano <suprnova32@gmail.com>2016-06-22 13:03:24 -0500
committerPatricio Cano <suprnova32@gmail.com>2016-07-05 16:54:22 -0500
commit8b14d1d2c20a5b8c7ef985007f90fd3aa12c3277 (patch)
tree8feea6564958e689d056ba5e483a1369c06f51cb /lib/gitlab/git_access.rb
parent7735ef86f0714a5b2a4cb4db8ec0471654563885 (diff)
downloadgitlab-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/gitlab/git_access.rb')
-rw-r--r--lib/gitlab/git_access.rb14
1 files changed, 4 insertions, 10 deletions
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)