public
Fork of bmizerany/sinatra
Description: Classy web-development dressed in a DSL
Homepage: http://sinatrarb.com
Clone URL: git://github.com/Chrononaut/sinatra.git
Some refactoring for HTTP Auth, makes use of Rack
Chrononaut (author)
Sat May 03 07:05:00 -0700 2008
commit  4382a49b33f65b7e6367785d58b8cf4bddfcee51
tree    7d860ce33b5c2eafb8f57fe9255105d188e24d2d
parent  c0fa3049a96abbceb6f41d7472e3b2aa30370890
...
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
 
 
627
628
629
630
631
632
633
634
635
636
 
 
 
637
638
639
...
605
606
607
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
608
609
610
611
612
 
 
 
 
 
 
 
613
614
615
616
617
618
0
@@ -605,35 +605,14 @@ module Sinatra
0
       end
0
       
0
       def authenticate_with_http_basic(&login_procedure)
0
- def authenticate(&login_procedure)
0
- def authorization
0
- request.env['HTTP_AUTHORIZATION'] ||
0
- request.env['X-HTTP_AUTHORIZATION'] ||
0
- request.env['X_HTTP_AUTHORIZATION'] ||
0
- request.env['REDIRECT_X_HTTP_AUTHORIZATION']
0
- end
0
-
0
- # Decodes credentials (Base64)
0
- def user_name_and_password
0
- (authorization.split.last || '').unpack("m")[0].split(/:/, 2)
0
- end
0
-
0
- if authorization
0
- login_procedure.call(*user_name_and_password)
0
- end
0
- end
0
-
0
- authenticate(&login_procedure)
0
+ auth = Rack::Auth::Basic::Request.new(request.env)
0
+ login_procedure.call(*auth.credentials) if auth.provided? && auth.basic?
0
       end
0
       
0
       def request_http_basic_authentication(realm = "Application")
0
- def authentication_request(realm)
0
- status(401)
0
- header("WWW-Authenticate" => %(Basic realm="#{realm.gsub(/"/, "")}"))
0
- throw :halt, "HTTP Basic: Access denied.\n"
0
- end
0
-
0
- authentication_request(realm)
0
+ status(401)
0
+ header("WWW-Authenticate" => 'Basic realm="%s"' % realm)
0
+ throw :halt, "HTTP Basic: Access denied.\n"
0
       end
0
       
0
     end

Comments

    No one has commented yet.