Sha256: f6c760fefe197270cf52cd1a46c843e9f09092b4c002481bb79e691b3743fead
Contents?: true
Size: 562 Bytes
Versions: 4
Compression:
Stored size: 562 Bytes
Contents
module Melodiest module Auth # http://www.sinatrarb.com/faq.html#auth module Http def authorized!(username="admin", password="admin") return if authorized?(username, password) headers['WWW-Authenticate'] = 'Basic realm="Restricted Area"' halt 401, "Not authorized\n" end def authorized?(username, password) @auth ||= Rack::Auth::Basic::Request.new(request.env) @auth.provided? and @auth.basic? and @auth.credentials and @auth.credentials == [username, password] end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
melodiest-0.2.1 | lib/melodiest/auth/http.rb |
melodiest-0.2.0 | lib/melodiest/auth/http.rb |
melodiest-0.1.1 | lib/melodiest/auth.rb |
melodiest-0.1.0 | lib/melodiest/auth.rb |