-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Rack::Auth.add_scheme to enable folks to fix anything that breaks * Add common auth schemes, MS ones, AWS ones, etc are missing, as unlikely * Checked Rails - they don't use our authorization code * Checked Warden - uses rails * Checked Omniauth - uses rails * Checked doorkeeper - users rails * Checked rack-authentication - does it's own thing * Checked warden-oauth - doesn't do headers * Checked devise - uses rails * Checked oauth2-rack - header creation only * Checked rack-oauth2-server - does it's own thing * Probably missed a bunch, but that'll have to do
- Loading branch information
Showing
3 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
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 == :basic | ||
|
||
|
||
env['HTTP_AUTHORIZATION'] = 'Digest aXJyZXNwb25zaWJsZQ==' | ||
req = Rack::Auth::AbstractRequest.new(env) | ||
req.scheme.should == :digest | ||
|
||
env['HTTP_AUTHORIZATION'] = 'Bearer aXJyZXNwb25zaWJsZQ==' | ||
req = Rack::Auth::AbstractRequest.new(env) | ||
req.scheme.should == :bearer | ||
|
||
env['HTTP_AUTHORIZATION'] = 'MAC aXJyZXNwb25zaWJsZQ==' | ||
req = Rack::Auth::AbstractRequest.new(env) | ||
req.scheme.should == :mac | ||
|
||
env['HTTP_AUTHORIZATION'] = 'Token aXJyZXNwb25zaWJsZQ==' | ||
req = Rack::Auth::AbstractRequest.new(env) | ||
req.scheme.should == :token | ||
|
||
env['HTTP_AUTHORIZATION'] = 'OAuth aXJyZXNwb25zaWJsZQ==' | ||
req = Rack::Auth::AbstractRequest.new(env) | ||
req.scheme.should == :oauth | ||
|
||
env['HTTP_AUTHORIZATION'] = 'OAuth2 aXJyZXNwb25zaWJsZQ==' | ||
req = Rack::Auth::AbstractRequest.new(env) | ||
req.scheme.should == :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 |