mirror of
https://github.com/omniauth/omniauth.git
synced 2022-11-09 12:31:49 -05:00
Remove all traces of request['auth'], fix up Google Apps.
This commit is contained in:
parent
86862ea95d
commit
d3cb48af6f
8 changed files with 18 additions and 15 deletions
|
@ -35,7 +35,7 @@ module OmniAuth
|
|||
|
||||
def perform
|
||||
@response = perform_authentication(endpoint)
|
||||
request.POST['auth'] = auth_hash
|
||||
@env['rack.auth'] = auth_hash
|
||||
@env['REQUEST_METHOD'] = 'GET'
|
||||
@env['PATH_INFO'] = "#{OmniAuth.config.path_prefix}/#{name}/callback"
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ module OmniAuth
|
|||
return fail!(:password_mismatch) if request[:password_confirmation] && request[:password_confirmation] != '' && request[:password] != request[:password_confirmation]
|
||||
env['REQUEST_METHOD'] = 'GET'
|
||||
env['PATH_INFO'] = request.path + '/callback'
|
||||
request['auth'] = auth_hash(encrypt(request[:identifier], request[:password]))
|
||||
env['rack.auth'] = auth_hash(encrypt(request[:identifier], request[:password]))
|
||||
@app.call(env)
|
||||
end
|
||||
|
||||
|
|
|
@ -6,19 +6,19 @@ module OmniAuth
|
|||
|
||||
def sets_an_auth_hash
|
||||
it 'should set an auth hash' do
|
||||
last_request['auth'].should be_kind_of(Hash)
|
||||
last_request.env['rack.auth'].should be_kind_of(Hash)
|
||||
end
|
||||
end
|
||||
|
||||
def sets_provider_to(provider)
|
||||
it "should set the provider to #{provider}" do
|
||||
(last_request['auth'] || {})['provider'].should == provider
|
||||
(last_request.env['rack.auth'] || {})['provider'].should == provider
|
||||
end
|
||||
end
|
||||
|
||||
def sets_uid_to(uid)
|
||||
it "should set the UID to #{uid}" do
|
||||
(last_request['auth'] || {})['uid'].should == uid
|
||||
(last_request.env['rack.auth'] || {})['uid'].should == uid
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ describe OmniAuth::Strategies::Password, :type => :strategy do
|
|||
sets_an_auth_hash
|
||||
sets_provider_to 'password'
|
||||
it 'should set the UID to an opaque identifier' do
|
||||
uid = last_request['auth']['uid']
|
||||
uid = last_request.env['rack.auth']['uid']
|
||||
uid.should_not be_nil
|
||||
uid.should_not =~ /jerome/
|
||||
uid.should_not =~ /my password/
|
||||
|
|
|
@ -23,10 +23,7 @@ module OmniAuth
|
|||
def callback_phase
|
||||
request_token = ::OAuth::RequestToken.new(consumer, session[:oauth][name.to_sym].delete(:request_token), session[:oauth][name.to_sym].delete(:request_secret))
|
||||
@access_token = request_token.get_access_token(:oauth_verifier => request.params['oauth_verifier'])
|
||||
|
||||
request['auth'] = self.auth_hash
|
||||
|
||||
@app.call(self.env)
|
||||
super
|
||||
rescue ::OAuth::Unauthorized
|
||||
fail!(:invalid_credentials)
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ describe "OmniAuth::Strategies::OAuth" do
|
|||
use OmniAuth::Builder do
|
||||
provider :oauth, 'example.org', 'abc', 'def', :site => 'https://api.example.org'
|
||||
end
|
||||
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, [Rack::Request.new(env).params.key?('auth').to_s]] }
|
||||
run lambda { |env| [200, {'Content-Type' => 'text/plain'}, [env.key?('rack.auth').to_s]] }
|
||||
}.to_app
|
||||
end
|
||||
|
||||
|
@ -43,8 +43,8 @@ describe "OmniAuth::Strategies::OAuth" do
|
|||
end
|
||||
|
||||
it 'should exchange the request token for an access token' do
|
||||
last_request['auth']['provider'].should == 'example.org'
|
||||
last_request['auth']['extra']['access_token'].should be_kind_of(OAuth::AccessToken)
|
||||
last_request.env['rack.auth']['provider'].should == 'example.org'
|
||||
last_request.env['rack.auth']['extra']['access_token'].should be_kind_of(OAuth::AccessToken)
|
||||
end
|
||||
|
||||
it 'should call through to the master app' do
|
||||
|
|
|
@ -8,6 +8,13 @@ module OmniAuth
|
|||
super(app, store, options)
|
||||
end
|
||||
|
||||
def get_identifier
|
||||
OmniAuth::Form.build('Google Apps Authentication') do
|
||||
label_field('Google Apps Domain', 'domain')
|
||||
input_field('url', 'domain')
|
||||
end.to_response
|
||||
end
|
||||
|
||||
def identifier
|
||||
options[:domain] || request['domain']
|
||||
end
|
||||
|
|
|
@ -79,8 +79,7 @@ module OmniAuth
|
|||
openid.call(env)
|
||||
resp = env.delete('rack.openid.response')
|
||||
if resp && resp.status == :success
|
||||
request['auth'] = auth_hash(resp)
|
||||
@app.call(env)
|
||||
super
|
||||
else
|
||||
fail!(:invalid_credentials)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue