diff options
author | Ash McKenzie <amckenzie@gitlab.com> | 2019-01-16 15:10:12 +1100 |
---|---|---|
committer | Ash McKenzie <amckenzie@gitlab.com> | 2019-01-16 19:14:46 +1100 |
commit | 61111d4c0d0bbe232a983611a86607af6d9e9a66 (patch) | |
tree | ba80e4f4b34cb9dc4cc32b925675800ea205a279 | |
parent | c0a5b628c896d59691b3d3a3a050d53d8a49f729 (diff) | |
download | gitlab-ce-61111d4c0d0bbe232a983611a86607af6d9e9a66.tar.gz |
Bang up predicate methods and use #internal_route?
Extract internal route logic check out into #internal_route?
Add ? to #grack_route and #lfs_route predicate methods
-rw-r--r-- | lib/gitlab/middleware/read_only/controller.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/gitlab/middleware/read_only/controller.rb b/lib/gitlab/middleware/read_only/controller.rb index e97f22d8315..817db12ac55 100644 --- a/lib/gitlab/middleware/read_only/controller.rb +++ b/lib/gitlab/middleware/read_only/controller.rb @@ -77,10 +77,10 @@ module Gitlab # Overridden in EE module def whitelisted_routes - grack_route || ReadOnly.internal_routes.any? { |path| request.path.include?(path) } || lfs_route || sidekiq_route? + grack_route? || internal_route? || lfs_route? || sidekiq_route? end - def grack_route + def grack_route? # Calling route_hash may be expensive. Only do it if we think there's a possible match return false unless request.path.end_with?('.git/git-upload-pack', '.git/git-receive-pack') @@ -88,7 +88,11 @@ module Gitlab WHITELISTED_GIT_ROUTES[route_hash[:controller]]&.include?(route_hash[:action]) end - def lfs_route + def internal_route? + ReadOnly.internal_routes.any? { |path| request.path.include?(path) } + end + + def lfs_route? # Calling route_hash may be expensive. Only do it if we think there's a possible match unless request.path.end_with?('/info/lfs/objects/batch', '/info/lfs/locks', '/info/lfs/locks/verify') || |