Skip to content
Browse files

Rack::Auth::AbstractRequest#scheme returns strings

 * This is a breaking API change, but doesn't appear to be used in public
  • Loading branch information...
1 parent a13426b commit 0c76175fcccad74ba2f991c487d3669c28a297c8 @raggi raggi committed Jan 13, 2013
Showing with 3 additions and 76 deletions.
  1. +0 −12 lib/rack.rb
  2. +1 −5 lib/rack/auth/abstract/request.rb
  3. +1 −1 lib/rack/auth/basic.rb
  4. +1 −1 lib/rack/auth/digest/request.rb
  5. +0 −57 test/spec_auth.rb
View
12 lib/rack.rb
@@ -73,18 +73,6 @@ module Digest
autoload :Params, "rack/auth/digest/params"
autoload :Request, "rack/auth/digest/request"
end
-
- # Not all of the following schemes are "standards", but they are used often.
- @schemes = %w[basic digest bearer mac token oauth oauth2]
-
- def self.add_scheme scheme
- @schemes << scheme
- @schemes.uniq!
- end
-
- def self.schemes
- @schemes.dup
- end
end
module Session
View
6 lib/rack/auth/abstract/request.rb
@@ -21,11 +21,7 @@ def parts
end
def scheme
- @scheme ||=
- begin
- s = parts.first.downcase
- Rack::Auth.schemes.include?(s) ? s.to_sym : s
- end
+ @scheme ||= parts.first.downcase
end
def params
View
2 lib/rack/auth/basic.rb
@@ -41,7 +41,7 @@ def valid?(auth)
class Request < Auth::AbstractRequest
def basic?
- !parts.first.nil? && :basic == scheme
+ !parts.first.nil? && "basic" == scheme
end
def credentials
View
2 lib/rack/auth/digest/request.rb
@@ -11,7 +11,7 @@ def method
end
def digest?
- :digest == scheme
+ "digest" == scheme
end
def correct_uri?
View
57 test/spec_auth.rb
@@ -1,57 +0,0 @@
-require 'rack'
-
-describe Rack::Auth do
- it "should have all common authentication schemes" do
- Rack::Auth.schemes.should.include? 'basic'
- Rack::Auth.schemes.should.include? 'digest'
- Rack::Auth.schemes.should.include? 'bearer'
- Rack::Auth.schemes.should.include? 'token'
- end
-
- it "should allow registration of new auth schemes" do
- Rack::Auth.schemes.should.not.include "test"
- Rack::Auth.add_scheme "test"
- Rack::Auth.schemes.should.include "test"
- end
-end
-
-describe Rack::Auth::AbstractRequest do
- it "should symbolize known auth schemes" do
- env = Rack::MockRequest.env_for('/')
- env['HTTP_AUTHORIZATION'] = 'Basic aXJyZXNwb25zaWJsZQ=='
- req = Rack::Auth::AbstractRequest.new(env)
- req.scheme.should.equal :basic
-
-
- env['HTTP_AUTHORIZATION'] = 'Digest aXJyZXNwb25zaWJsZQ=='
- req = Rack::Auth::AbstractRequest.new(env)
- req.scheme.should.equal :digest
-
- env['HTTP_AUTHORIZATION'] = 'Bearer aXJyZXNwb25zaWJsZQ=='
- req = Rack::Auth::AbstractRequest.new(env)
- req.scheme.should.equal :bearer
-
- env['HTTP_AUTHORIZATION'] = 'MAC aXJyZXNwb25zaWJsZQ=='
- req = Rack::Auth::AbstractRequest.new(env)
- req.scheme.should.equal :mac
-
- env['HTTP_AUTHORIZATION'] = 'Token aXJyZXNwb25zaWJsZQ=='
- req = Rack::Auth::AbstractRequest.new(env)
- req.scheme.should.equal :token
-
- env['HTTP_AUTHORIZATION'] = 'OAuth aXJyZXNwb25zaWJsZQ=='
- req = Rack::Auth::AbstractRequest.new(env)
- req.scheme.should.equal :oauth
-
- env['HTTP_AUTHORIZATION'] = 'OAuth2 aXJyZXNwb25zaWJsZQ=='
- req = Rack::Auth::AbstractRequest.new(env)
- req.scheme.should.equal :oauth2
- end
-
- it "should not symbolize unknown auth schemes" do
- env = Rack::MockRequest.env_for('/')
- env['HTTP_AUTHORIZATION'] = 'magic aXJyZXNwb25zaWJsZQ=='
- req = Rack::Auth::AbstractRequest.new(env)
- req.scheme.should == "magic"
- end
-end

0 comments on commit 0c76175

Please sign in to comment.
Something went wrong with that request. Please try again.