Commit 210922ff authored by Takuya Noguchi's avatar Takuya Noguchi

Refactor workhorse passthrough URL checker

- improve performance by skipping hash matching
- rename Grack with workhorse_passthrough
- add links for workhorse passthrough implementation
Signed-off-by: default avatarTakuya Noguchi <takninnovationresearch@gmail.com>
parent ceffcc4c
---
title: Refactor workhorse passthrough URL checker
merge_request: 26157
author: Takuya Noguchi
type: performance
......@@ -90,12 +90,14 @@ module Gitlab
# Overridden in EE module
def whitelisted_routes
grack_route? || internal_route? || lfs_route? || compare_git_revisions_route? || sidekiq_route? || session_route? || graphql_query?
workhorse_passthrough_route? || internal_route? || lfs_route? || compare_git_revisions_route? || sidekiq_route? || session_route? || graphql_query?
end
def grack_route?
# URL for requests passed through gitlab-workhorse to rails-web
# https://gitlab.com/gitlab-org/gitlab-workhorse/-/merge_requests/12
def workhorse_passthrough_route?
# Calling route_hash may be expensive. Only do it if we think there's a possible match
return false unless
return false unless request.post? &&
request.path.end_with?('.git/git-upload-pack', '.git/git-receive-pack')
WHITELISTED_GIT_ROUTES[route_hash[:controller]]&.include?(route_hash[:action])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment