Merge branch 'grack-auth-new-instance' into 'master'

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.

See merge request !1237
This commit is contained in:
Dmitriy Zaporozhets 2015-09-02 18:05:16 +00:00
commit d9f794a850
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