diff options
Diffstat (limited to 'lib/gitlab/middleware/read_only/controller.rb')
-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? |