Commit aaa916f15c9bde139058888be660705390cc02db
1 parent
b5442eb5
Exists in
master
and in
4 other branches
use high level api and compatibility with Passenger
Showing
1 changed file
with
8 additions
and
7 deletions
Show diff stats
lib/gitlab/backend/grack_auth.rb
@@ -12,21 +12,22 @@ module Grack | @@ -12,21 +12,22 @@ module Grack | ||
12 | # Pass Gitolite update hook | 12 | # Pass Gitolite update hook |
13 | ENV['GL_BYPASS_UPDATE_HOOK'] = "true" | 13 | ENV['GL_BYPASS_UPDATE_HOOK'] = "true" |
14 | 14 | ||
15 | - # Need this patch because the rails mount | ||
16 | - @env['PATH_INFO'] = @env['REQUEST_PATH'] | 15 | + # Need this patch due to the rails mount |
16 | + @env['PATH_INFO'] = @request.path | ||
17 | + @env['SCRIPT_NAME'] = "" | ||
17 | 18 | ||
18 | # Find project by PATH_INFO from env | 19 | # Find project by PATH_INFO from env |
19 | - if m = /^\/([\w-]+).git/.match(@env['PATH_INFO']).to_a | 20 | + if m = /^\/([\w-]+).git/.match(@request.path_info).to_a |
20 | return false unless project = Project.find_by_path(m.last) | 21 | return false unless project = Project.find_by_path(m.last) |
21 | end | 22 | end |
22 | 23 | ||
23 | # Git upload and receive | 24 | # Git upload and receive |
24 | - if @env['REQUEST_METHOD'] == 'GET' | 25 | + if @request.get? |
25 | true | 26 | true |
26 | - elsif @env['REQUEST_METHOD'] == 'POST' | ||
27 | - if @env['REQUEST_URI'].end_with?('git-upload-pack') | 27 | + elsif @request.post? |
28 | + if @request.path_info.end_with?('git-upload-pack') | ||
28 | return project.dev_access_for?(user) | 29 | return project.dev_access_for?(user) |
29 | - elsif @env['REQUEST_URI'].end_with?('git-receive-pack') | 30 | + elsif @request.path_info.end_with?('git-receive-pack') |
30 | if project.protected_branches.map(&:name).include?(current_ref) | 31 | if project.protected_branches.map(&:name).include?(current_ref) |
31 | project.master_access_for?(user) | 32 | project.master_access_for?(user) |
32 | else | 33 | else |