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.

Files changed (189) hide show
  1. data/README.md +62 -34
  2. data/lib/omniauth/version.rb +3 -3
  3. metadata +74 -228
  4. data/Gemfile +0 -12
  5. data/Rakefile +0 -51
  6. data/oa-basic/Gemfile +0 -7
  7. data/oa-basic/LICENSE +0 -19
  8. data/oa-basic/README.rdoc +0 -34
  9. data/oa-basic/Rakefile +0 -6
  10. data/oa-basic/lib/oa-basic.rb +0 -1
  11. data/oa-basic/lib/omniauth/basic.rb +0 -8
  12. data/oa-basic/lib/omniauth/strategies/http_basic.rb +0 -56
  13. data/oa-basic/lib/omniauth/version.rb +0 -19
  14. data/oa-basic/oa-basic.gemspec +0 -27
  15. data/oa-basic/spec/omniauth/strategies/basic_spec.rb +0 -7
  16. data/oa-basic/spec/spec_helper.rb +0 -11
  17. data/oa-core/Gemfile +0 -3
  18. data/oa-core/LICENSE +0 -19
  19. data/oa-core/Rakefile +0 -6
  20. data/oa-core/autotest/discover.rb +0 -1
  21. data/oa-core/lib/oa-core.rb +0 -1
  22. data/oa-core/lib/omniauth/builder.rb +0 -33
  23. data/oa-core/lib/omniauth/core.rb +0 -135
  24. data/oa-core/lib/omniauth/form.rb +0 -186
  25. data/oa-core/lib/omniauth/strategy.rb +0 -227
  26. data/oa-core/lib/omniauth/test.rb +0 -12
  27. data/oa-core/lib/omniauth/test/phony_session.rb +0 -8
  28. data/oa-core/lib/omniauth/test/strategy_macros.rb +0 -34
  29. data/oa-core/lib/omniauth/test/strategy_test_case.rb +0 -49
  30. data/oa-core/lib/omniauth/version.rb +0 -19
  31. data/oa-core/oa-core.gemspec +0 -24
  32. data/oa-core/spec/omniauth/builder_spec.rb +0 -20
  33. data/oa-core/spec/omniauth/core_spec.rb +0 -79
  34. data/oa-core/spec/omniauth/strategy_spec.rb +0 -363
  35. data/oa-core/spec/spec_helper.rb +0 -12
  36. data/oa-enterprise/Gemfile +0 -7
  37. data/oa-enterprise/LICENSE +0 -19
  38. data/oa-enterprise/README.rdoc +0 -82
  39. data/oa-enterprise/Rakefile +0 -6
  40. data/oa-enterprise/lib/oa-enterprise.rb +0 -1
  41. data/oa-enterprise/lib/omniauth/enterprise.rb +0 -8
  42. data/oa-enterprise/lib/omniauth/strategies/cas.rb +0 -47
  43. data/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb +0 -98
  44. data/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb +0 -91
  45. data/oa-enterprise/lib/omniauth/strategies/ldap.rb +0 -111
  46. data/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb +0 -279
  47. data/oa-enterprise/lib/omniauth/version.rb +0 -19
  48. data/oa-enterprise/oa-enterprise.gemspec +0 -31
  49. data/oa-enterprise/spec/fixtures/cas_failure.xml +0 -4
  50. data/oa-enterprise/spec/fixtures/cas_success.xml +0 -8
  51. data/oa-enterprise/spec/omniauth/strategies/cas_spec.rb +0 -94
  52. data/oa-enterprise/spec/omniauth/strategies/ldap_spec.rb +0 -41
  53. data/oa-enterprise/spec/spec_helper.rb +0 -14
  54. data/oa-more/Gemfile +0 -7
  55. data/oa-more/LICENSE +0 -19
  56. data/oa-more/README.rdoc +0 -22
  57. data/oa-more/Rakefile +0 -6
  58. data/oa-more/lib/oa-more.rb +0 -1
  59. data/oa-more/lib/omniauth/more.rb +0 -11
  60. data/oa-more/lib/omniauth/strategies/draugiem.rb +0 -104
  61. data/oa-more/lib/omniauth/strategies/flickr.rb +0 -86
  62. data/oa-more/lib/omniauth/strategies/ign.rb +0 -93
  63. data/oa-more/lib/omniauth/strategies/windows_live.rb +0 -39
  64. data/oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb +0 -1143
  65. data/oa-more/lib/omniauth/strategies/yupoo.rb +0 -67
  66. data/oa-more/lib/omniauth/version.rb +0 -19
  67. data/oa-more/oa-more.gemspec +0 -29
  68. data/oa-more/spec/omniauth/strategies/draugiem_spec.rb +0 -51
  69. data/oa-more/spec/omniauth/strategies/flickr_spec.rb +0 -7
  70. data/oa-more/spec/spec_helper.rb +0 -11
  71. data/oa-oauth/Gemfile +0 -7
  72. data/oa-oauth/LICENSE +0 -19
  73. data/oa-oauth/README.rdoc +0 -35
  74. data/oa-oauth/Rakefile +0 -6
  75. data/oa-oauth/autotest/discover.rb +0 -1
  76. data/oa-oauth/lib/oa-oauth.rb +0 -1
  77. data/oa-oauth/lib/omniauth/oauth.rb +0 -56
  78. data/oa-oauth/lib/omniauth/strategies/bitly.rb +0 -46
  79. data/oa-oauth/lib/omniauth/strategies/dailymile.rb +0 -64
  80. data/oa-oauth/lib/omniauth/strategies/doit.rb +0 -60
  81. data/oa-oauth/lib/omniauth/strategies/dopplr.rb +0 -53
  82. data/oa-oauth/lib/omniauth/strategies/douban.rb +0 -60
  83. data/oa-oauth/lib/omniauth/strategies/evernote.rb +0 -54
  84. data/oa-oauth/lib/omniauth/strategies/facebook.rb +0 -70
  85. data/oa-oauth/lib/omniauth/strategies/foursquare.rb +0 -62
  86. data/oa-oauth/lib/omniauth/strategies/github.rb +0 -50
  87. data/oa-oauth/lib/omniauth/strategies/goodreads.rb +0 -44
  88. data/oa-oauth/lib/omniauth/strategies/google.rb +0 -80
  89. data/oa-oauth/lib/omniauth/strategies/gowalla.rb +0 -72
  90. data/oa-oauth/lib/omniauth/strategies/hyves.rb +0 -67
  91. data/oa-oauth/lib/omniauth/strategies/identica.rb +0 -49
  92. data/oa-oauth/lib/omniauth/strategies/instagram.rb +0 -56
  93. data/oa-oauth/lib/omniauth/strategies/instapaper.rb +0 -40
  94. data/oa-oauth/lib/omniauth/strategies/linked_in.rb +0 -56
  95. data/oa-oauth/lib/omniauth/strategies/mailru.rb +0 -107
  96. data/oa-oauth/lib/omniauth/strategies/meetup.rb +0 -56
  97. data/oa-oauth/lib/omniauth/strategies/miso.rb +0 -41
  98. data/oa-oauth/lib/omniauth/strategies/mixi.rb +0 -59
  99. data/oa-oauth/lib/omniauth/strategies/netflix.rb +0 -65
  100. data/oa-oauth/lib/omniauth/strategies/oauth.rb +0 -83
  101. data/oa-oauth/lib/omniauth/strategies/oauth2.rb +0 -91
  102. data/oa-oauth/lib/omniauth/strategies/plurk.rb +0 -58
  103. data/oa-oauth/lib/omniauth/strategies/qzone.rb +0 -69
  104. data/oa-oauth/lib/omniauth/strategies/rdio.rb +0 -45
  105. data/oa-oauth/lib/omniauth/strategies/renren.rb +0 -87
  106. data/oa-oauth/lib/omniauth/strategies/salesforce.rb +0 -44
  107. data/oa-oauth/lib/omniauth/strategies/smug_mug.rb +0 -42
  108. data/oa-oauth/lib/omniauth/strategies/sound_cloud.rb +0 -46
  109. data/oa-oauth/lib/omniauth/strategies/t163.rb +0 -57
  110. data/oa-oauth/lib/omniauth/strategies/taobao.rb +0 -79
  111. data/oa-oauth/lib/omniauth/strategies/teambox.rb +0 -49
  112. data/oa-oauth/lib/omniauth/strategies/thirty_seven_signals.rb +0 -41
  113. data/oa-oauth/lib/omniauth/strategies/tqq.rb +0 -64
  114. data/oa-oauth/lib/omniauth/strategies/trade_me.rb +0 -45
  115. data/oa-oauth/lib/omniauth/strategies/trip_it.rb +0 -22
  116. data/oa-oauth/lib/omniauth/strategies/tsina.rb +0 -79
  117. data/oa-oauth/lib/omniauth/strategies/tsohu.rb +0 -57
  118. data/oa-oauth/lib/omniauth/strategies/tumblr.rb +0 -60
  119. data/oa-oauth/lib/omniauth/strategies/twitter.rb +0 -57
  120. data/oa-oauth/lib/omniauth/strategies/type_pad.rb +0 -76
  121. data/oa-oauth/lib/omniauth/strategies/vimeo.rb +0 -54
  122. data/oa-oauth/lib/omniauth/strategies/vkontakte.rb +0 -87
  123. data/oa-oauth/lib/omniauth/strategies/xauth.rb +0 -67
  124. data/oa-oauth/lib/omniauth/strategies/yahoo.rb +0 -55
  125. data/oa-oauth/lib/omniauth/strategies/yammer.rb +0 -43
  126. data/oa-oauth/lib/omniauth/strategies/you_tube.rb +0 -73
  127. data/oa-oauth/lib/omniauth/version.rb +0 -19
  128. data/oa-oauth/oa-oauth.gemspec +0 -32
  129. data/oa-oauth/spec/fixtures/basecamp_200.xml +0 -24
  130. data/oa-oauth/spec/fixtures/campfire_200.json +0 -10
  131. data/oa-oauth/spec/omniauth/strategies/bitly_spec.rb +0 -5
  132. data/oa-oauth/spec/omniauth/strategies/dailymile_spec.rb +0 -5
  133. data/oa-oauth/spec/omniauth/strategies/doit_spec.rb +0 -5
  134. data/oa-oauth/spec/omniauth/strategies/dopplr_spec.rb +0 -5
  135. data/oa-oauth/spec/omniauth/strategies/douban_spec.rb +0 -5
  136. data/oa-oauth/spec/omniauth/strategies/evernote_spec.rb +0 -5
  137. data/oa-oauth/spec/omniauth/strategies/facebook_spec.rb +0 -5
  138. data/oa-oauth/spec/omniauth/strategies/foursquare_spec.rb +0 -18
  139. data/oa-oauth/spec/omniauth/strategies/github_spec.rb +0 -5
  140. data/oa-oauth/spec/omniauth/strategies/goodreads_spec.rb +0 -6
  141. data/oa-oauth/spec/omniauth/strategies/google_spec.rb +0 -5
  142. data/oa-oauth/spec/omniauth/strategies/gowalla_spec.rb +0 -5
  143. data/oa-oauth/spec/omniauth/strategies/hyves_spec.rb +0 -5
  144. data/oa-oauth/spec/omniauth/strategies/identica_spec.rb +0 -5
  145. data/oa-oauth/spec/omniauth/strategies/linked_in_spec.rb +0 -5
  146. data/oa-oauth/spec/omniauth/strategies/mailru_spec.rb +0 -5
  147. data/oa-oauth/spec/omniauth/strategies/meetup_spec.rb +0 -14
  148. data/oa-oauth/spec/omniauth/strategies/miso_spec.rb +0 -5
  149. data/oa-oauth/spec/omniauth/strategies/netflix_spec.rb +0 -5
  150. data/oa-oauth/spec/omniauth/strategies/oauth2_spec.rb +0 -0
  151. data/oa-oauth/spec/omniauth/strategies/oauth_spec.rb +0 -77
  152. data/oa-oauth/spec/omniauth/strategies/plurk_spec.rb +0 -5
  153. data/oa-oauth/spec/omniauth/strategies/rdio_spec.rb +0 -5
  154. data/oa-oauth/spec/omniauth/strategies/salesforce_spec.rb +0 -5
  155. data/oa-oauth/spec/omniauth/strategies/smug_mug_spec.rb +0 -5
  156. data/oa-oauth/spec/omniauth/strategies/sound_cloud_spec.rb +0 -5
  157. data/oa-oauth/spec/omniauth/strategies/t163_spec.rb +0 -5
  158. data/oa-oauth/spec/omniauth/strategies/taobao_spec.rb +0 -5
  159. data/oa-oauth/spec/omniauth/strategies/teambox_spec.rb +0 -5
  160. data/oa-oauth/spec/omniauth/strategies/thirty_seven_signals_spec.rb +0 -5
  161. data/oa-oauth/spec/omniauth/strategies/trade_me_spec.rb +0 -5
  162. data/oa-oauth/spec/omniauth/strategies/trip_it_spec.rb +0 -5
  163. data/oa-oauth/spec/omniauth/strategies/tsina_spec.rb +0 -5
  164. data/oa-oauth/spec/omniauth/strategies/tumblr_spec.rb +0 -5
  165. data/oa-oauth/spec/omniauth/strategies/twitter_spec.rb +0 -20
  166. data/oa-oauth/spec/omniauth/strategies/type_pad_spec.rb +0 -5
  167. data/oa-oauth/spec/omniauth/strategies/vimeo_spec.rb +0 -5
  168. data/oa-oauth/spec/omniauth/strategies/vkontakte_spec.rb +0 -5
  169. data/oa-oauth/spec/omniauth/strategies/yahoo_spec.rb +0 -5
  170. data/oa-oauth/spec/omniauth/strategies/yammer_spec.rb +0 -5
  171. data/oa-oauth/spec/omniauth/strategies/you_tube_spec.rb +0 -5
  172. data/oa-oauth/spec/spec_helper.rb +0 -27
  173. data/oa-oauth/spec/support/shared_examples.rb +0 -29
  174. data/oa-openid/Gemfile +0 -7
  175. data/oa-openid/LICENSE +0 -19
  176. data/oa-openid/README.rdoc +0 -51
  177. data/oa-openid/Rakefile +0 -6
  178. data/oa-openid/lib/oa-openid.rb +0 -1
  179. data/oa-openid/lib/omniauth/openid.rb +0 -60
  180. data/oa-openid/lib/omniauth/openid/gapps.rb +0 -32
  181. data/oa-openid/lib/omniauth/strategies/google_apps.rb +0 -23
  182. data/oa-openid/lib/omniauth/strategies/open_id.rb +0 -132
  183. data/oa-openid/lib/omniauth/strategies/steam.rb +0 -55
  184. data/oa-openid/lib/omniauth/version.rb +0 -19
  185. data/oa-openid/oa-openid.gemspec +0 -28
  186. data/oa-openid/spec/omniauth/strategies/open_id_spec.rb +0 -71
  187. data/oa-openid/spec/spec_helper.rb +0 -14
  188. data/omniauth.gemspec +0 -20
  189. data/tasks/all.rb +0 -134
@@ -1,60 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- class Doit < OAuth2
7
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
8
- client_options = {
9
- :site => 'https://openapi.doit.im',
10
- :authorize_url => 'https://openapi.doit.im/oauth/authorize',
11
- :access_token_url => 'https://openapi.doit.im/oauth/access_token'
12
- }
13
-
14
- super(app, :doit, 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(client.site+"/v1/settings"),{'Authorization'=> 'OAuth'+@access_token.token})
21
- end
22
-
23
- def request_phase
24
- options[:response_type] ||= "code"
25
- super
26
- end
27
-
28
- def callback_phase
29
- options[:grant_type] ||= 'authorization_code'
30
- super
31
- end
32
-
33
- def user_info
34
- {
35
- 'account' => user_data['account'],
36
- 'username'=> user_data['username'],
37
- 'nickname'=> user_data['nickname'],
38
- 'gender'=> user_data['gender'],
39
- 'week_start'=> user_data['week_start'],
40
- 'birthday_day'=> user_data['birthday_day'],
41
- 'birthday_month'=> user_data['birthday_month'],
42
- 'birthday_year'=> user_data['birthday_year'],
43
- 'language'=> user_data['language'],
44
- 'user_timezone'=> user_data['user_timezone'],
45
- 'remind_email'=> user_data['remind_email'],
46
- 'created'=> user_data['created'],
47
- 'updated'=> user_data['updated']
48
- }
49
- end
50
-
51
- def auth_hash
52
- OmniAuth::Utils.deep_merge(super, {
53
- 'uid' => user_data['id'],
54
- 'user_info' => user_info,
55
- 'extra' => {'user_hash' => user_data}
56
- })
57
- end
58
- end
59
- end
60
- end
@@ -1,53 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to Dopplr via OAuth and retrieve an access token for API usage
8
- #
9
- # Usage:
10
- #
11
- # use OmniAuth::Strategies::Dopplr, 'consumerkey', 'consumersecret'
12
- #
13
- class Dopplr < OmniAuth::Strategies::OAuth
14
- # Initialize the Dopplr strategy.
15
- #
16
- # @option options [Hash, {}] :client_options Options to be passed directly to the OAuth Consumer
17
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
18
- client_options = {
19
- :site => 'https://www.dopplr.com',
20
- :request_token_path => "/oauth/request_token",
21
- :access_token_path => "/oauth/access_token",
22
- :authorize_path => "/oauth/authorize"
23
- }
24
-
25
- super(app, :dopplr, consumer_key, consumer_secret, client_options, options, &block)
26
- end
27
-
28
- def user_data
29
- @data ||= MultiJson.decode(@access_token.get('/oauthapi/whoami').body)['whoami']
30
- end
31
-
32
- def user_info
33
- {
34
- 'nickname' => user_data["nick"],
35
- 'first_name' => user_data["forename"],
36
- 'last_name' => user_data["surname"],
37
- 'name' => "#{user_data['forename']} #{user_data['surname']}",
38
- 'urls' => {
39
- 'Dopplr' => user_data["dopplr_url"],
40
- 'DopplrMobile' => user_data["mobile_url"],
41
- }
42
- }
43
- end
44
-
45
- def auth_hash
46
- OmniAuth::Utils.deep_merge(super, {
47
- 'uid' => user_data['nick'],
48
- 'user_info' => user_info
49
- })
50
- end
51
- end
52
- end
53
- end
@@ -1,60 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to Douban via OAuth and retrieve basic
8
- # user information.
9
- #
10
- # Usage:
11
- #
12
- # use OmniAuth::Strategies::Douban, 'APIKey', 'APIKeySecret'
13
- #
14
- class Douban < OmniAuth::Strategies::OAuth
15
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
16
- # Although in OAuth spec the :realm parameter is optional,
17
- # it is required for Douban.
18
- client_options = {
19
- :site => 'http://www.douban.com',
20
- :request_token_path => '/service/auth/request_token',
21
- :access_token_path => '/service/auth/access_token',
22
- :authorize_path => '/service/auth/authorize',
23
- :realm => 'OmniAuth'
24
- }
25
-
26
- super(app, :douban, consumer_key, consumer_secret, client_options, options, &block)
27
- end
28
-
29
- def auth_hash
30
- OmniAuth::Utils.deep_merge(super, {
31
- 'uid' => @access_token.params[:douban_user_id],
32
- 'user_info' => user_info,
33
- 'extra' => {'user_hash' => user_hash}
34
- })
35
- end
36
-
37
- def user_info
38
- user_hash = self.user_hash
39
-
40
- location = user_hash['location'] ? user_hash['location']['$t'] : nil
41
- image = user_hash['link'].find {|l| l['@rel'] == 'icon' }['@href']
42
- douban_url = user_hash['link'].find {|l| l['@rel'] == 'alternate' }['@href']
43
- {
44
- 'username' => user_hash['db:uid']['$t'],
45
- 'name' => user_hash['title']['$t'],
46
- 'location' => location,
47
- 'image' => image,
48
- 'description' => user_hash['content']['$t'],
49
- 'urls' => {
50
- 'Douban' => douban_url
51
- }
52
- }
53
- end
54
-
55
- def user_hash
56
- @user_hash ||= MultiJson.decode(@access_token.get('http://api.douban.com/people/%40me?alt=json').body)
57
- end
58
- end
59
- end
60
- end
@@ -1,54 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
- require 'evernote'
4
-
5
- module OmniAuth
6
- module Strategies
7
- #
8
- # Authenticate to Evernote via OAuth and retrieve an access token for API usage
9
- #
10
- # Usage:
11
- #
12
- # use OmniAuth::Strategies::Evernote, 'consumerkey', 'consumersecret'
13
- #
14
- class Evernote < OmniAuth::Strategies::OAuth
15
- # Initialize the Evernote strategy.
16
- #
17
- # @option options [Hash, {}] :client_options Options to be passed directly to the OAuth Consumer
18
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
19
- client_options = {
20
- :site => 'https://www.evernote.com',
21
- :request_token_path => '/oauth',
22
- :access_token_path => '/oauth',
23
- :authorize_path => '/OAuth.action',
24
- :oauth_signature_method => 'PLAINTEXT'
25
- }
26
-
27
- super(app, :evernote, consumer_key, consumer_secret, client_options, options, &block)
28
- end
29
-
30
- def auth_hash
31
- OmniAuth::Utils.deep_merge(super, {
32
- 'uid' => user_data.id,
33
- 'user_info' => user_info,
34
- 'extra' => user_data
35
- })
36
- end
37
-
38
- def user_info
39
- {
40
- 'name' => user_data.name,
41
- 'nickname' => user_data.username,
42
- }
43
- end
44
-
45
- def user_data
46
- @user_data ||= begin
47
- user_store_url = consumer.site + '/edam/user'
48
- client = ::Evernote::Client.new(::Evernote::EDAM::UserStore::UserStore::Client, user_store_url, {})
49
- client.getUser(@access_token.token)
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,70 +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::Facebook, 'client_id', 'client_secret'
11
- class Facebook < OAuth2
12
- # @param [Rack Application] app standard middleware application parameter
13
- # @param [String] client_id the application id as [registered on Facebook](http://www.facebook.com/developers/)
14
- # @param [String] client_secret the application secret as registered on Facebook
15
- # @option options [String] :scope ('email,offline_access') comma-separated extended permissions such as `email` and `manage_pages`
16
- def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
17
- super(app, :facebook, client_id, client_secret, {:site => 'https://graph.facebook.com/'}, options, &block)
18
- end
19
-
20
- def user_data
21
- @data ||= MultiJson.decode(@access_token.get('/me', {}, { "Accept-Language" => "en-us,en;"}))
22
- end
23
-
24
- def request_phase
25
- options[:scope] ||= "email,offline_access"
26
- super
27
- end
28
-
29
- def build_access_token
30
- if facebook_session.nil? || facebook_session.empty?
31
- super
32
- else
33
- @access_token = ::OAuth2::AccessToken.new(client, facebook_session['access_token'])
34
- end
35
- end
36
-
37
- def facebook_session
38
- session_cookie = request.cookies["fbs_#{client.id}"]
39
- if session_cookie
40
- @facebook_session ||= Rack::Utils.parse_query(request.cookies["fbs_#{client.id}"].gsub('"', ''))
41
- else
42
- nil
43
- end
44
- end
45
-
46
- def user_info
47
- {
48
- 'nickname' => user_data["username"],
49
- 'email' => (user_data["email"] if user_data["email"]),
50
- 'first_name' => user_data["first_name"],
51
- 'last_name' => user_data["last_name"],
52
- 'name' => "#{user_data['first_name']} #{user_data['last_name']}",
53
- 'image' => "http://graph.facebook.com/#{user_data['id']}/picture?type=square",
54
- 'urls' => {
55
- 'Facebook' => user_data["link"],
56
- 'Website' => user_data["website"],
57
- }
58
- }
59
- end
60
-
61
- def auth_hash
62
- OmniAuth::Utils.deep_merge(super, {
63
- 'uid' => user_data['id'],
64
- 'user_info' => user_info,
65
- 'extra' => {'user_hash' => user_data}
66
- })
67
- end
68
- end
69
- end
70
- end
@@ -1,62 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- class Foursquare < OAuth2
7
- # Initialize the middleware
8
- #
9
- # @option options [Boolean, true] :sign_in When true, use a sign-in flow instead of the authorization flow.
10
- # @option options [Boolean, false] :mobile When true, use the mobile sign-in interface.
11
- def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
12
- options[:sign_in] ||= true
13
- super(app, :foursquare, client_id, client_secret, {
14
- :site => "https://api.foursquare.com/v2",
15
- :authorize_url => authorize_url(options),
16
- :access_token_url => "https://foursquare.com/oauth2/access_token"
17
- }, options, &block)
18
- end
19
-
20
- def authorize_url(options)
21
- "https://foursquare.com/#{'mobile/' if options[:mobile]}oauth2/#{options[:sign_in] ? 'authenticate' : 'authorize'}"
22
- end
23
-
24
- def user_data
25
- @data ||= MultiJson.decode(@access_token.get(client.site+'/users/self', {'oauth_token' => @access_token.token}))
26
- end
27
-
28
- def request_phase
29
- options[:response_type] ||= 'code'
30
- super
31
- end
32
-
33
- def callback_phase
34
- options[:grant_type] ||= 'authorization_code'
35
- super
36
- end
37
-
38
- def user_info
39
- {
40
- 'nickname' => user_data['response']['user']['contact']['twitter'],
41
- 'first_name' => user_data['response']['user']['firstName'],
42
- 'last_name' => user_data['response']['user']['lastName'],
43
- 'email' => user_data['response']['user']['contact']['email'],
44
- 'name' => "#{user_data['response']['user']['firstName']} #{user_data['response']['user']['lastName']}".strip,
45
- # 'location' => user_data['response']['user']['location'],
46
- 'image' => user_data['response']['user']['photo'],
47
- # 'description' => user_data['response']['user']['description'],
48
- 'phone' => user_data['response']['user']['contact']['phone'],
49
- 'urls' => {}
50
- }
51
- end
52
-
53
- def auth_hash
54
- OmniAuth::Utils.deep_merge(super, {
55
- 'uid' => user_data['response']['user']['id'],
56
- 'user_info' => user_info,
57
- 'extra' => {'user_hash' => user_data['response']['user']}
58
- })
59
- end
60
- end
61
- end
62
- end
@@ -1,50 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- # OAuth 2.0 based authentication with GitHub. In order to
7
- # sign up for an application, you need to [register an application](http://github.com/account/applications/new)
8
- # and provide the proper credentials to this middleware.
9
- class GitHub < OAuth2
10
- # @param [Rack Application] app standard middleware application argument
11
- # @param [String] client_id the application ID for your client
12
- # @param [String] client_secret the application secret
13
- def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
14
- client_options = {
15
- :site => 'https://github.com/',
16
- :authorize_path => '/login/oauth/authorize',
17
- :access_token_path => '/login/oauth/access_token'
18
- }
19
-
20
- super(app, :github, client_id, client_secret, client_options, options, &block)
21
- end
22
-
23
- protected
24
-
25
- def user_data
26
- @data ||= MultiJson.decode(@access_token.get('/api/v2/json/user/show'))['user']
27
- end
28
-
29
- def user_info
30
- {
31
- 'nickname' => user_data["login"],
32
- 'email' => user_data['email'],
33
- 'name' => user_data['name'],
34
- 'urls' => {
35
- 'GitHub' => "http://github.com/#{user_data['login']}",
36
- 'Blog' => user_data["blog"],
37
- }
38
- }
39
- end
40
-
41
- def auth_hash
42
- OmniAuth::Utils.deep_merge(super, {
43
- 'uid' => user_data['id'],
44
- 'user_info' => user_info,
45
- 'extra' => {'user_hash' => user_data}
46
- })
47
- end
48
- end
49
- end
50
- end
@@ -1,44 +0,0 @@
1
- require 'multi_xml'
2
- require 'omniauth/oauth'
3
-
4
- module OmniAuth
5
- module Strategies
6
- class Goodreads < OmniAuth::Strategies::OAuth
7
-
8
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
9
- client_options = {
10
- :site => 'http://www.goodreads.com',
11
- }
12
- @consumer_key = consumer_key
13
- super(app, :goodreads, consumer_key, consumer_secret, client_options, options, &block)
14
- end
15
-
16
- def auth_hash
17
- hash = user_hash(@access_token)
18
-
19
- OmniAuth::Utils.deep_merge(super, {
20
- 'uid' => hash.delete('id'),
21
- 'user_info' => hash
22
- })
23
- end
24
-
25
- def user_hash(access_token)
26
- authenticated_user = MultiXml.parse(@access_token.get('/api/auth_user').body)
27
- id = authenticated_user.xpath('GoodreadsResponse/user').attribute('id').value.to_i
28
- response_doc = MultiXml.parse(open("http://www.goodreads.com/user/show/#{id}.xml?key=#{@consumer_key}").read)
29
- user = response_doc.xpath('GoodreadsResponse/user')
30
-
31
- hash = {
32
- 'id' => id,
33
- 'name' => user.xpath('name').text,
34
- 'user_name' => user.xpath('user_name').text,
35
- 'image_url' => user.xpath('image_url').text,
36
- 'about' => user.xpath('about').text,
37
- 'location' => user.xpath('location').text,
38
- 'website' => user.xpath('website').text,
39
- }
40
- end
41
- end
42
- end
43
- end
44
-