Class: Boxlet::Handlers::Auth
- Inherits:
-
Object
- Object
- Boxlet::Handlers::Auth
- Defined in:
- lib/handlers/auth.rb
Defined Under Namespace
Classes: Request
Instance Method Summary collapse
- #authorize(request) ⇒ Object
-
#initialize(username, password) ⇒ Auth
constructor
A new instance of Auth.
Constructor Details
#initialize(username, password) ⇒ Auth
Returns a new instance of Auth.
4 5 6 7 8 |
# File 'lib/handlers/auth.rb', line 4 def initialize(username, password) @username = username @password = password @realm = "Boxlet" end |
Instance Method Details
#authorize(request) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/handlers/auth.rb', line 10 def (request) @auth = Request.new(request.env) return unless @auth.provided? return bad_request unless @auth.basic? if valid?(@username, @password) headers = {'REMOTE_USER' => @username} [200, headers, yield] else end end |