Merge branch 'master' of github.com:intridea/omniauth into 1.0-beta
This commit is contained in:
commit
ab45e0f700
|
@ -71,6 +71,7 @@ OmniAuth currently supports the following external providers:
|
|||
* Twitter (credit: [mbleigh](https://github.com/mbleigh))
|
||||
* Vimeo (credit: [jamiew](https://github.com/jamiew))
|
||||
* Vkontakte (credit: [german](https://github.com/german))
|
||||
* WePay (credit: [ryanwood](https://github.com/ryanwood))
|
||||
* Yammer (credit: [kltcalamay](https://github.com/kltcalamay))
|
||||
* YouTube (credit: [jamiew](https://github.com/jamiew))
|
||||
* CAS (Central Authentication Service) (credit: [jamesarosen](https://github.com/jamesarosen))
|
||||
|
|
|
@ -12,6 +12,7 @@ module OmniAuth
|
|||
autoload :Doit, 'omniauth/strategies/doit'
|
||||
autoload :Dopplr, 'omniauth/strategies/dopplr'
|
||||
autoload :Douban, 'omniauth/strategies/douban'
|
||||
autoload :Dropbox, 'omniauth/strategies/dropbox'
|
||||
autoload :Evernote, 'omniauth/strategies/evernote'
|
||||
autoload :Facebook, 'omniauth/strategies/facebook'
|
||||
autoload :Foursquare, 'omniauth/strategies/foursquare'
|
||||
|
@ -52,6 +53,7 @@ module OmniAuth
|
|||
autoload :TypePad, 'omniauth/strategies/type_pad'
|
||||
autoload :Vimeo, 'omniauth/strategies/vimeo'
|
||||
autoload :Vkontakte, 'omniauth/strategies/vkontakte'
|
||||
autoload :WePay, 'omniauth/strategies/we_pay'
|
||||
autoload :Yahoo, 'omniauth/strategies/yahoo'
|
||||
autoload :Yammer, 'omniauth/strategies/yammer'
|
||||
autoload :YouTube, 'omniauth/strategies/you_tube'
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
require 'omniauth/oauth'
|
||||
require 'multi_json'
|
||||
|
||||
module OmniAuth
|
||||
module Strategies
|
||||
class Dropbox < OmniAuth::Strategies::OAuth
|
||||
def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
|
||||
client_options = {
|
||||
:site => "https://api.dropbox.com",
|
||||
:proxy => ENV["HTTP_PROXY"] || ENV["http_proxy"],
|
||||
:request_token_url => "https://api.dropbox.com/0/oauth/request_token",
|
||||
:authorize_url => "https://www.dropbox.com/0/oauth/authorize",
|
||||
:access_token_url => "https://api.dropbox.com/0/oauth/access_token"
|
||||
}
|
||||
super(app, :dropbox, client_id, client_secret, client_options, options, &block)
|
||||
end
|
||||
|
||||
def user_data
|
||||
@data ||= MultiJson.decode(@access_token.get('/0/account/info').body)
|
||||
end
|
||||
|
||||
def user_info
|
||||
{
|
||||
'name' => "#{user_data['display_name']}"
|
||||
}
|
||||
end
|
||||
|
||||
def auth_hash
|
||||
OmniAuth::Utils.deep_merge(super, {
|
||||
'uid' => user_data['uid'],
|
||||
'user_info' => user_info
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -21,7 +21,7 @@ module OmniAuth
|
|||
}
|
||||
|
||||
google_contacts_auth = "www.google.com/m8/feeds"
|
||||
options[:scope] ||= google_contacts_auth
|
||||
options[:scope] ||= "http://#{google_contacts_auth}"
|
||||
options[:scope] << " http://#{google_contacts_auth}" unless options[:scope] =~ %r[http[s]?:\/\/#{google_contacts_auth}]
|
||||
|
||||
super(app, :google, consumer_key, consumer_secret, client_options, options)
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
require 'omniauth/oauth'
|
||||
require 'multi_json'
|
||||
|
||||
module OmniAuth
|
||||
module Strategies
|
||||
# OAuth 2.0 based authentication with WePay. In order to
|
||||
# sign up for an application, you need to [register an application](https://wepay.com/developer/register)
|
||||
# and provide the proper credentials to this middleware.
|
||||
class WePay < OAuth2
|
||||
# @param [Rack Application] app standard middleware application argument
|
||||
# @param [String] client_id the application ID for your client
|
||||
# @param [String] client_secret the application secret
|
||||
def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
|
||||
client_options = {
|
||||
:site => "https://wepayapi.com",
|
||||
:authorize_url => 'https://www.wepay.com/session/authorize',
|
||||
:access_token_path => '/v1/oauth2/token'
|
||||
}
|
||||
|
||||
super(app, :we_pay, client_id, client_secret, client_options, options, &block)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def user_data
|
||||
@data ||= MultiJson.decode(@access_token.get('/v1/user'))['result']
|
||||
end
|
||||
|
||||
def user_info
|
||||
{
|
||||
'email' => user_data['email'],
|
||||
'name' => "#{user_data['firstName']} #{user_data['lastName']}",
|
||||
'first_name' => user_data['firstName'],
|
||||
'last_name' => user_data['lastName'],
|
||||
'image' => user_data['picture']
|
||||
}
|
||||
end
|
||||
|
||||
def auth_hash
|
||||
OmniAuth::Utils.deep_merge(super, {
|
||||
'uid' => user_data['user_id'],
|
||||
'user_info' => user_info,
|
||||
'extra' => {'user_hash' => user_data}
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
|
||||
describe OmniAuth::Strategies::Dropbox do
|
||||
it_should_behave_like "an oauth strategy"
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require File.expand_path('../../../spec_helper', __FILE__)
|
||||
|
||||
describe OmniAuth::Strategies::WePay do
|
||||
it_should_behave_like "an oauth2 strategy"
|
||||
end
|
Loading…
Reference in New Issue