omniauth 0.2.6 → 0.3.0

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.
Files changed (214) hide show
  1. data/README.md +62 -34
  2. data/lib/omniauth/version.rb +2 -2
  3. metadata +59 -225
  4. data/.autotest +0 -9
  5. data/.document +0 -5
  6. data/.gemtest +0 -0
  7. data/.gitignore +0 -56
  8. data/.rspec +0 -2
  9. data/.travis.yml +0 -9
  10. data/.yardopts +0 -4
  11. data/Gemfile +0 -12
  12. data/Rakefile +0 -51
  13. data/oa-basic/.gemtest +0 -0
  14. data/oa-basic/.rspec +0 -3
  15. data/oa-basic/.yardopts +0 -4
  16. data/oa-basic/Gemfile +0 -7
  17. data/oa-basic/LICENSE +0 -19
  18. data/oa-basic/README.rdoc +0 -34
  19. data/oa-basic/Rakefile +0 -6
  20. data/oa-basic/lib/oa-basic.rb +0 -1
  21. data/oa-basic/lib/omniauth/basic.rb +0 -8
  22. data/oa-basic/lib/omniauth/strategies/http_basic.rb +0 -56
  23. data/oa-basic/lib/omniauth/version.rb +0 -19
  24. data/oa-basic/oa-basic.gemspec +0 -27
  25. data/oa-basic/spec/omniauth/strategies/basic_spec.rb +0 -7
  26. data/oa-basic/spec/spec_helper.rb +0 -11
  27. data/oa-core/.gemtest +0 -0
  28. data/oa-core/.rspec +0 -3
  29. data/oa-core/.yardopts +0 -4
  30. data/oa-core/Gemfile +0 -3
  31. data/oa-core/LICENSE +0 -19
  32. data/oa-core/Rakefile +0 -6
  33. data/oa-core/autotest/discover.rb +0 -1
  34. data/oa-core/lib/oa-core.rb +0 -1
  35. data/oa-core/lib/omniauth/builder.rb +0 -33
  36. data/oa-core/lib/omniauth/core.rb +0 -135
  37. data/oa-core/lib/omniauth/form.rb +0 -186
  38. data/oa-core/lib/omniauth/strategy.rb +0 -227
  39. data/oa-core/lib/omniauth/test/phony_session.rb +0 -8
  40. data/oa-core/lib/omniauth/test/strategy_macros.rb +0 -34
  41. data/oa-core/lib/omniauth/test/strategy_test_case.rb +0 -49
  42. data/oa-core/lib/omniauth/test.rb +0 -12
  43. data/oa-core/lib/omniauth/version.rb +0 -19
  44. data/oa-core/oa-core.gemspec +0 -24
  45. data/oa-core/spec/omniauth/builder_spec.rb +0 -20
  46. data/oa-core/spec/omniauth/core_spec.rb +0 -79
  47. data/oa-core/spec/omniauth/strategy_spec.rb +0 -363
  48. data/oa-core/spec/spec_helper.rb +0 -12
  49. data/oa-enterprise/.gemtest +0 -0
  50. data/oa-enterprise/.rspec +0 -3
  51. data/oa-enterprise/.yardopts +0 -4
  52. data/oa-enterprise/Gemfile +0 -7
  53. data/oa-enterprise/LICENSE +0 -19
  54. data/oa-enterprise/README.rdoc +0 -82
  55. data/oa-enterprise/Rakefile +0 -6
  56. data/oa-enterprise/lib/oa-enterprise.rb +0 -1
  57. data/oa-enterprise/lib/omniauth/enterprise.rb +0 -8
  58. data/oa-enterprise/lib/omniauth/strategies/cas/configuration.rb +0 -98
  59. data/oa-enterprise/lib/omniauth/strategies/cas/service_ticket_validator.rb +0 -91
  60. data/oa-enterprise/lib/omniauth/strategies/cas.rb +0 -47
  61. data/oa-enterprise/lib/omniauth/strategies/ldap/adaptor.rb +0 -279
  62. data/oa-enterprise/lib/omniauth/strategies/ldap.rb +0 -111
  63. data/oa-enterprise/lib/omniauth/version.rb +0 -19
  64. data/oa-enterprise/oa-enterprise.gemspec +0 -31
  65. data/oa-enterprise/spec/fixtures/cas_failure.xml +0 -4
  66. data/oa-enterprise/spec/fixtures/cas_success.xml +0 -8
  67. data/oa-enterprise/spec/omniauth/strategies/cas_spec.rb +0 -94
  68. data/oa-enterprise/spec/omniauth/strategies/ldap_spec.rb +0 -41
  69. data/oa-enterprise/spec/spec_helper.rb +0 -14
  70. data/oa-more/.gemtest +0 -0
  71. data/oa-more/.rspec +0 -3
  72. data/oa-more/.yardopts +0 -4
  73. data/oa-more/Gemfile +0 -7
  74. data/oa-more/LICENSE +0 -19
  75. data/oa-more/README.rdoc +0 -22
  76. data/oa-more/Rakefile +0 -6
  77. data/oa-more/lib/oa-more.rb +0 -1
  78. data/oa-more/lib/omniauth/more.rb +0 -11
  79. data/oa-more/lib/omniauth/strategies/draugiem.rb +0 -104
  80. data/oa-more/lib/omniauth/strategies/flickr.rb +0 -86
  81. data/oa-more/lib/omniauth/strategies/ign.rb +0 -93
  82. data/oa-more/lib/omniauth/strategies/windows_live/windowslivelogin.rb +0 -1143
  83. data/oa-more/lib/omniauth/strategies/windows_live.rb +0 -39
  84. data/oa-more/lib/omniauth/strategies/yupoo.rb +0 -67
  85. data/oa-more/lib/omniauth/version.rb +0 -19
  86. data/oa-more/oa-more.gemspec +0 -29
  87. data/oa-more/spec/omniauth/strategies/draugiem_spec.rb +0 -51
  88. data/oa-more/spec/omniauth/strategies/flickr_spec.rb +0 -7
  89. data/oa-more/spec/spec_helper.rb +0 -11
  90. data/oa-oauth/.gemtest +0 -0
  91. data/oa-oauth/.rspec +0 -3
  92. data/oa-oauth/.yardopts +0 -4
  93. data/oa-oauth/Gemfile +0 -7
  94. data/oa-oauth/LICENSE +0 -19
  95. data/oa-oauth/README.rdoc +0 -35
  96. data/oa-oauth/Rakefile +0 -6
  97. data/oa-oauth/autotest/discover.rb +0 -1
  98. data/oa-oauth/lib/oa-oauth.rb +0 -1
  99. data/oa-oauth/lib/omniauth/oauth.rb +0 -56
  100. data/oa-oauth/lib/omniauth/strategies/bitly.rb +0 -46
  101. data/oa-oauth/lib/omniauth/strategies/dailymile.rb +0 -64
  102. data/oa-oauth/lib/omniauth/strategies/doit.rb +0 -60
  103. data/oa-oauth/lib/omniauth/strategies/dopplr.rb +0 -53
  104. data/oa-oauth/lib/omniauth/strategies/douban.rb +0 -60
  105. data/oa-oauth/lib/omniauth/strategies/evernote.rb +0 -54
  106. data/oa-oauth/lib/omniauth/strategies/facebook.rb +0 -70
  107. data/oa-oauth/lib/omniauth/strategies/foursquare.rb +0 -62
  108. data/oa-oauth/lib/omniauth/strategies/github.rb +0 -50
  109. data/oa-oauth/lib/omniauth/strategies/goodreads.rb +0 -44
  110. data/oa-oauth/lib/omniauth/strategies/google.rb +0 -80
  111. data/oa-oauth/lib/omniauth/strategies/gowalla.rb +0 -72
  112. data/oa-oauth/lib/omniauth/strategies/hyves.rb +0 -67
  113. data/oa-oauth/lib/omniauth/strategies/identica.rb +0 -49
  114. data/oa-oauth/lib/omniauth/strategies/instagram.rb +0 -56
  115. data/oa-oauth/lib/omniauth/strategies/instapaper.rb +0 -40
  116. data/oa-oauth/lib/omniauth/strategies/linked_in.rb +0 -56
  117. data/oa-oauth/lib/omniauth/strategies/mailru.rb +0 -107
  118. data/oa-oauth/lib/omniauth/strategies/meetup.rb +0 -56
  119. data/oa-oauth/lib/omniauth/strategies/miso.rb +0 -41
  120. data/oa-oauth/lib/omniauth/strategies/mixi.rb +0 -59
  121. data/oa-oauth/lib/omniauth/strategies/netflix.rb +0 -65
  122. data/oa-oauth/lib/omniauth/strategies/oauth.rb +0 -83
  123. data/oa-oauth/lib/omniauth/strategies/oauth2.rb +0 -91
  124. data/oa-oauth/lib/omniauth/strategies/plurk.rb +0 -58
  125. data/oa-oauth/lib/omniauth/strategies/qzone.rb +0 -69
  126. data/oa-oauth/lib/omniauth/strategies/rdio.rb +0 -45
  127. data/oa-oauth/lib/omniauth/strategies/renren.rb +0 -87
  128. data/oa-oauth/lib/omniauth/strategies/salesforce.rb +0 -44
  129. data/oa-oauth/lib/omniauth/strategies/smug_mug.rb +0 -42
  130. data/oa-oauth/lib/omniauth/strategies/sound_cloud.rb +0 -46
  131. data/oa-oauth/lib/omniauth/strategies/t163.rb +0 -57
  132. data/oa-oauth/lib/omniauth/strategies/taobao.rb +0 -79
  133. data/oa-oauth/lib/omniauth/strategies/teambox.rb +0 -49
  134. data/oa-oauth/lib/omniauth/strategies/thirty_seven_signals.rb +0 -41
  135. data/oa-oauth/lib/omniauth/strategies/tqq.rb +0 -64
  136. data/oa-oauth/lib/omniauth/strategies/trade_me.rb +0 -45
  137. data/oa-oauth/lib/omniauth/strategies/trip_it.rb +0 -22
  138. data/oa-oauth/lib/omniauth/strategies/tsina.rb +0 -79
  139. data/oa-oauth/lib/omniauth/strategies/tsohu.rb +0 -57
  140. data/oa-oauth/lib/omniauth/strategies/tumblr.rb +0 -60
  141. data/oa-oauth/lib/omniauth/strategies/twitter.rb +0 -57
  142. data/oa-oauth/lib/omniauth/strategies/type_pad.rb +0 -76
  143. data/oa-oauth/lib/omniauth/strategies/vimeo.rb +0 -54
  144. data/oa-oauth/lib/omniauth/strategies/vkontakte.rb +0 -87
  145. data/oa-oauth/lib/omniauth/strategies/xauth.rb +0 -67
  146. data/oa-oauth/lib/omniauth/strategies/yahoo.rb +0 -55
  147. data/oa-oauth/lib/omniauth/strategies/yammer.rb +0 -43
  148. data/oa-oauth/lib/omniauth/strategies/you_tube.rb +0 -73
  149. data/oa-oauth/lib/omniauth/version.rb +0 -19
  150. data/oa-oauth/oa-oauth.gemspec +0 -32
  151. data/oa-oauth/spec/fixtures/basecamp_200.xml +0 -24
  152. data/oa-oauth/spec/fixtures/campfire_200.json +0 -10
  153. data/oa-oauth/spec/omniauth/strategies/bitly_spec.rb +0 -5
  154. data/oa-oauth/spec/omniauth/strategies/dailymile_spec.rb +0 -5
  155. data/oa-oauth/spec/omniauth/strategies/doit_spec.rb +0 -5
  156. data/oa-oauth/spec/omniauth/strategies/dopplr_spec.rb +0 -5
  157. data/oa-oauth/spec/omniauth/strategies/douban_spec.rb +0 -5
  158. data/oa-oauth/spec/omniauth/strategies/evernote_spec.rb +0 -5
  159. data/oa-oauth/spec/omniauth/strategies/facebook_spec.rb +0 -5
  160. data/oa-oauth/spec/omniauth/strategies/foursquare_spec.rb +0 -18
  161. data/oa-oauth/spec/omniauth/strategies/github_spec.rb +0 -5
  162. data/oa-oauth/spec/omniauth/strategies/goodreads_spec.rb +0 -6
  163. data/oa-oauth/spec/omniauth/strategies/google_spec.rb +0 -5
  164. data/oa-oauth/spec/omniauth/strategies/gowalla_spec.rb +0 -5
  165. data/oa-oauth/spec/omniauth/strategies/hyves_spec.rb +0 -5
  166. data/oa-oauth/spec/omniauth/strategies/identica_spec.rb +0 -5
  167. data/oa-oauth/spec/omniauth/strategies/linked_in_spec.rb +0 -5
  168. data/oa-oauth/spec/omniauth/strategies/mailru_spec.rb +0 -5
  169. data/oa-oauth/spec/omniauth/strategies/meetup_spec.rb +0 -14
  170. data/oa-oauth/spec/omniauth/strategies/miso_spec.rb +0 -5
  171. data/oa-oauth/spec/omniauth/strategies/netflix_spec.rb +0 -5
  172. data/oa-oauth/spec/omniauth/strategies/oauth2_spec.rb +0 -0
  173. data/oa-oauth/spec/omniauth/strategies/oauth_spec.rb +0 -77
  174. data/oa-oauth/spec/omniauth/strategies/plurk_spec.rb +0 -5
  175. data/oa-oauth/spec/omniauth/strategies/rdio_spec.rb +0 -5
  176. data/oa-oauth/spec/omniauth/strategies/salesforce_spec.rb +0 -5
  177. data/oa-oauth/spec/omniauth/strategies/smug_mug_spec.rb +0 -5
  178. data/oa-oauth/spec/omniauth/strategies/sound_cloud_spec.rb +0 -5
  179. data/oa-oauth/spec/omniauth/strategies/t163_spec.rb +0 -5
  180. data/oa-oauth/spec/omniauth/strategies/taobao_spec.rb +0 -5
  181. data/oa-oauth/spec/omniauth/strategies/teambox_spec.rb +0 -5
  182. data/oa-oauth/spec/omniauth/strategies/thirty_seven_signals_spec.rb +0 -5
  183. data/oa-oauth/spec/omniauth/strategies/trade_me_spec.rb +0 -5
  184. data/oa-oauth/spec/omniauth/strategies/trip_it_spec.rb +0 -5
  185. data/oa-oauth/spec/omniauth/strategies/tsina_spec.rb +0 -5
  186. data/oa-oauth/spec/omniauth/strategies/tumblr_spec.rb +0 -5
  187. data/oa-oauth/spec/omniauth/strategies/twitter_spec.rb +0 -20
  188. data/oa-oauth/spec/omniauth/strategies/type_pad_spec.rb +0 -5
  189. data/oa-oauth/spec/omniauth/strategies/vimeo_spec.rb +0 -5
  190. data/oa-oauth/spec/omniauth/strategies/vkontakte_spec.rb +0 -5
  191. data/oa-oauth/spec/omniauth/strategies/yahoo_spec.rb +0 -5
  192. data/oa-oauth/spec/omniauth/strategies/yammer_spec.rb +0 -5
  193. data/oa-oauth/spec/omniauth/strategies/you_tube_spec.rb +0 -5
  194. data/oa-oauth/spec/spec_helper.rb +0 -27
  195. data/oa-oauth/spec/support/shared_examples.rb +0 -29
  196. data/oa-openid/.gemtest +0 -0
  197. data/oa-openid/.rspec +0 -3
  198. data/oa-openid/.yardopts +0 -4
  199. data/oa-openid/Gemfile +0 -7
  200. data/oa-openid/LICENSE +0 -19
  201. data/oa-openid/README.rdoc +0 -51
  202. data/oa-openid/Rakefile +0 -6
  203. data/oa-openid/lib/oa-openid.rb +0 -1
  204. data/oa-openid/lib/omniauth/openid/gapps.rb +0 -32
  205. data/oa-openid/lib/omniauth/openid.rb +0 -60
  206. data/oa-openid/lib/omniauth/strategies/google_apps.rb +0 -23
  207. data/oa-openid/lib/omniauth/strategies/open_id.rb +0 -132
  208. data/oa-openid/lib/omniauth/strategies/steam.rb +0 -55
  209. data/oa-openid/lib/omniauth/version.rb +0 -19
  210. data/oa-openid/oa-openid.gemspec +0 -28
  211. data/oa-openid/spec/omniauth/strategies/open_id_spec.rb +0 -71
  212. data/oa-openid/spec/spec_helper.rb +0 -14
  213. data/omniauth.gemspec +0 -20
  214. data/tasks/all.rb +0 -134
@@ -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
-
@@ -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
-