Commit aaa916f15c9bde139058888be660705390cc02db

Authored by Saito
1 parent b5442eb5

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 12 # Pass Gitolite update hook
13 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 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 21 return false unless project = Project.find_by_path(m.last)
21 22 end
22 23  
23 24 # Git upload and receive
24   - if @env['REQUEST_METHOD'] == 'GET'
  25 + if @request.get?
25 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 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 31 if project.protected_branches.map(&:name).include?(current_ref)
31 32 project.master_access_for?(user)
32 33 else
... ...