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,80 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to Google via OAuth and retrieve basic
|
8
|
-
# user information.
|
9
|
-
#
|
10
|
-
# Usage:
|
11
|
-
#
|
12
|
-
# use OmniAuth::Strategies::Google, 'consumerkey', 'consumersecret'
|
13
|
-
#
|
14
|
-
class Google < OmniAuth::Strategies::OAuth
|
15
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
16
|
-
client_options = {
|
17
|
-
:site => 'https://www.google.com',
|
18
|
-
:request_token_path => '/accounts/OAuthGetRequestToken',
|
19
|
-
:access_token_path => '/accounts/OAuthGetAccessToken',
|
20
|
-
:authorize_path => '/accounts/OAuthAuthorizeToken'
|
21
|
-
}
|
22
|
-
|
23
|
-
google_contacts_auth = "www.google.com/m8/feeds"
|
24
|
-
options[:scope] ||= google_contacts_auth
|
25
|
-
options[:scope] << " http://#{google_contacts_auth}" unless options[:scope] =~ %r[http[s]?:\/\/#{google_contacts_auth}]
|
26
|
-
|
27
|
-
super(app, :google, consumer_key, consumer_secret, client_options, options)
|
28
|
-
end
|
29
|
-
|
30
|
-
def auth_hash
|
31
|
-
ui = user_info
|
32
|
-
OmniAuth::Utils.deep_merge(super, {
|
33
|
-
'uid' => ui['uid'],
|
34
|
-
'user_info' => ui,
|
35
|
-
'extra' => {'user_hash' => user_hash}
|
36
|
-
})
|
37
|
-
end
|
38
|
-
|
39
|
-
def user_info
|
40
|
-
email = user_hash['feed']['id']['$t']
|
41
|
-
|
42
|
-
name = user_hash['feed']['author'].first['name']['$t']
|
43
|
-
name = email if name.strip == '(unknown)'
|
44
|
-
|
45
|
-
{
|
46
|
-
'email' => email,
|
47
|
-
'uid' => email,
|
48
|
-
'name' => name
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
def user_hash
|
53
|
-
# Google is very strict about keeping authorization and
|
54
|
-
# authentication separated.
|
55
|
-
# They give no endpoint to get a user's profile directly that I can
|
56
|
-
# find. We *can* get their name and email out of the contacts feed,
|
57
|
-
# however. It will fail in the extremely rare case of a user who has
|
58
|
-
# a Google Account but has never even signed up for Gmail. This has
|
59
|
-
# not been seen in the field.
|
60
|
-
@user_hash ||= MultiJson.decode(@access_token.get("http://www.google.com/m8/feeds/contacts/default/full?max-results=1&alt=json").body)
|
61
|
-
end
|
62
|
-
|
63
|
-
# Monkeypatch OmniAuth to pass the scope in the consumer.get_request_token call
|
64
|
-
def request_phase
|
65
|
-
request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => options[:scope]})
|
66
|
-
session['oauth'] ||= {}
|
67
|
-
session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
|
68
|
-
r = Rack::Response.new
|
69
|
-
|
70
|
-
if request_token.callback_confirmed?
|
71
|
-
r.redirect(request_token.authorize_url)
|
72
|
-
else
|
73
|
-
r.redirect(request_token.authorize_url(:oauth_callback => callback_url))
|
74
|
-
end
|
75
|
-
|
76
|
-
r.finish
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to Gowalla utilizing OAuth 2.0 and retrieve
|
8
|
-
# basic user information.
|
9
|
-
#
|
10
|
-
# @example Basic Usage
|
11
|
-
# use OmniAuth::Strategies::Gowalla, 'API Key', 'Secret Key'
|
12
|
-
class Gowalla < OAuth2
|
13
|
-
# @param [Rack Application] app standard middleware application parameter
|
14
|
-
# @param [String] api_key the application id as [registered on Gowalla](http://gowalla.com/api/keys)
|
15
|
-
# @param [String] secret_key the application secret as [registered on Gowalla](http://gowalla.com/api/keys)
|
16
|
-
# @option options ['read','read-write'] :scope ('read') the scope of your authorization request; must be `read` or `read-write`
|
17
|
-
def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
|
18
|
-
client_options = {
|
19
|
-
:site => 'https://api.gowalla.com/api/oauth',
|
20
|
-
:authorize_url => 'https://gowalla.com/api/oauth/new',
|
21
|
-
:access_token_url => 'https://api.gowalla.com/api/oauth/token'
|
22
|
-
}
|
23
|
-
|
24
|
-
super(app, :gowalla, api_key, secret_key, client_options, options, &block)
|
25
|
-
end
|
26
|
-
|
27
|
-
protected
|
28
|
-
|
29
|
-
def user_data
|
30
|
-
@data ||= MultiJson.decode(@access_token.get("/users/me.json"))
|
31
|
-
end
|
32
|
-
|
33
|
-
def refresh_token
|
34
|
-
@refresh_token ||= @access_token.refresh_token
|
35
|
-
end
|
36
|
-
|
37
|
-
def token_expires_at
|
38
|
-
@expires_at ||= @access_token.expires_at
|
39
|
-
end
|
40
|
-
|
41
|
-
def request_phase
|
42
|
-
options[:scope] ||= "read"
|
43
|
-
super
|
44
|
-
end
|
45
|
-
|
46
|
-
def user_info
|
47
|
-
{
|
48
|
-
'name' => "#{user_data['first_name']} #{user_data['last_name']}",
|
49
|
-
'nickname' => user_data["username"],
|
50
|
-
'first_name' => user_data["first_name"],
|
51
|
-
'last_name' => user_data["last_name"],
|
52
|
-
'location' => user_data["hometown"],
|
53
|
-
'description' => user_data["bio"],
|
54
|
-
'image' => user_data["image_url"],
|
55
|
-
'phone' => nil,
|
56
|
-
'urls' => {
|
57
|
-
'Gowalla' => "http://www.gowalla.com#{user_data['url']}",
|
58
|
-
'Website' => user_data["website"]
|
59
|
-
}
|
60
|
-
}
|
61
|
-
end
|
62
|
-
|
63
|
-
def auth_hash
|
64
|
-
OmniAuth::Utils.deep_merge(super, {
|
65
|
-
'uid' => user_data["url"].split('/').last,
|
66
|
-
'user_info' => user_info,
|
67
|
-
'extra' => {'user_hash' => user_data, 'refresh_token' => refresh_token, 'token_expires_at' => token_expires_at}
|
68
|
-
})
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
|
5
|
-
module OmniAuth
|
6
|
-
module Strategies
|
7
|
-
class Hyves < OmniAuth::Strategies::OAuth
|
8
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
9
|
-
client_options = {
|
10
|
-
:request_token_path => request_token_path,
|
11
|
-
:authorize_path => "http://www.hyves.nl/api/authorize",
|
12
|
-
:access_token_path => access_token_path,
|
13
|
-
:http_method => :get,
|
14
|
-
:scheme => :header
|
15
|
-
}
|
16
|
-
super(app, :hyves, consumer_key, consumer_secret, client_options, options, &block)
|
17
|
-
end
|
18
|
-
|
19
|
-
def auth_hash
|
20
|
-
hash = user_hash(@access_token)
|
21
|
-
|
22
|
-
{
|
23
|
-
"provider" => "hyves",
|
24
|
-
"uid" => hash["userid"],
|
25
|
-
"user_info" => {
|
26
|
-
"name" => hash["firstname"] + " " + hash["lastname"],
|
27
|
-
"first_name" => hash["firstname"],
|
28
|
-
"last_name" => hash["lastname"]
|
29
|
-
},
|
30
|
-
"credentials" => {
|
31
|
-
"token" => @access_token.token,
|
32
|
-
"secret" => @access_token.secret
|
33
|
-
}
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
def user_hash(access_token)
|
38
|
-
rsp = MultiJson.decode( access_token.get("http://data.hyves-api.nl/?userid=#{access_token.params[:userid]}&ha_method=users.get&#{default_options}").body )
|
39
|
-
rsp["user"].first
|
40
|
-
end
|
41
|
-
|
42
|
-
def request_token_path
|
43
|
-
"http://data.hyves-api.nl/?#{request_token_options}&#{default_options}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def access_token_path
|
47
|
-
"http://data.hyves-api.nl/?#{access_token_options}&#{default_options}"
|
48
|
-
end
|
49
|
-
|
50
|
-
def default_options
|
51
|
-
to_params( { :ha_version => "2.0", :ha_format => "json", :ha_fancylayout => false } )
|
52
|
-
end
|
53
|
-
|
54
|
-
def request_token_options
|
55
|
-
to_params( { :methods => "users.get,friends.get,wwws.create", :ha_method => "auth.requesttoken", :strict_oauth_spec_response => true } )
|
56
|
-
end
|
57
|
-
|
58
|
-
def access_token_options
|
59
|
-
to_params( { :ha_method => "auth.accesstoken", :strict_oauth_spec_response => true } )
|
60
|
-
end
|
61
|
-
|
62
|
-
def to_params(options)
|
63
|
-
options.collect { |key, value| "#{key}=#{value}"}.join('&')
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to Identica via OAuth and retrieve basic
|
8
|
-
# user information.
|
9
|
-
#
|
10
|
-
# Usage:
|
11
|
-
#
|
12
|
-
# use OmniAuth::Strategies::Identica, 'consumerkey', 'consumersecret'
|
13
|
-
#
|
14
|
-
class Identica < OmniAuth::Strategies::OAuth
|
15
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
16
|
-
super(app, :identica, consumer_key, consumer_secret,
|
17
|
-
{:site => 'http://identi.ca',
|
18
|
-
:request_token_path => "/api/oauth/request_token",
|
19
|
-
:access_token_path => "/api/oauth/access_token",
|
20
|
-
:authorize_path => "/api/oauth/authorize"}, options, &block)
|
21
|
-
end
|
22
|
-
|
23
|
-
def auth_hash
|
24
|
-
OmniAuth::Utils.deep_merge(super, {
|
25
|
-
'uid' => user_hash['id'],
|
26
|
-
'user_info' => user_info,
|
27
|
-
'extra' => {'user_hash' => user_hash}
|
28
|
-
})
|
29
|
-
end
|
30
|
-
|
31
|
-
def user_info
|
32
|
-
user_hash = self.user_hash
|
33
|
-
|
34
|
-
{
|
35
|
-
'nickname' => user_hash['screen_name'],
|
36
|
-
'name' => user_hash['name'],
|
37
|
-
'location' => user_hash['location'],
|
38
|
-
'image' => user_hash['profile_image_url'],
|
39
|
-
'description' => user_hash['description'],
|
40
|
-
'urls' => {'Website' => user_hash['url']}
|
41
|
-
}
|
42
|
-
end
|
43
|
-
|
44
|
-
def user_hash
|
45
|
-
@user_hash ||= MultiJson.decode(@access_token.get('/api/account/verify_credentials.json').body)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
# Authenticate to Facebook utilizing OAuth 2.0 and retrieve
|
7
|
-
# basic user information.
|
8
|
-
#
|
9
|
-
# @example Basic Usage
|
10
|
-
# use OmniAuth::Strategies::Instagram, 'client_id', 'client_secret'
|
11
|
-
class Instagram < OAuth2
|
12
|
-
# @option options [String] :scope separate the scopes by a space
|
13
|
-
def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
|
14
|
-
client_options = {
|
15
|
-
:site => "https://api.instagram.com/",
|
16
|
-
:authorize_url => "/oauth/authorize",
|
17
|
-
:access_token_url => "/oauth/access_token"
|
18
|
-
}
|
19
|
-
|
20
|
-
super(app, :instagram, client_id, client_secret, client_options, options, &block)
|
21
|
-
end
|
22
|
-
|
23
|
-
def request_phase
|
24
|
-
options[:scope] ||= "basic"
|
25
|
-
options[:response_type] ||= 'code'
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
def callback_phase
|
30
|
-
options[:grant_type] ||= 'authorization_code'
|
31
|
-
super
|
32
|
-
end
|
33
|
-
|
34
|
-
def user_data
|
35
|
-
@data ||= MultiJson.decode(@access_token.get("/v1/users/self"))
|
36
|
-
end
|
37
|
-
|
38
|
-
def user_info
|
39
|
-
{
|
40
|
-
'nickname' => user_data['data']['username'],
|
41
|
-
'name' => user_data['data']['full_name'],
|
42
|
-
'image' => user_data['data']['profile_picture'],
|
43
|
-
'urls' => {}
|
44
|
-
}
|
45
|
-
end
|
46
|
-
|
47
|
-
def auth_hash
|
48
|
-
OmniAuth::Utils.deep_merge(super, {
|
49
|
-
'uid' => user_data['data']['id'],
|
50
|
-
'user_info' => user_info,
|
51
|
-
'extra' => {'user_hash' => user_data['data']}
|
52
|
-
})
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
class Instapaper < OmniAuth::Strategies::XAuth
|
7
|
-
|
8
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
9
|
-
client_options = {
|
10
|
-
:title => 'Instapaper',
|
11
|
-
:site => 'https://www.instapaper.com',
|
12
|
-
:access_token_path => '/api/1/oauth/access_token'
|
13
|
-
}
|
14
|
-
super(app, :instapaper, consumer_key, consumer_secret, client_options, options, &block)
|
15
|
-
end
|
16
|
-
|
17
|
-
protected
|
18
|
-
|
19
|
-
def user_data
|
20
|
-
@data ||= MultiJson.decode(@access_token.get('/api/1/account/verify_credentials').body)[0]
|
21
|
-
end
|
22
|
-
|
23
|
-
def user_info
|
24
|
-
{
|
25
|
-
'nickname' => user_data['username'],
|
26
|
-
'name' => user_data['username']
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
def auth_hash
|
31
|
-
OmniAuth::Utils.deep_merge(super, {
|
32
|
-
'uid' => user_data['user_id'],
|
33
|
-
'user_info' => user_info
|
34
|
-
})
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'multi_xml'
|
2
|
-
require 'omniauth/oauth'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
class LinkedIn < OmniAuth::Strategies::OAuth
|
7
|
-
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
8
|
-
client_options = {
|
9
|
-
:site => 'https://api.linkedin.com',
|
10
|
-
:request_token_path => '/uas/oauth/requestToken',
|
11
|
-
:access_token_path => '/uas/oauth/accessToken',
|
12
|
-
:authorize_path => '/uas/oauth/authorize',
|
13
|
-
:scheme => :header
|
14
|
-
}
|
15
|
-
|
16
|
-
client_options[:authorize_path] = '/uas/oauth/authenticate' unless options[:sign_in] == false
|
17
|
-
|
18
|
-
super(app, :linked_in, consumer_key, consumer_secret, client_options, options, &block)
|
19
|
-
end
|
20
|
-
|
21
|
-
def auth_hash
|
22
|
-
hash = user_hash(@access_token)
|
23
|
-
|
24
|
-
OmniAuth::Utils.deep_merge(super, {
|
25
|
-
'uid' => hash.delete('id'),
|
26
|
-
'user_info' => hash
|
27
|
-
})
|
28
|
-
end
|
29
|
-
|
30
|
-
def user_hash(access_token)
|
31
|
-
person = MultiXml.parse(@access_token.get('/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location,public-profile-url)').body)['person']
|
32
|
-
|
33
|
-
hash = {
|
34
|
-
'id' => person['id'],
|
35
|
-
'first_name' => person['first_name'],
|
36
|
-
'last_name' => person['last_name'],
|
37
|
-
'nickname' => person['public_profile_url'].split('/').last,
|
38
|
-
'location' => person['location']['name'],
|
39
|
-
'image' => person['picture_url'],
|
40
|
-
'description' => person['headline'],
|
41
|
-
'public_profile_url' => person['public_profile_url']
|
42
|
-
}
|
43
|
-
hash['urls']={}
|
44
|
-
member_urls = person['member_url_resources']['member_url']
|
45
|
-
if (!member_urls.nil?) and (!member_urls.empty?)
|
46
|
-
[member_urls].flatten.each do |url|
|
47
|
-
hash['urls']["#{url['name']}"]=url['url']
|
48
|
-
end
|
49
|
-
end
|
50
|
-
hash['urls']['LinkedIn'] = person['public_profile_url']
|
51
|
-
hash['name'] = "#{hash['first_name']} #{hash['last_name']}"
|
52
|
-
hash
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
require 'omniauth/oauth'
|
2
|
-
require 'multi_json'
|
3
|
-
|
4
|
-
module OmniAuth
|
5
|
-
module Strategies
|
6
|
-
#
|
7
|
-
# Authenticate to Vkontakte utilizing OAuth 2.0 and retrieve
|
8
|
-
# basic user information.
|
9
|
-
# documentation available here:
|
10
|
-
# http://api.mail.ru/docs/guides/oauth/sites/
|
11
|
-
#
|
12
|
-
# @example Basic Usage
|
13
|
-
# use OmniAuth::Strategies::Mailru, 'API Key', 'Secret Key', :private_key => 'Private Key'
|
14
|
-
class Mailru < OAuth2
|
15
|
-
# @param [Rack Application] app standard middleware application parameter
|
16
|
-
# @param [String] api_key the application id as [registered in Mailru]
|
17
|
-
# @param [String] secret_key the application secret as [registered in Mailru]
|
18
|
-
def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
|
19
|
-
client_options = {
|
20
|
-
:site => 'https://connect.mail.ru',
|
21
|
-
:authorize_path => '/oauth/authorize',
|
22
|
-
:access_token_path => '/oauth/token'
|
23
|
-
}
|
24
|
-
|
25
|
-
@private_key = options[:private_key]
|
26
|
-
|
27
|
-
super(app, :mailru, api_key, secret_key, client_options, options, &block)
|
28
|
-
end
|
29
|
-
|
30
|
-
protected
|
31
|
-
|
32
|
-
def request_phase
|
33
|
-
options[:response_type] ||= 'code'
|
34
|
-
super
|
35
|
-
end
|
36
|
-
|
37
|
-
def calculate_signature(params)
|
38
|
-
str = params['uids'] + (params.sort.collect { |c| "#{c[0]}=#{c[1]}" }).join('') + @private_key
|
39
|
-
Digest::MD5.hexdigest(str)
|
40
|
-
end
|
41
|
-
|
42
|
-
def user_data
|
43
|
-
request_params = {
|
44
|
-
'method' => 'users.getInfo',
|
45
|
-
'app_id' => client_id,
|
46
|
-
'session_key' => @access_token.token,
|
47
|
-
'uids' => @access_token['x_mailru_vid']
|
48
|
-
}
|
49
|
-
|
50
|
-
request_params.merge!('sig' => calculate_signature(request_params))
|
51
|
-
@data ||= MultiJson.decode(client.request(:get, 'http://www.appsmail.ru/platform/api', request_params))[0]
|
52
|
-
end
|
53
|
-
|
54
|
-
#"uid": "15410773191172635989",
|
55
|
-
#"first_name": "Евгений",
|
56
|
-
#"last_name": "Маслов",
|
57
|
-
#"nick": "maslov",
|
58
|
-
#"sex": 0,
|
59
|
-
#"birthday": "15.02.1980",
|
60
|
-
#"has_pic": 1,
|
61
|
-
#"pic": "http://avt.appsmail.ru/mail/emaslov/_avatar",
|
62
|
-
#"pic_small": "http://avt.appsmail.ru/mail/emaslov/_avatarsmall",
|
63
|
-
#"pic_big": "http://avt.appsmail.ru/mail/emaslov/_avatarbig",
|
64
|
-
#"link": "http://my.mail.ru/mail/emaslov/",
|
65
|
-
#"referer_type": "",
|
66
|
-
#"referer_id": "",
|
67
|
-
#"is_online": 1,
|
68
|
-
#"vip" : 1,
|
69
|
-
#"location": {
|
70
|
-
# "country": {
|
71
|
-
# "name": "Россия",
|
72
|
-
# "id": "24"
|
73
|
-
# },
|
74
|
-
# "city": {
|
75
|
-
# "name": "Москва",
|
76
|
-
# "id": "25"
|
77
|
-
# },
|
78
|
-
# "region": {
|
79
|
-
# "name": "Москва",
|
80
|
-
# "id": "999999"
|
81
|
-
# }
|
82
|
-
#}
|
83
|
-
|
84
|
-
def user_info
|
85
|
-
{
|
86
|
-
'nickname' => user_data['nick'],
|
87
|
-
'email' => user_data['email'],
|
88
|
-
'first_name' => user_data["first_name"],
|
89
|
-
'last_name' => user_data["last_name"],
|
90
|
-
'name' => "#{user_data['first_name']} #{user_data['last_name']}",
|
91
|
-
'image' => @data['pic'],
|
92
|
-
'urls' => {
|
93
|
-
'Mailru' => user_data["link"]
|
94
|
-
}
|
95
|
-
}
|
96
|
-
end
|
97
|
-
|
98
|
-
def auth_hash
|
99
|
-
OmniAuth::Utils.deep_merge(super, {
|
100
|
-
'uid' => user_data['uid'],
|
101
|
-
'user_info' => user_info,
|
102
|
-
'extra' => {'user_hash' => user_data}
|
103
|
-
})
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|