Module: Melodiest::Auth::Http
- Defined in:
- lib/melodiest/auth/http.rb
Overview
Instance Method Summary collapse
- #authorized!(username = "admin", password = "admin") ⇒ Object
- #authorized?(username, password) ⇒ Boolean
Instance Method Details
#authorized!(username = "admin", password = "admin") ⇒ Object
6 7 8 9 10 |
# File 'lib/melodiest/auth/http.rb', line 6 def (username="admin", password="admin") return if (username, password) headers['WWW-Authenticate'] = 'Basic realm="Restricted Area"' halt 401, "Not authorized\n" end |
#authorized?(username, password) ⇒ Boolean
12 13 14 15 |
# File 'lib/melodiest/auth/http.rb', line 12 def (username, password) @auth ||= Rack::Auth::Basic::Request.new(request.env) @auth.provided? and @auth.basic? and @auth.credentials and @auth.credentials == [username, password] end |