Avoid instance variable re-use trouble

This is the quickest/dumbest/safest way I could think of to prevent
the instance variable reuse problems we have on dev.gitlab.org now.
This commit is contained in:
Jacob Vosmaer 2015-09-02 18:47:56 +02:00
parent 308c6428ae
commit 30bf2b9cc3
2 changed files with 9 additions and 1 deletions

View File

@ -30,7 +30,7 @@ Gitlab::Application.routes.draw do
end
# Enable Grack support
mount Grack::Auth.new({}), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]
mount Grack::AuthSpawner, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]
# Help
get 'help' => 'help#index'

View File

@ -1,6 +1,14 @@
require_relative 'shell_env'
module Grack
class AuthSpawner
def self.call(env)
# Avoid issues with instance variables in Grack::Auth persisting across
# requests by creating a new instance for each request.
Auth.new({}).call(env)
end
end
class Auth < Rack::Auth::Basic
attr_accessor :user, :project, :env