omniauth 0.2.6 → 0.3.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of omniauth might be problematic. Click here for more details.
- data/README.md +62 -34
- data/lib/omniauth/version.rb +3 -3
- metadata +74 -228
- data/Gemfile +0 -12
- data/Rakefile +0 -51
- data/oa-basic/Gemfile +0 -7
- data/oa-basic/LICENSE +0 -19
- data/oa-basic/README.rdoc +0 -34
- data/oa-basic/Rakefile +0 -6
- data/oa-basic/lib/oa-basic.rb +0 -1
- data/oa-basic/lib/omniauth/basic.rb +0 -8
- data/oa-basic/lib/omniauth/strategies/http_basic.rb +0 -56
- data/oa-basic/lib/omniauth/version.rb +0 -19
- data/oa-basic/oa-basic.gemspec +0 -27
- data/oa-basic/spec/omniauth/strategies/basic_spec.rb +0 -7
- data/oa-basic/spec/spec_helper.rb +0 -11
- data/oa-core/Gemfile +0 -3
- data/oa-core/LICENSE +0 -19
- data/oa-core/Rakefile +0 -6
- data/oa-core/autotest/discover.rb +0 -1
- data/oa-core/lib/oa-core.rb +0 -1
- data/oa-core/lib/omniauth/builder.rb +0 -33
- data/oa-core/lib/omniauth/core.rb +0 -135
- data/oa-core/lib/omniauth/form.rb +0 -186
- data/oa-core/lib/omniauth/strategy.rb +0 -227
- data/oa-core/lib/omniauth/test.rb +0 -12
- data/oa-core/lib/omniauth/test/phony_session.rb +0 -8
- data/oa-core/lib/omniauth/test/strategy_macros.rb +0 -34
- data/oa-core/lib/omniauth/test/strategy_test_case.rb +0 -49
- data/oa-core/lib/omniauth/version.rb +0 -19
- data/oa-core/oa-core.gemspec +0 -24
- data/oa-core/spec/omniauth/builder_spec.rb +0 -20
- data/oa-core/spec/omniauth/core_spec.rb +0 -79
- data/oa-core/spec/omniauth/strategy_spec.rb +0 -363
- data/oa-core/spec/spec_helper.rb +0 -12
- data/oa-enterprise/Gemfile +0 -7
- data/oa-enterprise/LICENSE +0 -19
- data/oa-enterprise/README.rdoc +0 -82
- data/oa-enterprise/Rakefile +0 -6
- data/oa-enterprise/lib/oa-enterprise.rb +0 -1
- data/oa-enterprise/lib/omniauth/enterprise.rb +0 -8
- data/oa-enterprise/lib/omniauth/strategies/cas.rb +0 -47
- data/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb +0 -98
- data/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb +0 -91
- data/oa-enterprise/lib/omniauth/strategies/ldap.rb +0 -111
- data/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb +0 -279
- data/oa-enterprise/lib/omniauth/version.rb +0 -19
- data/oa-enterprise/oa-enterprise.gemspec +0 -31
- data/oa-enterprise/spec/fixtures/cas_failure.xml +0 -4
- data/oa-enterprise/spec/fixtures/cas_success.xml +0 -8
- data/oa-enterprise/spec/omniauth/strategies/cas_spec.rb +0 -94
- data/oa-enterprise/spec/omniauth/strategies/ldap_spec.rb +0 -41
- data/oa-enterprise/spec/spec_helper.rb +0 -14
- data/oa-more/Gemfile +0 -7
- data/oa-more/LICENSE +0 -19
- data/oa-more/README.rdoc +0 -22
- data/oa-more/Rakefile +0 -6
- data/oa-more/lib/oa-more.rb +0 -1
- data/oa-more/lib/omniauth/more.rb +0 -11
- data/oa-more/lib/omniauth/strategies/draugiem.rb +0 -104
- data/oa-more/lib/omniauth/strategies/flickr.rb +0 -86
- data/oa-more/lib/omniauth/strategies/ign.rb +0 -93
- data/oa-more/lib/omniauth/strategies/windows_live.rb +0 -39
- data/oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb +0 -1143
- data/oa-more/lib/omniauth/strategies/yupoo.rb +0 -67
- data/oa-more/lib/omniauth/version.rb +0 -19
- data/oa-more/oa-more.gemspec +0 -29
- data/oa-more/spec/omniauth/strategies/draugiem_spec.rb +0 -51
- data/oa-more/spec/omniauth/strategies/flickr_spec.rb +0 -7
- data/oa-more/spec/spec_helper.rb +0 -11
- data/oa-oauth/Gemfile +0 -7
- data/oa-oauth/LICENSE +0 -19
- data/oa-oauth/README.rdoc +0 -35
- data/oa-oauth/Rakefile +0 -6
- data/oa-oauth/autotest/discover.rb +0 -1
- data/oa-oauth/lib/oa-oauth.rb +0 -1
- data/oa-oauth/lib/omniauth/oauth.rb +0 -56
- data/oa-oauth/lib/omniauth/strategies/bitly.rb +0 -46
- data/oa-oauth/lib/omniauth/strategies/dailymile.rb +0 -64
- data/oa-oauth/lib/omniauth/strategies/doit.rb +0 -60
- data/oa-oauth/lib/omniauth/strategies/dopplr.rb +0 -53
- data/oa-oauth/lib/omniauth/strategies/douban.rb +0 -60
- data/oa-oauth/lib/omniauth/strategies/evernote.rb +0 -54
- data/oa-oauth/lib/omniauth/strategies/facebook.rb +0 -70
- data/oa-oauth/lib/omniauth/strategies/foursquare.rb +0 -62
- data/oa-oauth/lib/omniauth/strategies/github.rb +0 -50
- data/oa-oauth/lib/omniauth/strategies/goodreads.rb +0 -44
- data/oa-oauth/lib/omniauth/strategies/google.rb +0 -80
- data/oa-oauth/lib/omniauth/strategies/gowalla.rb +0 -72
- data/oa-oauth/lib/omniauth/strategies/hyves.rb +0 -67
- data/oa-oauth/lib/omniauth/strategies/identica.rb +0 -49
- data/oa-oauth/lib/omniauth/strategies/instagram.rb +0 -56
- data/oa-oauth/lib/omniauth/strategies/instapaper.rb +0 -40
- data/oa-oauth/lib/omniauth/strategies/linked_in.rb +0 -56
- data/oa-oauth/lib/omniauth/strategies/mailru.rb +0 -107
- data/oa-oauth/lib/omniauth/strategies/meetup.rb +0 -56
- data/oa-oauth/lib/omniauth/strategies/miso.rb +0 -41
- data/oa-oauth/lib/omniauth/strategies/mixi.rb +0 -59
- data/oa-oauth/lib/omniauth/strategies/netflix.rb +0 -65
- data/oa-oauth/lib/omniauth/strategies/oauth.rb +0 -83
- data/oa-oauth/lib/omniauth/strategies/oauth2.rb +0 -91
- data/oa-oauth/lib/omniauth/strategies/plurk.rb +0 -58
- data/oa-oauth/lib/omniauth/strategies/qzone.rb +0 -69
- data/oa-oauth/lib/omniauth/strategies/rdio.rb +0 -45
- data/oa-oauth/lib/omniauth/strategies/renren.rb +0 -87
- data/oa-oauth/lib/omniauth/strategies/salesforce.rb +0 -44
- data/oa-oauth/lib/omniauth/strategies/smug_mug.rb +0 -42
- data/oa-oauth/lib/omniauth/strategies/sound_cloud.rb +0 -46
- data/oa-oauth/lib/omniauth/strategies/t163.rb +0 -57
- data/oa-oauth/lib/omniauth/strategies/taobao.rb +0 -79
- data/oa-oauth/lib/omniauth/strategies/teambox.rb +0 -49
- data/oa-oauth/lib/omniauth/strategies/thirty_seven_signals.rb +0 -41
- data/oa-oauth/lib/omniauth/strategies/tqq.rb +0 -64
- data/oa-oauth/lib/omniauth/strategies/trade_me.rb +0 -45
- data/oa-oauth/lib/omniauth/strategies/trip_it.rb +0 -22
- data/oa-oauth/lib/omniauth/strategies/tsina.rb +0 -79
- data/oa-oauth/lib/omniauth/strategies/tsohu.rb +0 -57
- data/oa-oauth/lib/omniauth/strategies/tumblr.rb +0 -60
- data/oa-oauth/lib/omniauth/strategies/twitter.rb +0 -57
- data/oa-oauth/lib/omniauth/strategies/type_pad.rb +0 -76
- data/oa-oauth/lib/omniauth/strategies/vimeo.rb +0 -54
- data/oa-oauth/lib/omniauth/strategies/vkontakte.rb +0 -87
- data/oa-oauth/lib/omniauth/strategies/xauth.rb +0 -67
- data/oa-oauth/lib/omniauth/strategies/yahoo.rb +0 -55
- data/oa-oauth/lib/omniauth/strategies/yammer.rb +0 -43
- data/oa-oauth/lib/omniauth/strategies/you_tube.rb +0 -73
- data/oa-oauth/lib/omniauth/version.rb +0 -19
- data/oa-oauth/oa-oauth.gemspec +0 -32
- data/oa-oauth/spec/fixtures/basecamp_200.xml +0 -24
- data/oa-oauth/spec/fixtures/campfire_200.json +0 -10
- data/oa-oauth/spec/omniauth/strategies/bitly_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/dailymile_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/doit_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/dopplr_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/douban_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/evernote_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/facebook_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/foursquare_spec.rb +0 -18
- data/oa-oauth/spec/omniauth/strategies/github_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/goodreads_spec.rb +0 -6
- data/oa-oauth/spec/omniauth/strategies/google_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/gowalla_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/hyves_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/identica_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/linked_in_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/mailru_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/meetup_spec.rb +0 -14
- data/oa-oauth/spec/omniauth/strategies/miso_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/netflix_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/oauth2_spec.rb +0 -0
- data/oa-oauth/spec/omniauth/strategies/oauth_spec.rb +0 -77
- data/oa-oauth/spec/omniauth/strategies/plurk_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/rdio_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/salesforce_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/smug_mug_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/sound_cloud_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/t163_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/taobao_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/teambox_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/thirty_seven_signals_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/trade_me_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/trip_it_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/tsina_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/tumblr_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/twitter_spec.rb +0 -20
- data/oa-oauth/spec/omniauth/strategies/type_pad_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/vimeo_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/vkontakte_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/yahoo_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/yammer_spec.rb +0 -5
- data/oa-oauth/spec/omniauth/strategies/you_tube_spec.rb +0 -5
- data/oa-oauth/spec/spec_helper.rb +0 -27
- data/oa-oauth/spec/support/shared_examples.rb +0 -29
- data/oa-openid/Gemfile +0 -7
- data/oa-openid/LICENSE +0 -19
- data/oa-openid/README.rdoc +0 -51
- data/oa-openid/Rakefile +0 -6
- data/oa-openid/lib/oa-openid.rb +0 -1
- data/oa-openid/lib/omniauth/openid.rb +0 -60
- data/oa-openid/lib/omniauth/openid/gapps.rb +0 -32
- data/oa-openid/lib/omniauth/strategies/google_apps.rb +0 -23
- data/oa-openid/lib/omniauth/strategies/open_id.rb +0 -132
- data/oa-openid/lib/omniauth/strategies/steam.rb +0 -55
- data/oa-openid/lib/omniauth/version.rb +0 -19
- data/oa-openid/oa-openid.gemspec +0 -28
- data/oa-openid/spec/omniauth/strategies/open_id_spec.rb +0 -71
- data/oa-openid/spec/spec_helper.rb +0 -14
- data/omniauth.gemspec +0 -20
- data/tasks/all.rb +0 -134
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to qzone (QQ) via OAuth and retrieve basic
|
8
|
-
# user information.
|
9
|
-
#
|
10
|
-
# Usage:
|
11
|
-
#
|
12
|
-
# use OmniAuth::Strategies::Qzone, 'consumerkey', 'consumersecret'
|
13
|
-
#
|
14
|
-
class Qzone < OmniAuth::Strategies::OAuth
|
15
|
-
# Initialize the middleware
|
16
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
17
|
-
client_options = {
|
18
|
-
:site => 'http://openapi.qzone.qq.com',
|
19
|
-
:request_token_path => '/oauth/qzoneoauth_request_token',
|
20
|
-
:access_token_path => '/oauth/qzoneoauth_access_token',
|
21
|
-
:authorize_path => '/oauth/qzoneoauth_authorize',
|
22
|
-
:scheme => :query_string,
|
23
|
-
:http_method => :get
|
24
|
-
}
|
25
|
-
|
26
|
-
options[:authorize_params] = {:oauth_consumer_key => consumer_key}
|
27
|
-
super(app, :qzone, consumer_key, consumer_secret, client_options, options)
|
28
|
-
end
|
29
|
-
|
30
|
-
#HACK qzone is using a none-standard parameter oauth_overicode
|
31
|
-
def consumer_options
|
32
|
-
@consumer_options[:access_token_path] = '/oauth/qzoneoauth_access_token?oauth_vericode=' + request['oauth_vericode'] if request['oauth_vericode']
|
33
|
-
@consumer_options
|
34
|
-
end
|
35
|
-
|
36
|
-
def callback_phase
|
37
|
-
session['oauth'][name.to_s]['callback_confirmed'] = true
|
38
|
-
super
|
39
|
-
end
|
40
|
-
|
41
|
-
def auth_hash
|
42
|
-
ui = user_info
|
43
|
-
OmniAuth::Utils.deep_merge(super, {
|
44
|
-
'uid' => ui['uid'],
|
45
|
-
'user_info' => ui,
|
46
|
-
'extra' => {'user_hash' => user_hash}
|
47
|
-
})
|
48
|
-
end
|
49
|
-
|
50
|
-
def user_info
|
51
|
-
user_hash = self.user_hash
|
52
|
-
{
|
53
|
-
'uid' => @access_token.params[:openid],
|
54
|
-
'nickname' => user_hash['nickname'],
|
55
|
-
'name' => user_hash['nickname'],
|
56
|
-
'image' => user_hash['figureurl'],
|
57
|
-
'urls' => {
|
58
|
-
'figureurl_1' => user_hash['figureurl_1'],
|
59
|
-
'figureurl_2' => user_hash['figureurl_2'],
|
60
|
-
}
|
61
|
-
}
|
62
|
-
end
|
63
|
-
|
64
|
-
def user_hash
|
65
|
-
@user_hash ||= MultiJson.decode(@access_token.get("/user/get_user_info?format=json&openid=#{@access_token.params[:openid]}").body)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to Rdio via OAuth and retrieve basic user information.
|
8
|
-
# Usage:
|
9
|
-
# use OmniAuth::Strategies::Rdio, 'consumerkey', 'consumersecret'
|
10
|
-
#
|
11
|
-
class Rdio < OmniAuth::Strategies::OAuth
|
12
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
13
|
-
opts = {
|
14
|
-
:site => 'http://api.rdio.com',
|
15
|
-
:request_token_path => "/oauth/request_token",
|
16
|
-
:access_token_path => "/oauth/access_token",
|
17
|
-
:authorize_url => "https://www.rdio.com/oauth/authorize"
|
18
|
-
}
|
19
|
-
super(app, :rdio, consumer_key, consumer_secret, opts, options, &block)
|
20
|
-
end
|
21
|
-
|
22
|
-
def auth_hash
|
23
|
-
OmniAuth::Utils.deep_merge(super, {
|
24
|
-
'uid' => user_hash['key'],
|
25
|
-
'user_info' => user_info,
|
26
|
-
'extra' => { 'user_hash' => user_hash }
|
27
|
-
})
|
28
|
-
end
|
29
|
-
|
30
|
-
def user_info
|
31
|
-
user = user_hash
|
32
|
-
{
|
33
|
-
'nickname' => user['username'],
|
34
|
-
'first_name' => user['firstName'],
|
35
|
-
'last_name' => user['lastName'],
|
36
|
-
'name' => "#{user['firstName']} #{user['lastName']}"
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
def user_hash
|
41
|
-
@user_hash ||= MultiJson.decode(@access_token.post("http://api.rdio.com/1/", { :method => 'currentUser', :extras => 'username' }).body)['result']
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,87 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
require 'digest/md5'
|
4
|
-
require 'net/http'
|
5
|
-
|
6
|
-
module OmniAuth
|
7
|
-
module Strategies
|
8
|
-
# Authenticate to Renren utilizing OAuth 2.0 and retrieve
|
9
|
-
# basic user information.
|
10
|
-
#
|
11
|
-
# @example Basic Usage
|
12
|
-
# use OmniAuth::Strategies::Renren, 'client_id', 'client_secret'
|
13
|
-
class Renren < OAuth2
|
14
|
-
# @param [Rack Application] app standard middleware application parameter
|
15
|
-
# @param [String] client_id the application id as [registered on Renren](http://dev.renren.com/)
|
16
|
-
# @param [String] client_secret the application secret as registered on Renren
|
17
|
-
# @option options [String] :scope ('publish_feed,status_update') comma-separated extended permissions such as `publish_feed` and `status_update`
|
18
|
-
def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
|
19
|
-
client_options = {
|
20
|
-
:site => "http://graph.renren.com/",
|
21
|
-
:authorize_url => "/oauth/authorize",
|
22
|
-
:access_token_url => "/oauth/token"
|
23
|
-
}
|
24
|
-
|
25
|
-
super(app, :renren, client_id, client_secret, client_options, options, &block)
|
26
|
-
end
|
27
|
-
|
28
|
-
def user_data
|
29
|
-
@data ||= MultiJson.decode(Net::HTTP.post_form(URI.parse('http://api.renren.com/restserver.do'), signed_params).body)[0]
|
30
|
-
end
|
31
|
-
|
32
|
-
def signed_params
|
33
|
-
params = {}
|
34
|
-
params[:api_key] = client.id
|
35
|
-
params[:method] = "users.getInfo"
|
36
|
-
params[:call_id] = Time.now.to_i
|
37
|
-
params[:format] = "json"
|
38
|
-
params[:v] = "1.0"
|
39
|
-
params[:uids] = session_key["user"]["id"]
|
40
|
-
params[:session_key] = session_key["renren_token"]["session_key"]
|
41
|
-
params[:sig] = Digest::MD5.hexdigest(params.map {|k,v| "#{k}=#{v}"}.sort.join("") + client.secret)
|
42
|
-
params
|
43
|
-
end
|
44
|
-
|
45
|
-
def session_key
|
46
|
-
@session_key ||= MultiJson.decode(@access_token.get('/renren_api/session_key'))
|
47
|
-
end
|
48
|
-
|
49
|
-
def request_phase
|
50
|
-
options[:scope] ||= "publish_feed"
|
51
|
-
super
|
52
|
-
end
|
53
|
-
|
54
|
-
def build_access_token
|
55
|
-
if renren_session.nil? || renrensession.empty?
|
56
|
-
super
|
57
|
-
else
|
58
|
-
@access_token = ::OAuth2::AccessToken.new(client, renren_session['access_token'])
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def renren_session
|
63
|
-
session_cookie = request.cookies["rrs_#{client.id}"]
|
64
|
-
if session_cookie
|
65
|
-
@renren_session ||= Rack::Utils.parse_query(request.cookies["rrs_#{client.id}"].gsub('"', ''))
|
66
|
-
else
|
67
|
-
nil
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def user_info
|
72
|
-
{
|
73
|
-
'name' => user_data["name"],
|
74
|
-
'image' => user_data["tinyurl"]
|
75
|
-
}
|
76
|
-
end
|
77
|
-
|
78
|
-
def auth_hash
|
79
|
-
OmniAuth::Utils.deep_merge(super, {
|
80
|
-
'uid' => user_data['uid'],
|
81
|
-
'user_info' => user_info,
|
82
|
-
'extra' => {'user_hash' => user_data}
|
83
|
-
})
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'omniauth/strategies/oauth2'
|
2
|
-
|
3
|
-
module OmniAuth
|
4
|
-
module Strategies
|
5
|
-
class Salesforce < OmniAuth::Strategies::OAuth2
|
6
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
7
|
-
client_options = {
|
8
|
-
:site => 'https://login.salesforce.com',
|
9
|
-
:authorize_path => '/services/oauth2/authorize',
|
10
|
-
:access_token_path => '/services/oauth2/token'
|
11
|
-
}
|
12
|
-
|
13
|
-
options.merge!(:response_type => 'code', :grant_type => 'authorization_code')
|
14
|
-
|
15
|
-
super(app, :salesforce, consumer_key, consumer_secret, client_options, options, &block)
|
16
|
-
end
|
17
|
-
|
18
|
-
def auth_hash
|
19
|
-
data = user_data
|
20
|
-
OmniAuth::Utils.deep_merge(super, {
|
21
|
-
'uid' => @access_token['id'],
|
22
|
-
'credentials' => {
|
23
|
-
'instance_url' => @access_token['instance_url']
|
24
|
-
},
|
25
|
-
'extra' => {'user_hash' => data},
|
26
|
-
'user_info' => {
|
27
|
-
'email' => data['email'],
|
28
|
-
'name' => data['display_name']
|
29
|
-
}
|
30
|
-
})
|
31
|
-
end
|
32
|
-
|
33
|
-
def user_data
|
34
|
-
@data ||= MultiJson.decode(@access_token.get(@access_token['id']))
|
35
|
-
rescue ::OAuth2::HTTPError => e
|
36
|
-
if e.response.status == 302
|
37
|
-
@data ||= MultiJson.decode(@access_token.get(e.response.headers['location']))
|
38
|
-
else
|
39
|
-
raise e
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to SmugMug via OAuth and retrieve basic user information.
|
8
|
-
# Usage:
|
9
|
-
# use OmniAuth::Strategies::SmugMug, 'consumerkey', 'consumersecret'
|
10
|
-
#
|
11
|
-
class SmugMug < OmniAuth::Strategies::OAuth
|
12
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
13
|
-
super(app, :smugmug, consumer_key, consumer_secret,
|
14
|
-
{:site => 'http://api.smugmug.com',
|
15
|
-
:request_token_path => "/services/oauth/getRequestToken.mg",
|
16
|
-
:access_token_path => "/services/oauth/getAccessToken.mg",
|
17
|
-
:authorize_path => "/services/oauth/authorize.mg"}, options, &block)
|
18
|
-
end
|
19
|
-
|
20
|
-
def auth_hash
|
21
|
-
OmniAuth::Utils.deep_merge(super, {
|
22
|
-
'uid' => user_hash['id'],
|
23
|
-
'user_info' => user_info,
|
24
|
-
'extra' => { 'user_hash' => user_hash }
|
25
|
-
})
|
26
|
-
end
|
27
|
-
|
28
|
-
# user info according to schema
|
29
|
-
def user_info
|
30
|
-
{
|
31
|
-
'nickname' => user_hash['NickName'],
|
32
|
-
'name' => user_hash['NickName']
|
33
|
-
}
|
34
|
-
end
|
35
|
-
|
36
|
-
# info as supplied by SmugMug
|
37
|
-
def user_hash
|
38
|
-
@user_hash ||= MultiJson.decode(@access_token.get('/services/api/json/1.2.2/?method=smugmug.auth.checkAccessToken').body)['Auth']['User']
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to SoundCloud via OAuth and retrieve basic
|
8
|
-
# user information.
|
9
|
-
#
|
10
|
-
# Usage:
|
11
|
-
#
|
12
|
-
# use OmniAuth::Strategies::SoundCloud, 'consumerkey', 'consumersecret'
|
13
|
-
#
|
14
|
-
|
15
|
-
class SoundCloud < OmniAuth::Strategies::OAuth
|
16
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
17
|
-
super(app, :soundcloud, consumer_key, consumer_secret, {:site => 'https://api.soundcloud.com'}, options)
|
18
|
-
end
|
19
|
-
|
20
|
-
def auth_hash
|
21
|
-
OmniAuth::Utils.deep_merge(super, {
|
22
|
-
'uid' => user_hash['id'],
|
23
|
-
'user_info' => user_info,
|
24
|
-
'extra' => {'user_hash' => user_hash}
|
25
|
-
})
|
26
|
-
end
|
27
|
-
|
28
|
-
def user_info
|
29
|
-
user_hash = self.user_hash
|
30
|
-
|
31
|
-
{
|
32
|
-
'name' => user_hash['full_name'],
|
33
|
-
'nickname' => user_hash['username'],
|
34
|
-
'location' => user_hash['city'],
|
35
|
-
'description' => user_hash['description'],
|
36
|
-
'image' => user_hash['avatar_url'],
|
37
|
-
'urls' => {'Website' => user_hash['website']}
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
def user_hash
|
42
|
-
@user_hash ||= MultiJson.decode(@access_token.get('/me.json').body)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to T163 via OAuth and retrieve basic
|
8
|
-
# user information.
|
9
|
-
#
|
10
|
-
# Usage:
|
11
|
-
#
|
12
|
-
# use OmniAuth::Strategies::T163, 'APIKey', 'APIKeySecret'
|
13
|
-
#
|
14
|
-
class T163 < OmniAuth::Strategies::OAuth
|
15
|
-
|
16
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
17
|
-
@api_key = consumer_key
|
18
|
-
|
19
|
-
client_options = {
|
20
|
-
:site => 'http://api.t.163.com',
|
21
|
-
:request_token_path => '/oauth/request_token',
|
22
|
-
:access_token_path => '/oauth/access_token',
|
23
|
-
:authorize_path => '/oauth/authenticate',
|
24
|
-
:realm => 'OmniAuth'
|
25
|
-
}
|
26
|
-
|
27
|
-
super(app, :t163, consumer_key, consumer_secret, client_options, options, &block)
|
28
|
-
end
|
29
|
-
|
30
|
-
def auth_hash
|
31
|
-
OmniAuth::Utils.deep_merge(super, {
|
32
|
-
'uid' => user_hash['screen_name'],
|
33
|
-
'user_info' => user_info,
|
34
|
-
'extra' => {'user_hash' => user_hash}
|
35
|
-
})
|
36
|
-
end
|
37
|
-
|
38
|
-
def user_info
|
39
|
-
user_hash = self.user_hash
|
40
|
-
{
|
41
|
-
'username' => user_hash['name'],
|
42
|
-
'name' => user_hash['realName'],
|
43
|
-
'location' => user_hash['location'],
|
44
|
-
'image' => user_hash['profile_image_url'],
|
45
|
-
'description' => user_hash['description'],
|
46
|
-
'urls' => {
|
47
|
-
'T163' => 'http://t.163.com'
|
48
|
-
}
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
def user_hash
|
53
|
-
@user_hash ||= MultiJson.decode(@access_token.get("http://api.t.163.com/account/verify_credentials.json").body)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
require 'digest/md5'
|
4
|
-
require 'net/http'
|
5
|
-
|
6
|
-
module OmniAuth
|
7
|
-
module Strategies
|
8
|
-
# Authenticate to Renren utilizing OAuth 2.0 and retrieve
|
9
|
-
# basic user information.
|
10
|
-
#
|
11
|
-
# @example Basic Usage
|
12
|
-
# use OmniAuth::Strategies::TB, 'client_id', 'client_secret'
|
13
|
-
class TB < OAuth2
|
14
|
-
# @param [Rack Application] app standard middleware application parameter
|
15
|
-
# @param [String] client_id the app key at taobao open platform
|
16
|
-
# @param [String] client_secret the app secret at taobao open platform
|
17
|
-
# @option options [String]
|
18
|
-
|
19
|
-
def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
|
20
|
-
client_options = {
|
21
|
-
:site => "https://oauth.taobao.com/",
|
22
|
-
:authorize_url => "/authorize",
|
23
|
-
:access_token_url => "/token"
|
24
|
-
}
|
25
|
-
|
26
|
-
super(app, :tb, client_id, client_secret, client_options, options, &block)
|
27
|
-
end
|
28
|
-
|
29
|
-
def user_data
|
30
|
-
# TODO to be moved in options
|
31
|
-
url = 'http://gw.api.taobao.com/router/rest'
|
32
|
-
|
33
|
-
query_param = {
|
34
|
-
:app_key => client_id,
|
35
|
-
|
36
|
-
# TODO to be moved in options
|
37
|
-
# TODO add more default fields (http://my.open.taobao.com/apidoc/index.htm#categoryId:1-dataStructId:3)
|
38
|
-
:fields => 'user_id,uid,nick,sex,buyer_credit,seller_credit,location,created,last_visit,birthday,type,status,alipay_no,alipay_account,alipay_account,email,consumer_protection,alipay_bind',
|
39
|
-
:format => 'json',
|
40
|
-
:method => 'taobao.user.get',
|
41
|
-
:session => @access_token.token,
|
42
|
-
:sign_method => 'md5',
|
43
|
-
:timestamp => Time.now.strftime("%Y-%m-%d %H:%M:%S"),
|
44
|
-
:v => '2.0'
|
45
|
-
}
|
46
|
-
query_param = generate_sign(query_param)
|
47
|
-
res = Net::HTTP.post_form(URI.parse(url), query_param)
|
48
|
-
@data ||= MultiJson.decode(res.body)["user_get_response"]["user"]
|
49
|
-
end
|
50
|
-
|
51
|
-
def request_phase
|
52
|
-
options[:state] ||= '1'
|
53
|
-
super
|
54
|
-
end
|
55
|
-
|
56
|
-
def user_info
|
57
|
-
{
|
58
|
-
'name' => user_data["nick"],
|
59
|
-
'email' => (user_data["email"] if user_data["email"]),
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
def auth_hash
|
64
|
-
OmniAuth::Utils.deep_merge(super, {
|
65
|
-
'uid' => user_data['uid'],
|
66
|
-
'user_info' => user_info,
|
67
|
-
'extra' => {'user_hash' => user_data}
|
68
|
-
})
|
69
|
-
end
|
70
|
-
|
71
|
-
def generate_sign(params)
|
72
|
-
str = client_secret + (params.sort.collect { |k, v| "#{k}#{v}" }).join + client_secret
|
73
|
-
params["sign"] = Digest::MD5.hexdigest(str).upcase!
|
74
|
-
params
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|