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
|
def perform
|
||||||
@response = perform_authentication(endpoint)
|
@response = perform_authentication(endpoint)
|
||||||
request.POST['auth'] = auth_hash
|
@env['rack.auth'] = auth_hash
|
||||||
@env['REQUEST_METHOD'] = 'GET'
|
@env['REQUEST_METHOD'] = 'GET'
|
||||||
@env['PATH_INFO'] = "#{OmniAuth.config.path_prefix}/#{name}/callback"
|
@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]
|
return fail!(:password_mismatch) if request[:password_confirmation] && request[:password_confirmation] != '' && request[:password] != request[:password_confirmation]
|
||||||
env['REQUEST_METHOD'] = 'GET'
|
env['REQUEST_METHOD'] = 'GET'
|
||||||
env['PATH_INFO'] = request.path + '/callback'
|
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)
|
@app.call(env)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,19 @@ module OmniAuth
|
||||||
|
|
||||||
def sets_an_auth_hash
|
def sets_an_auth_hash
|
||||||
it 'should set an auth hash' do
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
def sets_provider_to(provider)
|
def sets_provider_to(provider)
|
||||||
it "should set the provider to #{provider}" do
|
it "should set the provider to #{provider}" do
|
||||||
(last_request['auth'] || {})['provider'].should == provider
|
(last_request.env['rack.auth'] || {})['provider'].should == provider
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def sets_uid_to(uid)
|
def sets_uid_to(uid)
|
||||||
it "should set the UID to #{uid}" do
|
it "should set the UID to #{uid}" do
|
||||||
(last_request['auth'] || {})['uid'].should == uid
|
(last_request.env['rack.auth'] || {})['uid'].should == uid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe OmniAuth::Strategies::Password, :type => :strategy do
|
||||||
sets_an_auth_hash
|
sets_an_auth_hash
|
||||||
sets_provider_to 'password'
|
sets_provider_to 'password'
|
||||||
it 'should set the UID to an opaque identifier' do
|
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 be_nil
|
||||||
uid.should_not =~ /jerome/
|
uid.should_not =~ /jerome/
|
||||||
uid.should_not =~ /my password/
|
uid.should_not =~ /my password/
|
||||||
|
|
|
@ -23,10 +23,7 @@ module OmniAuth
|
||||||
def callback_phase
|
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))
|
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'])
|
@access_token = request_token.get_access_token(:oauth_verifier => request.params['oauth_verifier'])
|
||||||
|
super
|
||||||
request['auth'] = self.auth_hash
|
|
||||||
|
|
||||||
@app.call(self.env)
|
|
||||||
rescue ::OAuth::Unauthorized
|
rescue ::OAuth::Unauthorized
|
||||||
fail!(:invalid_credentials)
|
fail!(:invalid_credentials)
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe "OmniAuth::Strategies::OAuth" do
|
||||||
use OmniAuth::Builder do
|
use OmniAuth::Builder do
|
||||||
provider :oauth, 'example.org', 'abc', 'def', :site => 'https://api.example.org'
|
provider :oauth, 'example.org', 'abc', 'def', :site => 'https://api.example.org'
|
||||||
end
|
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
|
}.to_app
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ describe "OmniAuth::Strategies::OAuth" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should exchange the request token for an access token' do
|
it 'should exchange the request token for an access token' do
|
||||||
last_request['auth']['provider'].should == 'example.org'
|
last_request.env['rack.auth']['provider'].should == 'example.org'
|
||||||
last_request['auth']['extra']['access_token'].should be_kind_of(OAuth::AccessToken)
|
last_request.env['rack.auth']['extra']['access_token'].should be_kind_of(OAuth::AccessToken)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should call through to the master app' do
|
it 'should call through to the master app' do
|
||||||
|
|
|
@ -8,6 +8,13 @@ module OmniAuth
|
||||||
super(app, store, options)
|
super(app, store, options)
|
||||||
end
|
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
|
def identifier
|
||||||
options[:domain] || request['domain']
|
options[:domain] || request['domain']
|
||||||
end
|
end
|
||||||
|
|
|
@ -79,8 +79,7 @@ module OmniAuth
|
||||||
openid.call(env)
|
openid.call(env)
|
||||||
resp = env.delete('rack.openid.response')
|
resp = env.delete('rack.openid.response')
|
||||||
if resp && resp.status == :success
|
if resp && resp.status == :success
|
||||||
request['auth'] = auth_hash(resp)
|
super
|
||||||
@app.call(env)
|
|
||||||
else
|
else
|
||||||
fail!(:invalid_credentials)
|
fail!(:invalid_credentials)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue