summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Kozono <mkozono@gmail.com>2017-05-22 11:28:51 -0700
committerMichael Kozono <mkozono@gmail.com>2017-06-05 05:32:26 -0700
commite8972c11904c31fc614a31483098814adc38c2ac (patch)
tree9be9df9741598627ff8ac89a934ec23ef878d3d8 /lib
parent23d37382dabe3f7c7f2e11df2731de8e939e0cab (diff)
downloadgitlab-ce-e8972c11904c31fc614a31483098814adc38c2ac.tar.gz
Clarify error messages
And refactor to self-document a little better.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git_access.rb34
1 files changed, 26 insertions, 8 deletions
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index f43359d7dbd..176b0991971 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -14,8 +14,8 @@ module Gitlab
project_not_found: 'The project you were looking for could not be found.',
account_blocked: 'Your account has been blocked.',
command_not_allowed: "The command you're trying to execute is not allowed.",
- upload_pack_disabled_in_config: 'The command "git-upload-pack" is not allowed.',
- receive_pack_disabled_in_config: 'The command "git-receive-pack" is not allowed.'
+ upload_pack_disabled_over_http: 'Pulling over HTTP is not allowed.',
+ receive_pack_disabled_over_http: 'Pushing over HTTP is not allowed.'
}.freeze
DOWNLOAD_COMMANDS = %w{ git-upload-pack git-upload-archive }.freeze
@@ -94,12 +94,22 @@ module Gitlab
end
def check_command_disabled!(cmd)
- if http?
- if upload_pack?(cmd) && !Gitlab.config.gitlab_shell.upload_pack
- raise UnauthorizedError, ERROR_MESSAGES[:upload_pack_disabled_in_config]
- elsif receive_pack?(cmd) && !Gitlab.config.gitlab_shell.receive_pack
- raise UnauthorizedError, ERROR_MESSAGES[:receive_pack_disabled_in_config]
- end
+ if upload_pack?(cmd)
+ check_upload_pack_disabled!
+ elsif receive_pack?(cmd)
+ check_receive_pack_disabled!
+ end
+ end
+
+ def check_upload_pack_disabled!
+ if http? && upload_pack_disabled_over_http?
+ raise UnauthorizedError, ERROR_MESSAGES[:upload_pack_disabled_over_http]
+ end
+ end
+
+ def check_receive_pack_disabled!
+ if http? && receive_pack_disabled_over_http?
+ raise UnauthorizedError, ERROR_MESSAGES[:receive_pack_disabled_over_http]
end
end
@@ -215,6 +225,14 @@ module Gitlab
command == 'git-receive-pack'
end
+ def upload_pack_disabled_over_http?
+ !Gitlab.config.gitlab_shell.upload_pack
+ end
+
+ def receive_pack_disabled_over_http?
+ !Gitlab.config.gitlab_shell.receive_pack
+ end
+
protected
def user