9557224648c2ee94cb38fc96d7a1354015f8b5ec
1 require 'rack/auth/abstract/handler'
2 require 'rack/auth/abstract/request'
6 # Rack::Auth::Basic implements HTTP Basic Authentication, as per RFC 2617.
8 # Initialize with the Rack application that you want protecting,
9 # and a block that checks if a username and password pair are valid.
11 # See also: <tt>example/protectedlobster.rb</tt>
13 class Basic
< AbstractHandler
16 auth
= Basic
::Request.new(env)
18 return unauthorized
unless auth
.provided
?
20 return bad_request
unless auth
.basic
?
23 env['REMOTE_USER'] = auth
.username
35 'Basic realm="%s"' % realm
39 @authenticator.call(*auth
.credentials
)
42 class Request
< Auth
::AbstractRequest
48 @credentials ||= params
.unpack("m*").first
.split(/:/, 2)