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,41 +0,0 @@
1
- require File.expand_path('../../../spec_helper', __FILE__)
2
- require 'cgi'
3
-
4
- describe OmniAuth::Strategies::LDAP, :type => :strategy do
5
-
6
- include OmniAuth::Test::StrategyTestCase
7
-
8
- def strategy
9
- @ldap_server ||= 'ldap.example.org'
10
- [OmniAuth::Strategies::LDAP, {
11
- :host => @ldap_server,
12
- :port => 636,
13
- :method => :ssl,
14
- :uid => 'jeremyf',
15
- :base => 'o="University of OmniAuth", st=Sublime, c=RubyNation',
16
- }]
17
- end
18
-
19
- describe 'GET /auth/ldap' do
20
- before do
21
- get '/auth/ldap'
22
- end
23
-
24
- # TODO: Add checks that page has authentication form; I attempted
25
- # to use `should have_tag` but that was not working.
26
- it 'should get authentication page' do
27
- last_response.status.should == 200
28
- end
29
- end
30
-
31
- describe 'POST /auth/ldap' do
32
- before do
33
- post '/auth/ldap', {:username => 'jeremy', :password => 'valid_password' }
34
- end
35
-
36
- it 'should redirect us to /auth/ldap/callback' do
37
- last_response.should be_redirect
38
- last_response.location.should == '/auth/ldap/callback'
39
- end
40
- end
41
- end
@@ -1,14 +0,0 @@
1
- require 'simplecov'
2
- SimpleCov.start
3
- require 'rspec'
4
- require 'rack/test'
5
- require 'webmock/rspec'
6
- require 'omniauth/core'
7
- require 'omniauth/test'
8
- require 'omniauth/enterprise'
9
-
10
- RSpec.configure do |config|
11
- config.include WebMock::API
12
- config.include Rack::Test::Methods
13
- config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
14
- end
data/oa-more/.gemtest DELETED
File without changes
data/oa-more/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --format=nested
3
- --backtrace
data/oa-more/.yardopts DELETED
@@ -1,4 +0,0 @@
1
- --markup markdown
2
- --markup-provider maruku
3
- -
4
- LICENSE
data/oa-more/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- platforms :jruby do
4
- gem 'jruby-openssl', '~> 0.7'
5
- end
6
-
7
- gemspec
data/oa-more/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc.
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- THE SOFTWARE.
data/oa-more/README.rdoc DELETED
@@ -1,22 +0,0 @@
1
- = OmniAuth::More
2
-
3
- OmniAuth stratgies for authentication providers that do not
4
- fit into one of the other authentication gems.
5
-
6
- == Installation
7
-
8
- To install omniauth as a suite of gems:
9
-
10
- gem install omniauth
11
-
12
- To install just the providers in the "more" gem:
13
-
14
- gem install oa-more
15
-
16
- == OmniAuth Builder
17
-
18
- If you want to allow multiple providers, use the OmniAuth Builder:
19
-
20
- use OmniAuth::Builder do
21
- provider :flickr, 'api_key', 'secret_key', :scope => 'read'
22
- end
data/oa-more/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
- require 'rspec/core/rake_task'
4
- RSpec::Core::RakeTask.new(:spec)
5
- task :default => :spec
6
- task :test => :spec
@@ -1 +0,0 @@
1
- require 'omniauth/more'
@@ -1,11 +0,0 @@
1
- require 'omniauth/core'
2
-
3
- module OmniAuth
4
- module Strategies
5
- autoload :WindowsLive, 'omniauth/strategies/windows_live'
6
- autoload :Flickr, 'omniauth/strategies/flickr'
7
- autoload :Yupoo, 'omniauth/strategies/yupoo'
8
- autoload :Ign, 'omniauth/strategies/ign'
9
- autoload :Draugiem, 'omniauth/strategies/draugiem'
10
- end
11
- end
@@ -1,104 +0,0 @@
1
- require 'omniauth/core'
2
- require 'digest/md5'
3
- require 'rest-client'
4
- require 'multi_json'
5
-
6
- module OmniAuth
7
- module Strategies
8
- #
9
- # Authenticate to draugiem.lv and frype.com and others.
10
- #
11
- # @example Basic Rails Usage
12
- #
13
- # Add this to config/initializers/omniauth.rb
14
- #
15
- # Rails.application.config.middleware.use OmniAuth::Builder do
16
- # provider :draugiem, 'App id', 'API Key'
17
- # end
18
- #
19
- # @example Basic Rack example
20
- #
21
- # use Rack::Session::Cookie
22
- # use OmniAuth::Strategies::Draugiem, 'App id', 'API Key'
23
- #
24
- class Draugiem
25
- include OmniAuth::Strategy
26
- attr_accessor :app_id, :api_key
27
-
28
- def initialize(app, app_id, api_key)
29
- super(app, :draugiem)
30
- @app_id = app_id
31
- @api_key = api_key
32
- end
33
-
34
- protected
35
-
36
- def request_phase
37
- params = {
38
- :app => @app_id,
39
- :redirect => callback_url,
40
- :hash => Digest::MD5.hexdigest("#{@api_key}#{callback_url}")
41
- }
42
- query_string = params.collect{ |key,value| "#{key}=#{Rack::Utils.escape(value)}" }.join('&')
43
- redirect "http://api.draugiem.lv/authorize/?#{query_string}"
44
- end
45
-
46
- def callback_phase
47
- if request.params['dr_auth_status'] == 'ok' && request.params['dr_auth_code']
48
- response = RestClient.get('http://api.draugiem.lv/json/', { :params => draugiem_authorize_params(request.params['dr_auth_code']) })
49
- auth = MultiJson.decode(response.to_s)
50
- unless auth['error']
51
- @auth_data = auth
52
- super
53
- else
54
- fail!(auth['error']['code'].to_s,auth["error"]["description"].to_s)
55
- end
56
- else
57
- fail!(:invalid_request)
58
- end
59
- rescue Exception => e
60
- fail!(:invalid_response, e)
61
- end
62
-
63
- def auth_hash
64
- OmniAuth::Utils.deep_merge(super, {
65
- 'uid' => @auth_data['uid'],
66
- 'user_info' => get_user_info,
67
- 'credentials' => {
68
- 'apikey' => @auth_data['apikey']
69
- },
70
- 'extra' => { 'user_hash' => @auth_data }
71
- })
72
- end
73
-
74
- private
75
-
76
- def get_user_info
77
- if @auth_data['users'] && @auth_data['users'][@auth_data['uid']]
78
- user = @auth_data['users'][@auth_data['uid']]
79
- {
80
- 'name' => "#{user['name']} #{user['surname']}",
81
- 'nickname' => user['nick'],
82
- 'first_name' => user['name'],
83
- 'last_name' => user['surname'],
84
- 'location' => user['place'],
85
- 'age' => user['age'] =~ /^0-9$/ ? user['age'] : nil,
86
- 'adult' => user['adult'] == '1' ? true : false,
87
- 'image' => user['img'],
88
- 'sex' => user['sex']
89
- }
90
- else
91
- {}
92
- end
93
- end
94
-
95
- def draugiem_authorize_params code
96
- {
97
- :action => 'authorize',
98
- :app => @api_key,
99
- :code => code
100
- }
101
- end
102
- end
103
- end
104
- end
@@ -1,86 +0,0 @@
1
- require 'omniauth/core'
2
- require 'digest/md5'
3
- require 'rest-client'
4
- require 'multi_json'
5
-
6
- module OmniAuth
7
- module Strategies
8
- #
9
- # Authenticate to Flickr
10
- #
11
- # @example Basic Usage
12
- #
13
- # use OmniAuth::Strategies::Flickr, 'API Key', 'Secret Key', :scope => 'read'
14
- class Flickr
15
- include OmniAuth::Strategy
16
- attr_accessor :api_key, :secret_key, :options
17
-
18
- # error catching, based on OAuth2 callback
19
- class CallbackError < StandardError
20
- attr_accessor :error, :error_reason
21
- def initialize(error, error_reason)
22
- self.error = error
23
- self.error_reason = error_reason
24
- end
25
- end
26
-
27
- # @param [Rack Application] app standard middleware application parameter
28
- # @param [String] api_key the application id as [registered on Flickr](http://www.flickr.com/services/apps/)
29
- # @param [String] secret_key the application secret as [registered on Flickr](http://www.flickr.com/services/apps/)
30
- # @option options ['read','write','delete] :scope ('read') the scope of your authorization request; must be `read` or 'write' or 'delete'
31
- def initialize(app, api_key, secret_key, options = {})
32
- super(app, :flickr)
33
- @api_key = api_key
34
- @secret_key = secret_key
35
- @options = {:scope => 'read'}.merge(options)
36
- end
37
-
38
- protected
39
-
40
- def request_phase
41
- params = { :api_key => api_key, :perms => options[:scope] }
42
- params[:api_sig] = flickr_sign(params)
43
- query_string = params.collect{ |key,value| "#{key}=#{Rack::Utils.escape(value)}" }.join('&')
44
- redirect "http://flickr.com/services/auth/?#{query_string}"
45
- end
46
-
47
- def callback_phase
48
- params = { :api_key => api_key, :method => 'flickr.auth.getToken', :frob => request.params['frob'], :format => 'json', :nojsoncallback => '1' }
49
- params[:api_sig] = flickr_sign(params)
50
-
51
- response = RestClient.get('http://api.flickr.com/services/rest/', { :params => params })
52
- auth = MultiJson.decode(response.to_s)
53
- raise CallbackError.new(auth['code'],auth['message']) if auth['stat'] == 'fail'
54
-
55
- @user = auth['auth']['user']
56
- @access_token = auth['auth']['token']['_content']
57
-
58
- super
59
- rescue CallbackError => e
60
- fail!(:invalid_response, e)
61
- end
62
-
63
- def auth_hash
64
- OmniAuth::Utils.deep_merge(super, {
65
- 'uid' => @user['nsid'],
66
- 'credentials' => { 'token' => @access_token },
67
- 'user_info' => user_info,
68
- 'extra' => { 'user_hash' => @user }
69
- })
70
- end
71
-
72
- def user_info
73
- name = @user['fullname']
74
- name = @user['username'] if name.nil? || name.empty?
75
- {
76
- 'nickname' => @user['username'],
77
- 'name' => name,
78
- }
79
- end
80
-
81
- def flickr_sign(params)
82
- Digest::MD5.hexdigest(secret_key + params.sort{|a,b| a[0].to_s <=> b[0].to_s }.flatten.join)
83
- end
84
- end
85
- end
86
- end
@@ -1,93 +0,0 @@
1
- require 'omniauth/core'
2
- require 'openssl'
3
-
4
- module OmniAuth
5
- module Strategies
6
- class Ign
7
- include OmniAuth::Strategy
8
- IDENTIFIER_URL_PARAMETER = ""
9
-
10
- class CallbackError < StandardError
11
- attr_accessor :error, :error_reason
12
- def initialize(error, error_reason)
13
- self.error = error
14
- self.error_reason = error_reason
15
- end
16
- end
17
-
18
- def initialize(app, api_key, hostname=nil, options = {})
19
- options[:name] ||= "ign"
20
- super(app, :ign)
21
- @api_key = api_key
22
- @hostname = hostname
23
- end
24
-
25
- protected
26
-
27
- def request_phase
28
- OmniAuth::Form.build(:title => 'IGN Authentication', :header_info=>js) do
29
- label_field('Identifying you with the IGN server', IDENTIFIER_URL_PARAMETER)
30
- end.to_response
31
- end
32
-
33
- def callback_phase
34
- signature = OpenSSL::HMAC.hexdigest('sha1', @api_key, ("#{request.params["username"]}::#{request.params["timestamp"]}"))
35
-
36
- raise CallbackError.new("Invalid Signature","The supplied and calculated signature did not match, user not approved.") if signature != request.params["signature"]
37
-
38
- super
39
- rescue CallbackError => e
40
- fail!(:invalid_response, e)
41
- end
42
-
43
- def auth_hash
44
- OmniAuth::Utils.deep_merge(super, {
45
- 'uid' => "ign-" + request.params["username"],
46
- 'credentials' => { 'token' => request.params["signature"] },
47
- 'user_info' => user_info,
48
- 'extra' => { 'user_hash' => request.params }
49
- })
50
- end
51
-
52
- def user_info
53
- {
54
- 'nickname' => request.params["username"],
55
- }
56
- end
57
-
58
- def js
59
- @js = <<-JS
60
- $(document).ready(function() {
61
- $.ajax({
62
- url: "http://#{@hostname}/users/current.json?callback=z33k",
63
- type: "get",
64
- dataType:"jsonp",
65
- success: function(data) {
66
- if(typeof data.error == 'undefined'){
67
- // There is a current My IGN user
68
- var username = data.my_ign_username;
69
- var signature = data.signature;
70
- var timestamp = data.timestamp;
71
- window.location = "/auth/ign/callback?username=" +username+"&signature="+signature+"&timestamp=" + timestamp;
72
- }
73
- else{
74
- nouser();
75
- }
76
- }
77
- });
78
- return false;
79
- });
80
- function nouser() {
81
- var url = "http://my.ign.com/login?r="+window.location;
82
- top.location = url;
83
- window.location = url;
84
- }
85
- JS
86
- "\n<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js' type='text/javascript'></script>" +
87
- "\n<script type='text/javascript'>#{@js}</script>" +
88
- "\n<style type='text/css'>button {visibility:hidden;}</style>"
89
- end
90
-
91
- end
92
- end
93
- end