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,49 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
class Teambox < OAuth2
|
7
|
-
def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
|
8
|
-
client_options = {
|
9
|
-
:site => "https://teambox.com/",
|
10
|
-
:authorize_path => "/oauth/authorize",
|
11
|
-
:access_token_path => "/oauth/token"
|
12
|
-
}
|
13
|
-
super(app, :teambox, client_id, client_secret, client_options, options, &block)
|
14
|
-
end
|
15
|
-
def request_phase
|
16
|
-
options[:scope] ||= "offline_access"
|
17
|
-
options[:response_type] ||= 'code'
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
def callback_phase
|
22
|
-
options[:grant_type] ||= 'authorization_code'
|
23
|
-
super
|
24
|
-
end
|
25
|
-
|
26
|
-
def user_data
|
27
|
-
@data ||= MultiJson.decode(@access_token.get("/api/1/account"))
|
28
|
-
end
|
29
|
-
|
30
|
-
def user_info
|
31
|
-
{
|
32
|
-
'nickname' => user_data['username'],
|
33
|
-
'name' => user_data['first_name'],
|
34
|
-
'image' => user_data['avatar_url'],
|
35
|
-
'urls' => {}
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
def auth_hash
|
40
|
-
OmniAuth::Utils.deep_merge(super, {
|
41
|
-
'uid' => user_data['id'],
|
42
|
-
'user_info' => user_info,
|
43
|
-
'extra' => {'user_hash' => user_data}
|
44
|
-
})
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
class ThirtySevenSignals < OAuth2
|
7
|
-
def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
|
8
|
-
client_options = {
|
9
|
-
:site => 'https://launchpad.37signals.com/',
|
10
|
-
:authorize_path => '/authorization/new',
|
11
|
-
:access_token_path => '/authorization/token'
|
12
|
-
}
|
13
|
-
|
14
|
-
super(app, :thirty_seven_signals, client_id, client_secret, client_options, options, &block)
|
15
|
-
end
|
16
|
-
|
17
|
-
def user_data
|
18
|
-
@data ||= MultiJson.decode(@access_token.get('/authorization.json'))
|
19
|
-
end
|
20
|
-
|
21
|
-
def user_info
|
22
|
-
{
|
23
|
-
'email' => user_data['identity']['email_address'],
|
24
|
-
'first_name' => user_data['identity']['first_name'],
|
25
|
-
'last_name' => user_data['identity']['last_name'],
|
26
|
-
'name' => [user_data['identity']['first_name'], user_data['identity']['last_name']].join(' ').strip
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
def auth_hash
|
31
|
-
OmniAuth::Utils.deep_merge(super, {
|
32
|
-
'uid' => user_data['identity']['id'],
|
33
|
-
'user_info' => user_info,
|
34
|
-
'extra' => {
|
35
|
-
'accounts' => user_data['accounts']
|
36
|
-
}
|
37
|
-
})
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to Tqq via OAuth and retrieve basic
|
8
|
-
# user information.
|
9
|
-
#
|
10
|
-
# Usage:
|
11
|
-
#
|
12
|
-
# use OmniAuth::Strategies::Tqq, 'APIKey', 'APIKeySecret'
|
13
|
-
#
|
14
|
-
class Tqq < 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 => 'https://open.t.qq.com',
|
21
|
-
:request_token_path => '/cgi-bin/request_token',
|
22
|
-
:access_token_path => '/cgi-bin/access_token',
|
23
|
-
:authorize_path => '/cgi-bin/authorize',
|
24
|
-
:realm => 'OmniAuth',
|
25
|
-
:scheme => :query_string,
|
26
|
-
:nonce => nonce,
|
27
|
-
:http_method => :get,
|
28
|
-
}
|
29
|
-
|
30
|
-
super(app, :tqq, consumer_key, consumer_secret, client_options, options, &block)
|
31
|
-
end
|
32
|
-
|
33
|
-
def nonce
|
34
|
-
Base64.encode64(OpenSSL::Random.random_bytes(32)).gsub(/\W/, '')[0, 32]
|
35
|
-
end
|
36
|
-
|
37
|
-
def auth_hash
|
38
|
-
OmniAuth::Utils.deep_merge(super, {
|
39
|
-
'uid' => user_hash["data"]['uid'],
|
40
|
-
'user_info' => user_info,
|
41
|
-
'extra' => {'user_hash' => user_hash}
|
42
|
-
})
|
43
|
-
end
|
44
|
-
|
45
|
-
def user_info
|
46
|
-
user_hash = self.user_hash
|
47
|
-
{
|
48
|
-
'username' => user_hash["data"]['name'],
|
49
|
-
'name' => user_hash["data"]['nick'],
|
50
|
-
'location' => user_hash["data"]['location'],
|
51
|
-
'image' => user_hash["data"]['head'],
|
52
|
-
'description' => user_hash['description'],
|
53
|
-
'urls' => {
|
54
|
-
'Tqq' => 't.qq.com'
|
55
|
-
}
|
56
|
-
}
|
57
|
-
end
|
58
|
-
|
59
|
-
def user_hash
|
60
|
-
@user_hash ||= MultiJson.decode(@access_token.get("http://open.t.qq.com/api/user/info?format=json").body)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to TradeMe via OAuth and retrieve basic user information.
|
8
|
-
# Usage:
|
9
|
-
# use OmniAuth::Strategies::TradeMe, 'consumerkey', 'consumersecret'
|
10
|
-
#
|
11
|
-
class TradeMe < OmniAuth::Strategies::OAuth
|
12
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
13
|
-
super(app, :trademe, consumer_key, consumer_secret,
|
14
|
-
{:site => 'https://secure.trademe.co.nz',
|
15
|
-
:request_token_path => "/Oauth/RequestToken",
|
16
|
-
:access_token_path => "/Oauth/AccessToken",
|
17
|
-
:authorize_path => "/Oauth/Authorize",
|
18
|
-
}, options, &block)
|
19
|
-
end
|
20
|
-
|
21
|
-
def auth_hash
|
22
|
-
OmniAuth::Utils.deep_merge(super, {
|
23
|
-
'uid' => user_hash['MemberId'],
|
24
|
-
'user_info' => user_info,
|
25
|
-
'extra' => { 'user_hash' => user_hash },
|
26
|
-
})
|
27
|
-
end
|
28
|
-
|
29
|
-
# user info according to schema
|
30
|
-
def user_info
|
31
|
-
{
|
32
|
-
'nickname' => user_hash['Nickname'],
|
33
|
-
'first_name' => user_hash['FirstName'],
|
34
|
-
'last_name' => user_hash['LastName'],
|
35
|
-
'name' => [user_hash['FirstName'],user_hash['LastName']].reject{ |n| n.nil? || n.empty? }.join(' '),
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
# info as supplied by TradeMe user summary
|
40
|
-
def user_hash
|
41
|
-
@user_hash ||= MultiJson.decode(@access_token.get('https://api.trademe.co.nz/v1/MyTradeMe/Summary.json').body)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
|
3
|
-
module OmniAuth
|
4
|
-
module Strategies
|
5
|
-
#
|
6
|
-
# Authenticate to TripIt via OAuth and retrieve an access token for API usage
|
7
|
-
#
|
8
|
-
# Usage:
|
9
|
-
#
|
10
|
-
# use OmniAuth::Strategies::TripIt, 'consumerkey', 'consumersecret'
|
11
|
-
#
|
12
|
-
class TripIt < OmniAuth::Strategies::OAuth
|
13
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
14
|
-
super(app, :tripit, consumer_key, consumer_secret,
|
15
|
-
{:site => 'https://api.tripit.com',
|
16
|
-
:request_token_path => "/oauth/request_token",
|
17
|
-
:access_token_path => "/oauth/access_token",
|
18
|
-
:authorize_url => "https://www.tripit.com/oauth/authorize"}, options, &block)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to TSina via OAuth and retrieve basic
|
8
|
-
# user information.
|
9
|
-
#
|
10
|
-
# Usage:
|
11
|
-
#
|
12
|
-
# use OmniAuth::Strategies::TSina, 'APIKey', 'APIKeySecret'
|
13
|
-
#
|
14
|
-
class Tsina < 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.sina.com.cn',
|
21
|
-
:request_token_path => '/oauth/request_token',
|
22
|
-
:access_token_path => '/oauth/access_token',
|
23
|
-
:authorize_path => '/oauth/authorize',
|
24
|
-
:realm => 'OmniAuth'
|
25
|
-
}
|
26
|
-
|
27
|
-
super(app, :tsina, consumer_key, consumer_secret, client_options, options, &block)
|
28
|
-
end
|
29
|
-
|
30
|
-
def auth_hash
|
31
|
-
OmniAuth::Utils.deep_merge(super, {
|
32
|
-
'uid' => @access_token.params[:user_id],
|
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['screen_name'],
|
42
|
-
'name' => user_hash['name'],
|
43
|
-
'location' => user_hash['location'],
|
44
|
-
'image' => user_hash['profile_image_url'],
|
45
|
-
'description' => user_hash['description'],
|
46
|
-
'urls' => {
|
47
|
-
'Tsina' => user_hash['url']
|
48
|
-
}
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
# MonkeyPatch session['oauth']['tsina']['callback_confirmed'] to true
|
53
|
-
def request_phase
|
54
|
-
request_token = consumer.get_request_token(:oauth_callback => callback_url)
|
55
|
-
session['oauth'] ||= {}
|
56
|
-
session['oauth'][name.to_s] = {'callback_confirmed' => true, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
|
57
|
-
r = Rack::Response.new
|
58
|
-
|
59
|
-
if request_token.callback_confirmed?
|
60
|
-
r.redirect(request_token.authorize_url)
|
61
|
-
else
|
62
|
-
r.redirect(request_token.authorize_url(:oauth_callback => callback_url))
|
63
|
-
end
|
64
|
-
|
65
|
-
r.finish
|
66
|
-
rescue ::Timeout::Error => e
|
67
|
-
fail!(:timeout, e)
|
68
|
-
end
|
69
|
-
|
70
|
-
def user_hash
|
71
|
-
# http://api.t.sina.com.cn/users/show/:id.json?source=appkey
|
72
|
-
# @access_token.params[:user_id] is the UID
|
73
|
-
# @api_key is the appkey
|
74
|
-
uid = @access_token.params[:user_id]
|
75
|
-
@user_hash ||= MultiJson.decode(@access_token.get("http://api.t.sina.com.cn/users/show/#{uid}.json?source=#{@api_key}").body)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to Tsohu via OAuth and retrieve basic
|
8
|
-
# user information.
|
9
|
-
#
|
10
|
-
# Usage:
|
11
|
-
#
|
12
|
-
# use OmniAuth::Strategies::Tsohu, 'APIKey', 'APIKeySecret'
|
13
|
-
#
|
14
|
-
class Tsohu < 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.sohu.com',
|
21
|
-
:request_token_path => '/oauth/request_token',
|
22
|
-
:access_token_path => '/oauth/access_token',
|
23
|
-
:authorize_path => '/oauth/authorize',
|
24
|
-
:scheme => :header,
|
25
|
-
}
|
26
|
-
|
27
|
-
super(app, :tsohu, 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['id'],
|
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['screen_name'],
|
42
|
-
'name' => user_hash['name'],
|
43
|
-
'location' => user_hash['location'],
|
44
|
-
'image' => user_hash['profile_image_url'],
|
45
|
-
'description' => user_hash['description'],
|
46
|
-
'urls' => {
|
47
|
-
'Tsohu' => user_hash['url']
|
48
|
-
}
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
def user_hash
|
53
|
-
@user_hash ||= MultiJson.decode(@access_token.get("http://api.t.sohu.com/account/verify_credentials.json").body)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
|
3
|
-
module OmniAuth
|
4
|
-
module Strategies
|
5
|
-
#
|
6
|
-
# Authenticate to Tumblr via OAuth and retrieve basic
|
7
|
-
# user information.
|
8
|
-
#
|
9
|
-
# Usage:
|
10
|
-
#
|
11
|
-
# use OmniAuth::Strategies::Tumblr, 'consumerkey', 'consumersecret'
|
12
|
-
#
|
13
|
-
class Tumblr < OmniAuth::Strategies::OAuth
|
14
|
-
# Initialize the middleware
|
15
|
-
#
|
16
|
-
# @option options [Boolean, true] :sign_in When true, use the "Sign in with Tumblr" flow instead of the authorization flow.
|
17
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
18
|
-
client_options = {
|
19
|
-
:site => 'http://www.tumblr.com'
|
20
|
-
}
|
21
|
-
|
22
|
-
client_options[:authorize_path] = '/oauth/authorize' unless options[:sign_in] == false
|
23
|
-
super(app, :tumblr, consumer_key, consumer_secret, client_options, options)
|
24
|
-
end
|
25
|
-
|
26
|
-
def auth_hash
|
27
|
-
OmniAuth::Utils.deep_merge(super, {
|
28
|
-
'uid' => user['name'],
|
29
|
-
'user_info' => user_info,
|
30
|
-
'extra' => { 'user_hash' => user }
|
31
|
-
})
|
32
|
-
end
|
33
|
-
|
34
|
-
def user_info
|
35
|
-
{
|
36
|
-
'nickname' => user['name'],
|
37
|
-
'name' => user['title'],
|
38
|
-
'image' => user['avatar_url'],
|
39
|
-
'urls' => {
|
40
|
-
'website' => user['url'],
|
41
|
-
}
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
def user
|
46
|
-
tumblelogs = user_hash['tumblr']['tumblelog']
|
47
|
-
if tumblelogs.kind_of?(Array)
|
48
|
-
@user ||= tumblelogs[0]
|
49
|
-
else
|
50
|
-
@user ||= tumblelogs
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def user_hash
|
55
|
-
url = "http://www.tumblr.com/api/authenticate"
|
56
|
-
@user_hash ||= Hash.from_xml(@access_token.get(url).body)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to Twitter via OAuth and retrieve basic
|
8
|
-
# user information.
|
9
|
-
#
|
10
|
-
# Usage:
|
11
|
-
#
|
12
|
-
# use OmniAuth::Strategies::Twitter, 'consumerkey', 'consumersecret'
|
13
|
-
#
|
14
|
-
class Twitter < OmniAuth::Strategies::OAuth
|
15
|
-
# Initialize the middleware
|
16
|
-
#
|
17
|
-
# @option options [Boolean, true] :sign_in When true, use the "Sign in with Twitter" flow instead of the authorization flow.
|
18
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
19
|
-
client_options = {
|
20
|
-
:site => 'https://api.twitter.com'
|
21
|
-
}
|
22
|
-
|
23
|
-
options[:authorize_params] = {:force_login => 'true'} if options.delete(:force_login) == true
|
24
|
-
client_options[:authorize_path] = '/oauth/authenticate' unless options[:sign_in] == false
|
25
|
-
super(app, :twitter, consumer_key, consumer_secret, client_options, options)
|
26
|
-
end
|
27
|
-
|
28
|
-
def auth_hash
|
29
|
-
OmniAuth::Utils.deep_merge(super, {
|
30
|
-
'uid' => @access_token.params[:user_id],
|
31
|
-
'user_info' => user_info,
|
32
|
-
'extra' => {'user_hash' => user_hash}
|
33
|
-
})
|
34
|
-
end
|
35
|
-
|
36
|
-
def user_info
|
37
|
-
user_hash = self.user_hash
|
38
|
-
|
39
|
-
{
|
40
|
-
'nickname' => user_hash['screen_name'],
|
41
|
-
'name' => user_hash['name'] || user_hash['screen_name'],
|
42
|
-
'location' => user_hash['location'],
|
43
|
-
'image' => user_hash['profile_image_url'],
|
44
|
-
'description' => user_hash['description'],
|
45
|
-
'urls' => {
|
46
|
-
'Website' => user_hash['url'],
|
47
|
-
'Twitter' => 'http://twitter.com/' + user_hash['screen_name']
|
48
|
-
}
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
def user_hash
|
53
|
-
@user_hash ||= MultiJson.decode(@access_token.get('/1/account/verify_credentials.json').body)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|