diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-01 12:09:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-01 12:09:24 +0300 |
commit | a7704bf16a51a8c993215a69db17232e3f246b8e (patch) | |
tree | f0dc5c1d33e5a898d5340912548057fee3b72e43 /lib/gitlab/middleware | |
parent | 01d4c393e10ad70274aec35492bdf606a243494a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/middleware')
-rw-r--r-- | lib/gitlab/middleware/read_only/controller.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/gitlab/middleware/read_only/controller.rb b/lib/gitlab/middleware/read_only/controller.rb index 101172cdfcc..b11ee0afc10 100644 --- a/lib/gitlab/middleware/read_only/controller.rb +++ b/lib/gitlab/middleware/read_only/controller.rb @@ -9,7 +9,7 @@ module Gitlab APPLICATION_JSON_TYPES = %W{#{APPLICATION_JSON} application/vnd.git-lfs+json}.freeze ERROR_MESSAGE = 'You cannot perform write operations on a read-only instance' - ALLOWLISTED_GIT_ROUTES = { + ALLOWLISTED_GIT_READ_ONLY_ROUTES = { 'repositories/git_http' => %w{git_upload_pack} }.freeze @@ -34,7 +34,7 @@ module Gitlab end def call - if disallowed_request? && Gitlab::Database.read_only? + if disallowed_request? && read_only? Gitlab::AppLogger.debug('GitLab ReadOnly: preventing possible non read-only operation') if json_request? @@ -57,6 +57,11 @@ module Gitlab !allowlisted_routes end + # Overridden in EE module + def read_only? + Gitlab::Database.read_only? + end + def json_request? APPLICATION_JSON_TYPES.include?(request.media_type) end @@ -97,7 +102,7 @@ module Gitlab return false unless request.post? && request.path.end_with?('.git/git-upload-pack') - ALLOWLISTED_GIT_ROUTES[route_hash[:controller]]&.include?(route_hash[:action]) + ALLOWLISTED_GIT_READ_ONLY_ROUTES[route_hash[:controller]]&.include?(route_hash[:action]) end def internal_route? |