diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /lib/gitlab/middleware | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
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? |