Class: Egalite::Auth::Basic
Class Method Summary collapse
Class Method Details
.authorize(req, realm) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/egalite/auth/basic.rb', line 5 def self.(req,realm) auth = req. return (realm) if auth.blank? (method,credentials) = auth.split(' ', 2) return bad_request if method.downcase != "basic" (username,password) = credentials.unpack("m*").first.split(/:/,2) return (realm) unless yield(username,password) true end |
.bad_request ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/egalite/auth/basic.rb', line 22 def self.bad_request return [ 400, { 'Content-Type' => 'text/plain', 'Content-Length' => '0' }, [] ] end |
.unauthorized(realm) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/egalite/auth/basic.rb', line 14 def self.(realm) return [ 401, { 'Content-Type' => 'text/plain', 'Content-Length' => '0', 'WWW-Authenticate' => 'Basic realm="%s"' % realm }, [] ] end |