omniauth 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of omniauth might be problematic. Click here for more details.
- data/.autotest +9 -0
- data/.document +5 -0
- data/.gitignore +36 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/.yardopts +4 -0
- data/Gemfile +6 -1
- data/README.markdown +121 -0
- data/Rakefile +50 -2
- data/lib/omniauth/version.rb +18 -4
- data/oa-basic/.gemtest +0 -0
- data/oa-basic/.rspec +3 -0
- data/oa-basic/.yardopts +4 -0
- data/oa-basic/LICENSE +19 -0
- data/oa-basic/README.rdoc +34 -0
- data/oa-basic/Rakefile +6 -0
- data/oa-basic/lib/oa-basic.rb +1 -0
- data/oa-basic/lib/omniauth/basic.rb +8 -0
- data/oa-basic/lib/omniauth/strategies/http_basic.rb +56 -0
- data/oa-basic/lib/omniauth/version.rb +19 -0
- data/oa-basic/oa-basic.gemspec +28 -0
- data/oa-basic/spec/omniauth/strategies/basic_spec.rb +7 -0
- data/oa-basic/spec/spec_helper.rb +11 -0
- data/oa-core/.gemtest +0 -0
- data/oa-core/.rspec +3 -0
- data/oa-core/.yardopts +4 -0
- data/oa-core/LICENSE +19 -0
- data/oa-core/Rakefile +6 -0
- data/oa-core/autotest/discover.rb +1 -0
- data/oa-core/lib/oa-core.rb +1 -0
- data/oa-core/lib/omniauth/builder.rb +33 -0
- data/oa-core/lib/omniauth/core.rb +135 -0
- data/oa-core/lib/omniauth/form.rb +184 -0
- data/oa-core/lib/omniauth/strategy.rb +227 -0
- data/oa-core/lib/omniauth/test.rb +12 -0
- data/oa-core/lib/omniauth/test/phony_session.rb +8 -0
- data/oa-core/lib/omniauth/test/strategy_macros.rb +34 -0
- data/oa-core/lib/omniauth/test/strategy_test_case.rb +49 -0
- data/oa-core/lib/omniauth/version.rb +19 -0
- data/oa-core/oa-core.gemspec +24 -0
- data/oa-core/spec/omniauth/builder_spec.rb +20 -0
- data/oa-core/spec/omniauth/core_spec.rb +79 -0
- data/oa-core/spec/omniauth/strategy_spec.rb +358 -0
- data/oa-core/spec/spec_helper.rb +12 -0
- data/oa-enterprise/.gemtest +0 -0
- data/oa-enterprise/.rspec +3 -0
- data/oa-enterprise/.yardopts +4 -0
- data/oa-enterprise/LICENSE +19 -0
- data/oa-enterprise/README.rdoc +82 -0
- data/oa-enterprise/Rakefile +6 -0
- data/oa-enterprise/lib/oa-enterprise.rb +1 -0
- data/oa-enterprise/lib/omniauth/enterprise.rb +8 -0
- data/oa-enterprise/lib/omniauth/strategies/cas.rb +47 -0
- data/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb +98 -0
- data/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb +84 -0
- data/oa-enterprise/lib/omniauth/strategies/ldap.rb +111 -0
- data/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb +279 -0
- data/oa-enterprise/lib/omniauth/version.rb +19 -0
- data/oa-enterprise/oa-enterprise.gemspec +32 -0
- data/oa-enterprise/spec/fixtures/cas_failure.xml +4 -0
- data/oa-enterprise/spec/fixtures/cas_success.xml +8 -0
- data/oa-enterprise/spec/omniauth/strategies/cas_spec.rb +94 -0
- data/oa-enterprise/spec/spec_helper.rb +14 -0
- data/oa-more/.gemtest +0 -0
- data/oa-more/.rspec +3 -0
- data/oa-more/.yardopts +4 -0
- data/oa-more/LICENSE +19 -0
- data/oa-more/README.rdoc +22 -0
- data/oa-more/Rakefile +6 -0
- data/oa-more/lib/oa-more.rb +1 -0
- data/oa-more/lib/omniauth/more.rb +9 -0
- data/oa-more/lib/omniauth/strategies/flickr.rb +86 -0
- data/oa-more/lib/omniauth/strategies/windows_live.rb +39 -0
- data/oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb +1143 -0
- data/oa-more/lib/omniauth/strategies/yupoo.rb +67 -0
- data/oa-more/lib/omniauth/version.rb +19 -0
- data/oa-more/oa-more.gemspec +30 -0
- data/oa-more/spec/omniauth/strategies/flickr_spec.rb +7 -0
- data/oa-more/spec/spec_helper.rb +11 -0
- data/oa-oauth/.gemtest +0 -0
- data/oa-oauth/.rspec +3 -0
- data/oa-oauth/.yardopts +4 -0
- data/oa-oauth/LICENSE +19 -0
- data/oa-oauth/README.rdoc +35 -0
- data/oa-oauth/Rakefile +6 -0
- data/oa-oauth/autotest/discover.rb +1 -0
- data/oa-oauth/lib/oa-oauth.rb +1 -0
- data/oa-oauth/lib/omniauth/oauth.rb +53 -0
- data/oa-oauth/lib/omniauth/strategies/bitly.rb +46 -0
- data/oa-oauth/lib/omniauth/strategies/dailymile.rb +64 -0
- data/oa-oauth/lib/omniauth/strategies/doit.rb +60 -0
- data/oa-oauth/lib/omniauth/strategies/dopplr.rb +53 -0
- data/oa-oauth/lib/omniauth/strategies/douban.rb +60 -0
- data/oa-oauth/lib/omniauth/strategies/evernote.rb +54 -0
- data/oa-oauth/lib/omniauth/strategies/facebook.rb +70 -0
- data/oa-oauth/lib/omniauth/strategies/foursquare.rb +62 -0
- data/oa-oauth/lib/omniauth/strategies/github.rb +50 -0
- data/oa-oauth/lib/omniauth/strategies/goodreads.rb +44 -0
- data/oa-oauth/lib/omniauth/strategies/google.rb +80 -0
- data/oa-oauth/lib/omniauth/strategies/gowalla.rb +64 -0
- data/oa-oauth/lib/omniauth/strategies/hyves.rb +67 -0
- data/oa-oauth/lib/omniauth/strategies/identica.rb +49 -0
- data/oa-oauth/lib/omniauth/strategies/instagram.rb +56 -0
- data/oa-oauth/lib/omniauth/strategies/instapaper.rb +40 -0
- data/oa-oauth/lib/omniauth/strategies/linked_in.rb +55 -0
- data/oa-oauth/lib/omniauth/strategies/meetup.rb +56 -0
- data/oa-oauth/lib/omniauth/strategies/miso.rb +41 -0
- data/oa-oauth/lib/omniauth/strategies/mixi.rb +59 -0
- data/oa-oauth/lib/omniauth/strategies/netflix.rb +65 -0
- data/oa-oauth/lib/omniauth/strategies/oauth.rb +85 -0
- data/oa-oauth/lib/omniauth/strategies/oauth2.rb +98 -0
- data/oa-oauth/lib/omniauth/strategies/qzone.rb +69 -0
- data/oa-oauth/lib/omniauth/strategies/rdio.rb +45 -0
- data/oa-oauth/lib/omniauth/strategies/renren.rb +87 -0
- data/oa-oauth/lib/omniauth/strategies/salesforce.rb +44 -0
- data/oa-oauth/lib/omniauth/strategies/smug_mug.rb +42 -0
- data/oa-oauth/lib/omniauth/strategies/sound_cloud.rb +46 -0
- data/oa-oauth/lib/omniauth/strategies/t163.rb +57 -0
- data/oa-oauth/lib/omniauth/strategies/teambox.rb +49 -0
- data/oa-oauth/lib/omniauth/strategies/thirty_seven_signals.rb +41 -0
- data/oa-oauth/lib/omniauth/strategies/tqq.rb +64 -0
- data/oa-oauth/lib/omniauth/strategies/trade_me.rb +45 -0
- data/oa-oauth/lib/omniauth/strategies/trip_it.rb +22 -0
- data/oa-oauth/lib/omniauth/strategies/tsina.rb +79 -0
- data/oa-oauth/lib/omniauth/strategies/tsohu.rb +57 -0
- data/oa-oauth/lib/omniauth/strategies/tumblr.rb +60 -0
- data/oa-oauth/lib/omniauth/strategies/twitter.rb +57 -0
- data/oa-oauth/lib/omniauth/strategies/type_pad.rb +76 -0
- data/oa-oauth/lib/omniauth/strategies/vimeo.rb +54 -0
- data/oa-oauth/lib/omniauth/strategies/vkontakte.rb +84 -0
- data/oa-oauth/lib/omniauth/strategies/xauth.rb +67 -0
- data/oa-oauth/lib/omniauth/strategies/yahoo.rb +55 -0
- data/oa-oauth/lib/omniauth/strategies/yammer.rb +43 -0
- data/oa-oauth/lib/omniauth/strategies/you_tube.rb +73 -0
- data/oa-oauth/lib/omniauth/version.rb +19 -0
- data/oa-oauth/oa-oauth.gemspec +33 -0
- data/oa-oauth/spec/fixtures/basecamp_200.xml +24 -0
- data/oa-oauth/spec/fixtures/campfire_200.json +10 -0
- data/oa-oauth/spec/omniauth/strategies/bitly_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/dailymile_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/doit_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/dopplr_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/douban_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/evernote_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/facebook_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/foursquare_spec.rb +18 -0
- data/oa-oauth/spec/omniauth/strategies/github_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/goodreads_spec.rb +6 -0
- data/oa-oauth/spec/omniauth/strategies/google_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/gowalla_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/hyves_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/identica_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/linked_in_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/meetup_spec.rb +14 -0
- data/oa-oauth/spec/omniauth/strategies/miso_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/netflix_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/oauth2_spec.rb +0 -0
- data/oa-oauth/spec/omniauth/strategies/oauth_spec.rb +77 -0
- data/oa-oauth/spec/omniauth/strategies/rdio_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/salesforce_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/smug_mug_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/sound_cloud_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/t163_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/teambox_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/thirty_seven_signals_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/trade_me_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/trip_it_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/tsina_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/tumblr_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/twitter_spec.rb +20 -0
- data/oa-oauth/spec/omniauth/strategies/type_pad_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/vimeo_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/vkontakte_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/yahoo_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/yammer_spec.rb +5 -0
- data/oa-oauth/spec/omniauth/strategies/you_tube_spec.rb +5 -0
- data/oa-oauth/spec/spec_helper.rb +27 -0
- data/oa-oauth/spec/support/shared_examples.rb +29 -0
- data/oa-openid/.gemtest +0 -0
- data/oa-openid/.rspec +3 -0
- data/oa-openid/.yardopts +4 -0
- data/oa-openid/LICENSE +19 -0
- data/oa-openid/README.rdoc +51 -0
- data/oa-openid/Rakefile +6 -0
- data/oa-openid/lib/oa-openid.rb +1 -0
- data/oa-openid/lib/omniauth/openid.rb +59 -0
- data/oa-openid/lib/omniauth/openid/gapps.rb +32 -0
- data/oa-openid/lib/omniauth/strategies/google_apps.rb +23 -0
- data/oa-openid/lib/omniauth/strategies/open_id.rb +132 -0
- data/oa-openid/lib/omniauth/version.rb +19 -0
- data/oa-openid/oa-openid.gemspec +29 -0
- data/oa-openid/spec/omniauth/strategies/open_id_spec.rb +71 -0
- data/oa-openid/spec/spec_helper.rb +14 -0
- data/omniauth.gemspec +3 -3
- data/tasks/all.rb +134 -0
- metadata +199 -9
- data/README.rdoc +0 -17
@@ -0,0 +1,64 @@
|
|
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 request_phase
|
34
|
+
options[:scope] ||= "read"
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
def user_info
|
39
|
+
{
|
40
|
+
'name' => "#{user_data['first_name']} #{user_data['last_name']}",
|
41
|
+
'nickname' => user_data["username"],
|
42
|
+
'first_name' => user_data["first_name"],
|
43
|
+
'last_name' => user_data["last_name"],
|
44
|
+
'location' => user_data["hometown"],
|
45
|
+
'description' => user_data["bio"],
|
46
|
+
'image' => user_data["image_url"],
|
47
|
+
'phone' => nil,
|
48
|
+
'urls' => {
|
49
|
+
'Gowalla' => "http://www.gowalla.com#{user_data['url']}",
|
50
|
+
'Website' => user_data["website"]
|
51
|
+
}
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def auth_hash
|
56
|
+
OmniAuth::Utils.deep_merge(super, {
|
57
|
+
'uid' => user_data["url"].split('/').last,
|
58
|
+
'user_info' => user_info,
|
59
|
+
'extra' => {'user_hash' => user_data}
|
60
|
+
})
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,67 @@
|
|
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
|
@@ -0,0 +1,49 @@
|
|
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
|
@@ -0,0 +1,56 @@
|
|
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
|
@@ -0,0 +1,40 @@
|
|
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
|
+
|
@@ -0,0 +1,55 @@
|
|
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 = MulitXml.parse(@access_token.get('/v1/people/~:(id,first-name,last-name,headline,member-url-resources,picture-url,location,public-profile-url)').body).xpath('person')
|
32
|
+
|
33
|
+
hash = {
|
34
|
+
'id' => person.xpath('id').text,
|
35
|
+
'first_name' => person.xpath('first-name').text,
|
36
|
+
'last_name' => person.xpath('last-name').text,
|
37
|
+
'nickname' => person.xpath('public-profile-url').text.split('/').last,
|
38
|
+
'location' => person.xpath('location/name').text,
|
39
|
+
'image' => person.xpath('picture-url').text,
|
40
|
+
'description' => person.xpath('headline').text,
|
41
|
+
'public_profile_url' => person.xpath('public-profile-url').text,
|
42
|
+
'urls' => person.css('member-url-resources member-url').inject({}) do |h,element|
|
43
|
+
h[element.xpath('name').text] = element.xpath('url').text
|
44
|
+
h
|
45
|
+
end
|
46
|
+
}
|
47
|
+
|
48
|
+
hash['urls']['LinkedIn'] = person.xpath('public-profile-url').text
|
49
|
+
hash['name'] = "#{hash['first_name']} #{hash['last_name']}"
|
50
|
+
|
51
|
+
hash
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
#
|
7
|
+
# Authenticate with Meetup via OAuth and retrieve an access token for API usage
|
8
|
+
#
|
9
|
+
# Usage:
|
10
|
+
#
|
11
|
+
# use OmniAuth::Strategies::Meetup, 'consumerkey', 'consumersecret'
|
12
|
+
#
|
13
|
+
class Meetup < OmniAuth::Strategies::OAuth
|
14
|
+
# Initialize meetup middleware
|
15
|
+
# @param [Rack Application] app standard middleware application parameter
|
16
|
+
# @param [String] consumer_key the application consumer id
|
17
|
+
# @param [String] consumer_secret the application consumer secret
|
18
|
+
# @option options [Boolean, true] :sign_in When true, use a sign-in flow instead of the authorization flow.
|
19
|
+
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
20
|
+
auth_path = (options[:sign_in] == false) ? 'http://www.meetup.com/authorize' : 'http://www.meetup.com/authenticate'
|
21
|
+
|
22
|
+
super(app, :meetup, consumer_key, consumer_secret,
|
23
|
+
{ :request_token_path => "https://api.meetup.com/oauth/request",
|
24
|
+
:access_token_path => "https://api.meetup.com/oauth/access",
|
25
|
+
:authorize_path => auth_path }, options)
|
26
|
+
end
|
27
|
+
|
28
|
+
def auth_hash
|
29
|
+
OmniAuth::Utils.deep_merge(super, {
|
30
|
+
'uid' => member['id'],
|
31
|
+
'user_info' => user_info,
|
32
|
+
'extra' => { 'user_hash' => member }
|
33
|
+
})
|
34
|
+
end
|
35
|
+
|
36
|
+
def user_info
|
37
|
+
{
|
38
|
+
'name' => member['name'],
|
39
|
+
'image' => member['photo_url'],
|
40
|
+
'location' => member['city'],
|
41
|
+
'urls' => {
|
42
|
+
'profile' => member['link']
|
43
|
+
}
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def member
|
48
|
+
@member ||= parse(@access_token.get('https://api.meetup.com/members.json?relation=self').body)['results'][0]
|
49
|
+
end
|
50
|
+
|
51
|
+
def parse(response)
|
52
|
+
MultiJson.decode(response)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
#
|
7
|
+
# Authenticate to Miso via OAuth and retrieve basic
|
8
|
+
# user information.
|
9
|
+
#
|
10
|
+
# Usage:
|
11
|
+
#
|
12
|
+
# use OmniAuth::Strategies::Miso, 'consumerkey', 'consumersecret'
|
13
|
+
#
|
14
|
+
class Miso < OmniAuth::Strategies::OAuth
|
15
|
+
def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
|
16
|
+
super(app, :miso, consumer_key, consumer_secret, {:site => 'https://gomiso.com'}, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def auth_hash
|
20
|
+
OmniAuth::Utils.deep_merge(super, {
|
21
|
+
'uid' => user_hash['id'],
|
22
|
+
'user_info' => user_info,
|
23
|
+
'extra' => {'user_hash' => user_hash}
|
24
|
+
})
|
25
|
+
end
|
26
|
+
|
27
|
+
def user_info
|
28
|
+
{
|
29
|
+
'nickname' => user_hash['username'],
|
30
|
+
'name' => user_hash['full_name'],
|
31
|
+
'image' => user_hash['profile_image_url'],
|
32
|
+
'description' => user_hash['tagline'],
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def user_hash
|
37
|
+
@user_hash ||= MultiJson.decode(@access_token.get('/api/oauth/v1/users/show.json').body)['user']
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,59 @@
|
|
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::Mixi, 'client_id', 'client_secret'
|
11
|
+
class Mixi < 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://mixi.jp/",
|
16
|
+
:authorize_url => "/connect_authorize.pl",
|
17
|
+
:access_token_url => "https://secure.mixi-platform.com/2/token"
|
18
|
+
}
|
19
|
+
|
20
|
+
super(app, :mixi, client_id, client_secret, client_options, options, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def user_data
|
24
|
+
@data ||= MultiJson.decode(@access_token.get(
|
25
|
+
"http://api.mixi-platform.com/2/people/@me/@self",
|
26
|
+
{'oauth_token' => @access_token.token}
|
27
|
+
))
|
28
|
+
end
|
29
|
+
|
30
|
+
def request_phase
|
31
|
+
options[:scope] ||= "r_profile"
|
32
|
+
options[:display] ||= "pc"
|
33
|
+
options[:response_type] ||= 'code'
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
def callback_phase
|
38
|
+
options[:grant_type] ||= 'authorization_code'
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
def user_info
|
43
|
+
{
|
44
|
+
'nickname' => user_data['entry']['displayName'],
|
45
|
+
'image' => user_data['entry']['thumbnailUrl'],
|
46
|
+
'urls' => {:profile => user_data['entry']['profileUrl']}
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def auth_hash
|
51
|
+
OmniAuth::Utils.deep_merge(super, {
|
52
|
+
'uid' => user_data['entry']['id'],
|
53
|
+
'user_info' => user_info,
|
54
|
+
'extra' => {'user_hash' => user_data['entry']}
|
55
|
+
})
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|