Class: Rack::Auth::BasicPath
- Inherits:
-
AbstractHandler
- Object
- AbstractHandler
- Rack::Auth::BasicPath
- Defined in:
- lib/basic_path.rb
Defined Under Namespace
Classes: Request
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, username, password, *paths) ⇒ BasicPath
constructor
A new instance of BasicPath.
Constructor Details
#initialize(app, username, password, *paths) ⇒ BasicPath
Returns a new instance of BasicPath.
7 8 9 10 11 12 |
# File 'lib/basic_path.rb', line 7 def initialize(app, username, password, *paths) @app = app @username = username @password = password @path_regex = Regexp.union(paths) end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/basic_path.rb', line 14 def call(env) return @app.call(env) unless env['PATH_INFO'].match(@path_regex) auth = BasicPath::Request.new(env) return unless auth.provided? return bad_request unless auth.basic? if valid?(auth) env['REMOTE_USER'] = auth.username return @app.call(env) end end |