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,76 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to Typepad via OAuth and retrieve basic
8
- # user information.
9
- #
10
- # Usage:
11
- #
12
- # use OmniAuth::Strategies::Typepad, 'consumerkey', 'consumersecret', :application_id => 'my_type_pad_application_id'
13
- #
14
- # application_id is required.
15
- #
16
- class TypePad < OmniAuth::Strategies::OAuth
17
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
18
-
19
- # TypePad uses the application ID for one of the OAuth paths.
20
- app_id = options[:application_id]
21
-
22
- client_options = {
23
- :site => 'https://www.typepad.com',
24
- :request_token_path => '/secure/services/oauth/request_token',
25
- :access_token_path => '/secure/services/oauth/access_token',
26
- :authorize_path => "/secure/services/api/#{app_id}/oauth-approve",
27
- :http_method => :get,
28
- # You *must* use query_string for the token dance.
29
- :scheme => :query_string
30
- }
31
-
32
- options.merge! :scheme => :query_string, :http_method => :get
33
-
34
- super(app, :type_pad, consumer_key, consumer_secret, client_options, options)
35
- end
36
-
37
- def auth_hash
38
- ui = user_info
39
- OmniAuth::Utils.deep_merge(super, {
40
- 'uid' => ui['uid'],
41
- 'user_info' => ui,
42
- 'extra' => {'user_hash' => user_hash}
43
- })
44
- end
45
-
46
- def user_info
47
- user_hash = self.user_hash
48
-
49
- {
50
- 'uid' => user_hash['urlId'],
51
- 'nickname' => user_hash['preferredUsername'],
52
- 'name' => user_hash['displayName'],
53
- 'image' => user_hash['avatarLink']['url'],
54
- 'description' => user_hash['aboutMe'],
55
- 'urls' => {'Profile' => user_hash['profilePageUrl']}
56
- }
57
- end
58
-
59
- def user_hash
60
- # For authenticated requests, you have to use header as your scheme.
61
- # Failure to do so gives a unique response body - 'Auth is required'.
62
- # 'Unauthorized' is the response body of a truly unauthorized request.
63
-
64
- # Also note that API requests hit a different site than the OAuth dance.
65
- r = self.consumer.request(
66
- :get,
67
- "https://api.typepad.com/users/@self.json",
68
- @access_token,
69
- :scheme => 'header'
70
- )
71
-
72
- @user_hash ||= MultiJson.decode(r.body)
73
- end
74
- end
75
- end
76
- end
@@ -1,54 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to Vimeo via OAuth and retrieve basic user information.
8
- #
9
- # Usage:
10
- #
11
- # use OmniAuth::Strategies::Vimeo, 'consumerkey', 'consumersecret'
12
- #
13
- class Vimeo < OmniAuth::Strategies::OAuth
14
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
15
- opts = {
16
- :site => 'http://vimeo.com',
17
- :request_token_path => '/oauth/request_token',
18
- :access_token_path => '/oauth/access_token',
19
- :authorize_path => '/oauth/authorize'
20
- }
21
- super(app, :vimeo, consumer_key, consumer_secret, opts, options, &block)
22
- end
23
-
24
- def auth_hash
25
- user = user_hash['person']
26
- OmniAuth::Utils.deep_merge(super, {
27
- 'uid' => user['id'],
28
- 'user_info' => user_info,
29
- 'extra' => { 'user_hash' => user }
30
- })
31
- end
32
-
33
- def user_info
34
- user = user_hash['person']
35
- {
36
- 'nickname' => user['username'],
37
- 'name' => user['display_name'],
38
- 'location' => user['location'],
39
- 'description' => user['bio'],
40
- 'image' => user['portraits']['portrait'].select{|h| h['height'] == '300'}.first['_content'],
41
- 'urls' => {
42
- 'website' => user['url'],
43
- 'vimeo' => user['profileurl']
44
- }
45
- }
46
- end
47
-
48
- def user_hash
49
- url = "http://vimeo.com/api/rest/v2?method=vimeo.people.getInfo&format=json"
50
- @user_hash ||= MultiJson.decode(@access_token.get(url).body)
51
- end
52
- end
53
- end
54
- end
@@ -1,87 +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://vkontakte.ru/developers.php?o=-17680044&p=Authorization&s=0
11
- #
12
- # @example Basic Usage
13
- # use OmniAuth::Strategies::Vkontakte, 'API Key', 'Secret Key'
14
- class Vkontakte < OAuth2
15
- # @param [Rack Application] app standard middleware application parameter
16
- # @param [String] api_key the application id as [registered in Vkontakte]
17
- # @param [String] secret_key the application secret as [registered in Vkontakte]
18
- def initialize(app, api_key = nil, secret_key = nil, options = {}, &block)
19
- client_options = {
20
- :site => 'https://vkontakte.ru',
21
- :authorize_url => 'http://api.vkontakte.ru/oauth/authorize',
22
- :access_token_url => 'https://api.vkontakte.ru/oauth/token'
23
- }
24
-
25
- super(app, :vkontakte, api_key, secret_key, client_options, options, &block)
26
- end
27
-
28
- protected
29
-
30
- def user_data
31
- # http://vkontakte.ru/developers.php?o=-17680044&p=Description+of+Fields+of+the+fields+Parameter
32
- @fields ||= ['uid', 'first_name', 'last_name', 'nickname', 'domain', 'sex', 'bdate', 'city', 'country', 'timezone', 'photo', 'photo_big']
33
-
34
- # http://vkontakte.ru/developers.php?o=-1&p=getProfiles
35
- @data ||= MultiJson.decode(@access_token.get("https://api.vkontakte.ru/method/getProfiles?uid=#{@access_token['user_id']}&fields=#{@fields.join(',')}&access_token=#{@access_token.token}"))['response'][0]
36
-
37
- # we need these 2 additional requests since vkontakte returns only ids of the City and Country
38
- # http://vkontakte.ru/developers.php?o=-17680044&p=getCities
39
- cities = MultiJson.decode(@access_token.get("https://api.vkontakte.ru/method/getCities?cids=#{@data['city']}&access_token=#{@access_token.token}"))['response']
40
- @city ||= cities.first['name'] if cities && cities.first
41
-
42
- # http://vkontakte.ru/developers.php?o=-17680044&p=getCountries
43
- countries = MultiJson.decode(@access_token.get("https://api.vkontakte.ru/method/getCountries?cids=#{@data['country']}&access_token=#{@access_token}"))['response']
44
- @country ||= countries.first['name'] if countries && countries.first
45
- end
46
-
47
- def request_phase
48
- options[:response_type] ||= 'code'
49
- super
50
- end
51
-
52
- def user_info
53
- {
54
- 'first_name' => @data['first_name'],
55
- 'last_name' => @data['last_name'],
56
- 'name' => "#{@data['first_name']} #{@data['last_name']}",
57
- 'nickname' => @data['nickname'],
58
- 'birth_date' => @data['bdate'],
59
- 'image' => @data['photo'],
60
- 'location' => "#{@country}, #{@city}",
61
- 'urls' => {
62
- 'Vkontakte' => "http://vkontakte.ru/#{@data['domain']}"
63
- }
64
- }
65
- end
66
-
67
- def user_hash
68
- {
69
- "user_hash" => {
70
- "gender" => @data["sex"],
71
- "timezone" => @data["timezone"],
72
- "photo_big" => @data["photo_big"] # 200px maximum resolution of the avatar (http://vkontakte.ru/developers.php?o=-17680044&p=Description+of+Fields+of+the+fields+Parameter)
73
- }
74
- }
75
- end
76
-
77
- def auth_hash
78
- user_data # process user's info
79
- OmniAuth::Utils.deep_merge(super, {
80
- 'uid' => @data['uid'],
81
- 'user_info' => user_info,
82
- 'extra' => user_hash
83
- })
84
- end
85
- end
86
- end
87
- end
@@ -1,67 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- class XAuth
7
- include OmniAuth::Strategy
8
-
9
- attr_reader :name
10
- attr_accessor :consumer_key, :consumer_secret, :consumer_options
11
-
12
- def initialize(app, name, consumer_key = nil, consumer_secret = nil, consumer_options = {}, options = {}, &block)
13
- self.consumer_key = consumer_key
14
- self.consumer_secret = consumer_secret
15
- self.consumer_options = consumer_options
16
- super
17
- end
18
-
19
- def request_phase
20
- session['oauth'] ||= {}
21
- if env['REQUEST_METHOD'] == 'GET'
22
- get_credentials
23
- else
24
- session['omniauth.xauth'] = { 'x_auth_mode' => 'client_auth', 'x_auth_username' => request['username'], 'x_auth_password' => request['password'] }
25
- redirect callback_path
26
- end
27
- end
28
-
29
- def get_credentials
30
- OmniAuth::Form.build(consumer_options[:title] || "xAuth Credentials") do
31
- text_field 'Username', 'username'
32
- password_field 'Password', 'password'
33
- end.to_response
34
- end
35
-
36
- def consumer
37
- ::OAuth::Consumer.new(consumer_key, consumer_secret, consumer_options.merge(options[:client_options] || options[:consumer_options] || {}))
38
- end
39
-
40
- def callback_phase
41
- @access_token = consumer.get_access_token(nil, {}, session['omniauth.xauth'])
42
- super
43
- rescue ::Net::HTTPFatalError => e
44
- fail!(:service_unavailable, e)
45
- rescue ::OAuth::Unauthorized => e
46
- fail!(:invalid_credentials, e)
47
- rescue ::MultiJson::DecodeError => e
48
- fail!(:invalid_response, e)
49
- ensure
50
- session['omniauth.xauth'] = nil
51
- end
52
-
53
- def auth_hash
54
- OmniAuth::Utils.deep_merge(super, {
55
- 'credentials' => {
56
- 'token' => @access_token.token,
57
- 'secret' => @access_token.secret
58
- }, 'extra' => {
59
- 'access_token' => @access_token
60
- }
61
- })
62
- end
63
-
64
- end
65
- end
66
- end
67
-
@@ -1,55 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- #
7
- # Authenticate to Yahoo via OAuth and retrieve basic
8
- # user information.
9
- #
10
- # Usage:
11
- #
12
- # use OmniAuth::Strategies::Yahoo, 'consumerkey', 'consumersecret'
13
- #
14
- class Yahoo < OmniAuth::Strategies::OAuth
15
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
16
- client_options = {
17
- :site => 'https://api.login.yahoo.com',
18
- :request_token_path => '/oauth/v2/get_request_token',
19
- :access_token_path => '/oauth/v2/get_token',
20
- :authorize_path => "/oauth/v2/request_auth"
21
- }
22
-
23
- super(app, :yahoo, consumer_key, consumer_secret, client_options, options)
24
- end
25
-
26
- def auth_hash
27
- ui = user_info
28
- OmniAuth::Utils.deep_merge(super, {
29
- 'uid' => ui['uid'],
30
- 'user_info' => ui,
31
- 'extra' => {'user_hash' => user_hash}
32
- })
33
- end
34
-
35
- def user_info
36
- user_hash = self.user_hash
37
- profile = user_hash['profile']
38
- nickname = user_hash['profile']['nickname']
39
- {
40
- 'uid' => profile['guid'],
41
- 'nickname' => profile['nickname'],
42
- 'name' => profile['givenName'] || nickname,
43
- 'image' => profile['image']['imageUrl'],
44
- 'description' => profile['message'],
45
- 'urls' => {'Profile' => profile['profileUrl'] }
46
- }
47
- end
48
-
49
- def user_hash
50
- uid = @access_token.params['xoauth_yahoo_guid']
51
- @user_hash ||= MultiJson.decode(@access_token.get("http://social.yahooapis.com/v1/user/#{uid}/profile?format=json").body)
52
- end
53
- end
54
- end
55
- end
@@ -1,43 +0,0 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
3
-
4
- module OmniAuth
5
- module Strategies
6
- class Yammer < OmniAuth::Strategies::OAuth
7
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
8
- client_options = {
9
- :site => 'https://www.yammer.com',
10
- :request_token_path => '/oauth/request_token',
11
- :access_token_path => '/oauth/access_token',
12
- :authorize_path => "/oauth/authorize"
13
- }
14
-
15
- super(app, :yammer, consumer_key, consumer_secret, client_options, options)
16
- end
17
-
18
- def auth_hash
19
- OmniAuth::Utils.deep_merge(super, {
20
- 'uid' => user_hash['id'],
21
- 'user_info' => user_info,
22
- 'extra' => {'user_hash' => user_hash}
23
- })
24
- end
25
-
26
- def user_info
27
- user_hash = self.user_hash
28
- {
29
- 'nickname' => user_hash['name'],
30
- 'name' => user_hash['full-name'],
31
- 'location' => user_hash['location'],
32
- 'image' => user_hash['mugshot-url'],
33
- 'description' => user_hash['job-title'],
34
- 'urls' => {'Yammer' => user_hash['web-url']}
35
- }
36
- end
37
-
38
- def user_hash
39
- @user_hash ||= MultiJson.decode(@access_token.get('/api/v1/users/current.json').body)
40
- end
41
- end
42
- end
43
- end
@@ -1,73 +0,0 @@
1
- # Based heavily on the Google strategy, monkeypatch and all
2
-
3
- require 'omniauth/oauth'
4
- require 'multi_json'
5
-
6
- module OmniAuth
7
- module Strategies
8
- #
9
- # Authenticate to YouTube via OAuth and retrieve basic user info.
10
- #
11
- # Usage:
12
- #
13
- # use OmniAuth::Strategies::YouTube, 'consumerkey', 'consumersecret'
14
- #
15
- class YouTube < OmniAuth::Strategies::OAuth
16
- def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
17
- client_options = {
18
- :site => 'https://www.google.com',
19
- :request_token_path => '/accounts/OAuthGetRequestToken',
20
- :access_token_path => '/accounts/OAuthGetAccessToken',
21
- :authorize_path => '/accounts/OAuthAuthorizeToken'
22
- }
23
-
24
- super(app, :you_tube, consumer_key, consumer_secret, client_options, options)
25
- end
26
-
27
- def auth_hash
28
- ui = user_info
29
- OmniAuth::Utils.deep_merge(super, {
30
- 'uid' => ui['uid'],
31
- 'user_info' => ui,
32
- 'extra' => {'user_hash' => user_hash}
33
- })
34
- end
35
-
36
- def user_info
37
- entry = user_hash['entry']
38
- {
39
- 'uid' => entry['id']['$t'],
40
- 'nickname' => entry['author'].first['name']['$t'],
41
- 'first_name' => entry['yt$firstName'] && entry['yt$firstName']['$t'],
42
- 'last_name' => entry['yt$lastName'] && entry['yt$lastName']['$t'],
43
- 'image' => entry['media$thumbnail'] && entry['media$thumbnail']['url'],
44
- 'description' => entry['yt$description'] && entry['yt$description']['$t'],
45
- 'location' => entry['yt$location'] && entry['yt$location']['$t']
46
- }
47
- end
48
-
49
- def user_hash
50
- # YouTube treats 'default' as the currently logged-in user
51
- # via http://apiblog.youtube.com/2010/11/update-to-clientlogin-url.html
52
- @user_hash ||= MultiJson.decode(@access_token.get("http://gdata.youtube.com/feeds/api/users/default?alt=json").body)
53
- end
54
-
55
- # Monkeypatch consumer.get_request_token but specify YouTube scope rather than Google Contacts
56
- # TODO this is an easy patch to the underlying OAuth strategy a la OAuth2
57
- def request_phase
58
- request_token = consumer.get_request_token({:oauth_callback => callback_url}, {:scope => 'http://gdata.youtube.com'})
59
- session['oauth'] ||= {}
60
- session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
61
- r = Rack::Response.new
62
-
63
- if request_token.callback_confirmed?
64
- r.redirect(request_token.authorize_url)
65
- else
66
- r.redirect(request_token.authorize_url(:oauth_callback => callback_url))
67
- end
68
-
69
- r.finish
70
- end
71
- end
72
- end
73
- end