sorcery 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sorcery might be problematic. Click here for more details.

Files changed (93) hide show
  1. data/Gemfile +5 -2
  2. data/Gemfile.lock +12 -0
  3. data/README.rdoc +12 -7
  4. data/VERSION +1 -1
  5. data/lib/sorcery/controller/submodules/brute_force_protection.rb +1 -1
  6. data/lib/sorcery/crypto_providers/common.rb +2 -2
  7. data/lib/sorcery/engine.rb +0 -4
  8. data/lib/sorcery/initializers/initializer.rb +1 -0
  9. data/lib/sorcery/model/adapters/active_record.rb +28 -0
  10. data/lib/sorcery/model/adapters/mongoid.rb +59 -0
  11. data/lib/sorcery/model/submodules/activity_logging.rb +12 -3
  12. data/lib/sorcery/model/submodules/brute_force_protection.rb +6 -1
  13. data/lib/sorcery/model/submodules/external.rb +1 -0
  14. data/lib/sorcery/model/submodules/remember_me.rb +15 -1
  15. data/lib/sorcery/model/submodules/reset_password.rb +10 -3
  16. data/lib/sorcery/model/submodules/user_activation.rb +11 -1
  17. data/lib/sorcery/model/temporary_token.rb +1 -1
  18. data/lib/sorcery/model.rb +15 -7
  19. data/lib/sorcery/sinatra.rb +0 -1
  20. data/lib/sorcery/test_helpers/internal/sinatra.rb +6 -54
  21. data/lib/sorcery/test_helpers/internal.rb +2 -1
  22. data/lib/sorcery/test_helpers/sinatra.rb +4 -1
  23. data/lib/sorcery.rb +22 -1
  24. data/sorcery.gemspec +107 -10
  25. data/spec/Gemfile.lock +1 -1
  26. data/spec/rails3/Gemfile.lock +5 -5
  27. data/spec/rails3/spec/user_reset_password_spec.rb +2 -2
  28. data/spec/rails3/spec/user_spec.rb +0 -1
  29. data/spec/rails3_mongoid/.gitignore +4 -0
  30. data/spec/rails3_mongoid/.rspec +1 -0
  31. data/spec/rails3_mongoid/Gemfile +14 -0
  32. data/spec/rails3_mongoid/Gemfile.lock +146 -0
  33. data/spec/rails3_mongoid/Rakefile +11 -0
  34. data/spec/rails3_mongoid/app/controllers/application_controller.rb +108 -0
  35. data/spec/rails3_mongoid/app/helpers/application_helper.rb +2 -0
  36. data/spec/rails3_mongoid/app/mailers/sorcery_mailer.rb +25 -0
  37. data/spec/rails3_mongoid/app/models/authentication.rb +7 -0
  38. data/spec/rails3_mongoid/app/models/user.rb +5 -0
  39. data/spec/rails3_mongoid/app/views/layouts/application.html.erb +14 -0
  40. data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.html.erb +17 -0
  41. data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.text.erb +9 -0
  42. data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.html.erb +17 -0
  43. data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.text.erb +9 -0
  44. data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.html.erb +16 -0
  45. data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.text.erb +8 -0
  46. data/spec/rails3_mongoid/config/application.rb +51 -0
  47. data/spec/rails3_mongoid/config/boot.rb +13 -0
  48. data/spec/rails3_mongoid/config/environment.rb +5 -0
  49. data/spec/rails3_mongoid/config/environments/development.rb +26 -0
  50. data/spec/rails3_mongoid/config/environments/in_memory.rb +0 -0
  51. data/spec/rails3_mongoid/config/environments/production.rb +49 -0
  52. data/spec/rails3_mongoid/config/environments/test.rb +35 -0
  53. data/spec/rails3_mongoid/config/initializers/backtrace_silencers.rb +7 -0
  54. data/spec/rails3_mongoid/config/initializers/inflections.rb +10 -0
  55. data/spec/rails3_mongoid/config/initializers/mime_types.rb +5 -0
  56. data/spec/rails3_mongoid/config/initializers/secret_token.rb +7 -0
  57. data/spec/rails3_mongoid/config/initializers/session_store.rb +8 -0
  58. data/spec/rails3_mongoid/config/locales/en.yml +5 -0
  59. data/spec/rails3_mongoid/config/mongoid.yml +7 -0
  60. data/spec/rails3_mongoid/config/routes.rb +59 -0
  61. data/spec/rails3_mongoid/config.ru +4 -0
  62. data/spec/rails3_mongoid/db/schema.rb +23 -0
  63. data/spec/rails3_mongoid/db/seeds.rb +7 -0
  64. data/spec/rails3_mongoid/lib/tasks/.gitkeep +0 -0
  65. data/spec/rails3_mongoid/public/404.html +26 -0
  66. data/spec/rails3_mongoid/public/422.html +26 -0
  67. data/spec/rails3_mongoid/public/500.html +26 -0
  68. data/spec/rails3_mongoid/public/favicon.ico +0 -0
  69. data/spec/rails3_mongoid/public/images/rails.png +0 -0
  70. data/spec/rails3_mongoid/public/javascripts/application.js +2 -0
  71. data/spec/rails3_mongoid/public/javascripts/controls.js +965 -0
  72. data/spec/rails3_mongoid/public/javascripts/dragdrop.js +974 -0
  73. data/spec/rails3_mongoid/public/javascripts/effects.js +1123 -0
  74. data/spec/rails3_mongoid/public/javascripts/prototype.js +6001 -0
  75. data/spec/rails3_mongoid/public/javascripts/rails.js +175 -0
  76. data/spec/rails3_mongoid/public/robots.txt +5 -0
  77. data/spec/rails3_mongoid/public/stylesheets/.gitkeep +0 -0
  78. data/spec/rails3_mongoid/script/rails +6 -0
  79. data/spec/rails3_mongoid/spec/spec.opts +2 -0
  80. data/spec/rails3_mongoid/spec/spec_helper.orig.rb +27 -0
  81. data/spec/rails3_mongoid/spec/spec_helper.rb +55 -0
  82. data/spec/rails3_mongoid/spec/user_activation_spec.rb +178 -0
  83. data/spec/rails3_mongoid/spec/user_activity_logging_spec.rb +31 -0
  84. data/spec/rails3_mongoid/spec/user_brute_force_protection_spec.rb +41 -0
  85. data/spec/rails3_mongoid/spec/user_oauth_spec.rb +34 -0
  86. data/spec/rails3_mongoid/spec/user_remember_me_spec.rb +51 -0
  87. data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +174 -0
  88. data/spec/rails3_mongoid/spec/user_spec.rb +329 -0
  89. data/spec/rails3_mongoid/vendor/plugins/.gitkeep +0 -0
  90. data/spec/sinatra/Gemfile.lock +5 -5
  91. data/spec/sinatra/spec/spec_helper.rb +0 -1
  92. metadata +150 -37
  93. data/spec/untitled folder +0 -18
data/sorcery.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sorcery}
8
- s.version = "0.4.2"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Noam Ben Ari"]
12
- s.date = %q{2011-04-30}
12
+ s.date = %q{2011-05-10}
13
13
  s.description = %q{Provides common authentication needs such as signing in/out, activating by email and resetting password.}
14
14
  s.email = %q{nbenari@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -56,6 +56,8 @@ Gem::Specification.new do |s|
56
56
  "lib/sorcery/engine.rb",
57
57
  "lib/sorcery/initializers/initializer.rb",
58
58
  "lib/sorcery/model.rb",
59
+ "lib/sorcery/model/adapters/active_record.rb",
60
+ "lib/sorcery/model/adapters/mongoid.rb",
59
61
  "lib/sorcery/model/submodules/activity_logging.rb",
60
62
  "lib/sorcery/model/submodules/brute_force_protection.rb",
61
63
  "lib/sorcery/model/submodules/external.rb",
@@ -154,6 +156,67 @@ Gem::Specification.new do |s|
154
156
  "spec/rails3/spec/user_reset_password_spec.rb",
155
157
  "spec/rails3/spec/user_spec.rb",
156
158
  "spec/rails3/vendor/plugins/.gitkeep",
159
+ "spec/rails3_mongoid/.gitignore",
160
+ "spec/rails3_mongoid/.rspec",
161
+ "spec/rails3_mongoid/Gemfile",
162
+ "spec/rails3_mongoid/Gemfile.lock",
163
+ "spec/rails3_mongoid/Rakefile",
164
+ "spec/rails3_mongoid/app/controllers/application_controller.rb",
165
+ "spec/rails3_mongoid/app/helpers/application_helper.rb",
166
+ "spec/rails3_mongoid/app/mailers/sorcery_mailer.rb",
167
+ "spec/rails3_mongoid/app/models/authentication.rb",
168
+ "spec/rails3_mongoid/app/models/user.rb",
169
+ "spec/rails3_mongoid/app/views/layouts/application.html.erb",
170
+ "spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.html.erb",
171
+ "spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.text.erb",
172
+ "spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.html.erb",
173
+ "spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.text.erb",
174
+ "spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.html.erb",
175
+ "spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.text.erb",
176
+ "spec/rails3_mongoid/config.ru",
177
+ "spec/rails3_mongoid/config/application.rb",
178
+ "spec/rails3_mongoid/config/boot.rb",
179
+ "spec/rails3_mongoid/config/environment.rb",
180
+ "spec/rails3_mongoid/config/environments/development.rb",
181
+ "spec/rails3_mongoid/config/environments/in_memory.rb",
182
+ "spec/rails3_mongoid/config/environments/production.rb",
183
+ "spec/rails3_mongoid/config/environments/test.rb",
184
+ "spec/rails3_mongoid/config/initializers/backtrace_silencers.rb",
185
+ "spec/rails3_mongoid/config/initializers/inflections.rb",
186
+ "spec/rails3_mongoid/config/initializers/mime_types.rb",
187
+ "spec/rails3_mongoid/config/initializers/secret_token.rb",
188
+ "spec/rails3_mongoid/config/initializers/session_store.rb",
189
+ "spec/rails3_mongoid/config/locales/en.yml",
190
+ "spec/rails3_mongoid/config/mongoid.yml",
191
+ "spec/rails3_mongoid/config/routes.rb",
192
+ "spec/rails3_mongoid/db/schema.rb",
193
+ "spec/rails3_mongoid/db/seeds.rb",
194
+ "spec/rails3_mongoid/lib/tasks/.gitkeep",
195
+ "spec/rails3_mongoid/public/404.html",
196
+ "spec/rails3_mongoid/public/422.html",
197
+ "spec/rails3_mongoid/public/500.html",
198
+ "spec/rails3_mongoid/public/favicon.ico",
199
+ "spec/rails3_mongoid/public/images/rails.png",
200
+ "spec/rails3_mongoid/public/javascripts/application.js",
201
+ "spec/rails3_mongoid/public/javascripts/controls.js",
202
+ "spec/rails3_mongoid/public/javascripts/dragdrop.js",
203
+ "spec/rails3_mongoid/public/javascripts/effects.js",
204
+ "spec/rails3_mongoid/public/javascripts/prototype.js",
205
+ "spec/rails3_mongoid/public/javascripts/rails.js",
206
+ "spec/rails3_mongoid/public/robots.txt",
207
+ "spec/rails3_mongoid/public/stylesheets/.gitkeep",
208
+ "spec/rails3_mongoid/script/rails",
209
+ "spec/rails3_mongoid/spec/spec.opts",
210
+ "spec/rails3_mongoid/spec/spec_helper.orig.rb",
211
+ "spec/rails3_mongoid/spec/spec_helper.rb",
212
+ "spec/rails3_mongoid/spec/user_activation_spec.rb",
213
+ "spec/rails3_mongoid/spec/user_activity_logging_spec.rb",
214
+ "spec/rails3_mongoid/spec/user_brute_force_protection_spec.rb",
215
+ "spec/rails3_mongoid/spec/user_oauth_spec.rb",
216
+ "spec/rails3_mongoid/spec/user_remember_me_spec.rb",
217
+ "spec/rails3_mongoid/spec/user_reset_password_spec.rb",
218
+ "spec/rails3_mongoid/spec/user_spec.rb",
219
+ "spec/rails3_mongoid/vendor/plugins/.gitkeep",
157
220
  "spec/sinatra/Gemfile",
158
221
  "spec/sinatra/Gemfile.lock",
159
222
  "spec/sinatra/Rakefile",
@@ -182,8 +245,7 @@ Gem::Specification.new do |s|
182
245
  "spec/sinatra/views/test_login.erb",
183
246
  "spec/sorcery_crypto_providers_spec.rb",
184
247
  "spec/spec.opts",
185
- "spec/spec_helper.rb",
186
- "spec/untitled folder"
248
+ "spec/spec_helper.rb"
187
249
  ]
188
250
  s.homepage = %q{http://github.com/NoamB/sorcery}
189
251
  s.licenses = ["MIT"]
@@ -235,6 +297,35 @@ Gem::Specification.new do |s|
235
297
  "spec/rails3/spec/user_remember_me_spec.rb",
236
298
  "spec/rails3/spec/user_reset_password_spec.rb",
237
299
  "spec/rails3/spec/user_spec.rb",
300
+ "spec/rails3_mongoid/app/controllers/application_controller.rb",
301
+ "spec/rails3_mongoid/app/helpers/application_helper.rb",
302
+ "spec/rails3_mongoid/app/mailers/sorcery_mailer.rb",
303
+ "spec/rails3_mongoid/app/models/authentication.rb",
304
+ "spec/rails3_mongoid/app/models/user.rb",
305
+ "spec/rails3_mongoid/config/application.rb",
306
+ "spec/rails3_mongoid/config/boot.rb",
307
+ "spec/rails3_mongoid/config/environment.rb",
308
+ "spec/rails3_mongoid/config/environments/development.rb",
309
+ "spec/rails3_mongoid/config/environments/in_memory.rb",
310
+ "spec/rails3_mongoid/config/environments/production.rb",
311
+ "spec/rails3_mongoid/config/environments/test.rb",
312
+ "spec/rails3_mongoid/config/initializers/backtrace_silencers.rb",
313
+ "spec/rails3_mongoid/config/initializers/inflections.rb",
314
+ "spec/rails3_mongoid/config/initializers/mime_types.rb",
315
+ "spec/rails3_mongoid/config/initializers/secret_token.rb",
316
+ "spec/rails3_mongoid/config/initializers/session_store.rb",
317
+ "spec/rails3_mongoid/config/routes.rb",
318
+ "spec/rails3_mongoid/db/schema.rb",
319
+ "spec/rails3_mongoid/db/seeds.rb",
320
+ "spec/rails3_mongoid/spec/spec_helper.orig.rb",
321
+ "spec/rails3_mongoid/spec/spec_helper.rb",
322
+ "spec/rails3_mongoid/spec/user_activation_spec.rb",
323
+ "spec/rails3_mongoid/spec/user_activity_logging_spec.rb",
324
+ "spec/rails3_mongoid/spec/user_brute_force_protection_spec.rb",
325
+ "spec/rails3_mongoid/spec/user_oauth_spec.rb",
326
+ "spec/rails3_mongoid/spec/user_remember_me_spec.rb",
327
+ "spec/rails3_mongoid/spec/user_reset_password_spec.rb",
328
+ "spec/rails3_mongoid/spec/user_spec.rb",
238
329
  "spec/sinatra/authentication.rb",
239
330
  "spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb",
240
331
  "spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
@@ -264,10 +355,12 @@ Gem::Specification.new do |s|
264
355
  s.specification_version = 3
265
356
 
266
357
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
267
- s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
268
- s.add_runtime_dependency(%q<json>, [">= 1.5.1"])
269
358
  s.add_runtime_dependency(%q<oauth>, [">= 0.4.4"])
270
359
  s.add_runtime_dependency(%q<oauth2>, [">= 0.1.1"])
360
+ s.add_development_dependency(%q<rails>, [">= 3.0.0"])
361
+ s.add_development_dependency(%q<json>, [">= 1.5.1"])
362
+ s.add_development_dependency(%q<mongoid>, ["~> 2.0"])
363
+ s.add_development_dependency(%q<bson_ext>, ["~> 1.3"])
271
364
  s.add_development_dependency(%q<rspec>, ["~> 2.5.0"])
272
365
  s.add_development_dependency(%q<rspec-rails>, ["~> 2.5.0"])
273
366
  s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
@@ -281,10 +374,12 @@ Gem::Specification.new do |s|
281
374
  s.add_runtime_dependency(%q<oauth>, [">= 0.4.4"])
282
375
  s.add_runtime_dependency(%q<oauth2>, [">= 0.1.1"])
283
376
  else
284
- s.add_dependency(%q<rails>, [">= 3.0.0"])
285
- s.add_dependency(%q<json>, [">= 1.5.1"])
286
377
  s.add_dependency(%q<oauth>, [">= 0.4.4"])
287
378
  s.add_dependency(%q<oauth2>, [">= 0.1.1"])
379
+ s.add_dependency(%q<rails>, [">= 3.0.0"])
380
+ s.add_dependency(%q<json>, [">= 1.5.1"])
381
+ s.add_dependency(%q<mongoid>, ["~> 2.0"])
382
+ s.add_dependency(%q<bson_ext>, ["~> 1.3"])
288
383
  s.add_dependency(%q<rspec>, ["~> 2.5.0"])
289
384
  s.add_dependency(%q<rspec-rails>, ["~> 2.5.0"])
290
385
  s.add_dependency(%q<ruby-debug19>, [">= 0"])
@@ -299,10 +394,12 @@ Gem::Specification.new do |s|
299
394
  s.add_dependency(%q<oauth2>, [">= 0.1.1"])
300
395
  end
301
396
  else
302
- s.add_dependency(%q<rails>, [">= 3.0.0"])
303
- s.add_dependency(%q<json>, [">= 1.5.1"])
304
397
  s.add_dependency(%q<oauth>, [">= 0.4.4"])
305
398
  s.add_dependency(%q<oauth2>, [">= 0.1.1"])
399
+ s.add_dependency(%q<rails>, [">= 3.0.0"])
400
+ s.add_dependency(%q<json>, [">= 1.5.1"])
401
+ s.add_dependency(%q<mongoid>, ["~> 2.0"])
402
+ s.add_dependency(%q<bson_ext>, ["~> 1.3"])
306
403
  s.add_dependency(%q<rspec>, ["~> 2.5.0"])
307
404
  s.add_dependency(%q<rspec-rails>, ["~> 2.5.0"])
308
405
  s.add_dependency(%q<ruby-debug19>, [">= 0"])
data/spec/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- sorcery (0.4.2)
4
+ sorcery (0.5.0)
5
5
  bcrypt-ruby (~> 2.1.4)
6
6
  json (>= 1.5.1)
7
7
  oauth (>= 0.4.4)
@@ -2,7 +2,7 @@ PATH
2
2
  remote: ../../../
3
3
  specs:
4
4
  oauth (0.4.4)
5
- sorcery (0.4.2)
5
+ sorcery (0.5.0)
6
6
  bcrypt-ruby (~> 2.1.4)
7
7
  json (>= 1.5.1)
8
8
  oauth (>= 0.4.4)
@@ -64,11 +64,11 @@ GEM
64
64
  mime-types (~> 1.16)
65
65
  treetop (~> 1.4.8)
66
66
  mime-types (1.16)
67
- multi_json (0.0.5)
67
+ multi_json (1.0.1)
68
68
  multipart-post (1.1.0)
69
- oauth2 (0.4.0)
70
- faraday (~> 0.6.0)
71
- multi_json (~> 0.0.4)
69
+ oauth2 (0.4.1)
70
+ faraday (~> 0.6.1)
71
+ multi_json (>= 0.0.5)
72
72
  polyglot (0.3.1)
73
73
  rack (1.2.1)
74
74
  rack-mount (0.6.13)
@@ -27,7 +27,7 @@ describe "User with reset_password submodule" do
27
27
 
28
28
  specify { @user.should respond_to(:deliver_reset_password_instructions!) }
29
29
 
30
- specify { @user.should respond_to(:reset_password!) }
30
+ specify { @user.should respond_to(:change_password!) }
31
31
 
32
32
  it "should respond to .load_from_reset_password_token" do
33
33
  User.should respond_to(:load_from_reset_password_token)
@@ -146,7 +146,7 @@ describe "User with reset_password submodule" do
146
146
  create_new_user
147
147
  @user.deliver_reset_password_instructions!
148
148
  @user.reset_password_token.should_not be_nil
149
- @user.reset_password!(:password => "blabulsdf")
149
+ @user.change_password!("blabulsdf")
150
150
  @user.save!
151
151
  @user.reset_password_token.should be_nil
152
152
  end
@@ -323,5 +323,4 @@ describe "User with no submodules (core)" do
323
323
  @user.external?.should be_true
324
324
  end
325
325
  end
326
-
327
326
  end
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ db/*.sqlite3
3
+ log/*.log
4
+ tmp/**/*
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,14 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '3.0.3'
4
+ gem "sorcery", '>= 0.1.0', :path => '../../../'
5
+ gem "mongoid", "~> 2.0"
6
+ gem "bson_ext", "~> 1.3"
7
+
8
+ group :development, :test do
9
+ gem "rspec", "~> 2.5.0"
10
+ gem 'rspec-rails', "~> 2.5.0"
11
+ gem 'ruby-debug19'
12
+ gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
13
+ gem 'timecop'
14
+ end
@@ -0,0 +1,146 @@
1
+ PATH
2
+ remote: ../../../
3
+ specs:
4
+ oauth (0.4.4)
5
+ sorcery (0.5.0)
6
+ bcrypt-ruby (~> 2.1.4)
7
+ json (>= 1.5.1)
8
+ oauth (>= 0.4.4)
9
+ oauth (>= 0.4.4)
10
+ oauth2 (>= 0.1.1)
11
+ oauth2 (>= 0.1.1)
12
+ rails (>= 3.0.0)
13
+
14
+ GEM
15
+ remote: http://rubygems.org/
16
+ specs:
17
+ abstract (1.0.0)
18
+ actionmailer (3.0.3)
19
+ actionpack (= 3.0.3)
20
+ mail (~> 2.2.9)
21
+ actionpack (3.0.3)
22
+ activemodel (= 3.0.3)
23
+ activesupport (= 3.0.3)
24
+ builder (~> 2.1.2)
25
+ erubis (~> 2.6.6)
26
+ i18n (~> 0.4)
27
+ rack (~> 1.2.1)
28
+ rack-mount (~> 0.6.13)
29
+ rack-test (~> 0.5.6)
30
+ tzinfo (~> 0.3.23)
31
+ activemodel (3.0.3)
32
+ activesupport (= 3.0.3)
33
+ builder (~> 2.1.2)
34
+ i18n (~> 0.4)
35
+ activerecord (3.0.3)
36
+ activemodel (= 3.0.3)
37
+ activesupport (= 3.0.3)
38
+ arel (~> 2.0.2)
39
+ tzinfo (~> 0.3.23)
40
+ activeresource (3.0.3)
41
+ activemodel (= 3.0.3)
42
+ activesupport (= 3.0.3)
43
+ activesupport (3.0.3)
44
+ addressable (2.2.5)
45
+ archive-tar-minitar (0.5.2)
46
+ arel (2.0.6)
47
+ bcrypt-ruby (2.1.4)
48
+ bson (1.3.0)
49
+ bson_ext (1.3.0)
50
+ builder (2.1.2)
51
+ columnize (0.3.2)
52
+ diff-lcs (1.1.2)
53
+ erubis (2.6.6)
54
+ abstract (>= 1.0.0)
55
+ faraday (0.6.1)
56
+ addressable (~> 2.2.4)
57
+ multipart-post (~> 1.1.0)
58
+ rack (< 2, >= 1.1.0)
59
+ i18n (0.5.0)
60
+ json (1.5.1)
61
+ linecache19 (0.5.11)
62
+ ruby_core_source (>= 0.1.4)
63
+ mail (2.2.13)
64
+ activesupport (>= 2.3.6)
65
+ i18n (>= 0.4.0)
66
+ mime-types (~> 1.16)
67
+ treetop (~> 1.4.8)
68
+ mime-types (1.16)
69
+ mongo (1.3.0)
70
+ bson (>= 1.3.0)
71
+ mongoid (2.0.1)
72
+ activemodel (~> 3.0)
73
+ mongo (~> 1.3)
74
+ tzinfo (~> 0.3.22)
75
+ will_paginate (~> 3.0.pre)
76
+ multi_json (1.0.1)
77
+ multipart-post (1.1.0)
78
+ oauth2 (0.4.1)
79
+ faraday (~> 0.6.1)
80
+ multi_json (>= 0.0.5)
81
+ polyglot (0.3.1)
82
+ rack (1.2.1)
83
+ rack-mount (0.6.13)
84
+ rack (>= 1.0.0)
85
+ rack-test (0.5.6)
86
+ rack (>= 1.0)
87
+ rails (3.0.3)
88
+ actionmailer (= 3.0.3)
89
+ actionpack (= 3.0.3)
90
+ activerecord (= 3.0.3)
91
+ activeresource (= 3.0.3)
92
+ activesupport (= 3.0.3)
93
+ bundler (~> 1.0)
94
+ railties (= 3.0.3)
95
+ railties (3.0.3)
96
+ actionpack (= 3.0.3)
97
+ activesupport (= 3.0.3)
98
+ rake (>= 0.8.7)
99
+ thor (~> 0.14.4)
100
+ rake (0.8.7)
101
+ rspec (2.5.0)
102
+ rspec-core (~> 2.5.0)
103
+ rspec-expectations (~> 2.5.0)
104
+ rspec-mocks (~> 2.5.0)
105
+ rspec-core (2.5.1)
106
+ rspec-expectations (2.5.0)
107
+ diff-lcs (~> 1.1.2)
108
+ rspec-mocks (2.5.0)
109
+ rspec-rails (2.5.0)
110
+ actionpack (~> 3.0)
111
+ activesupport (~> 3.0)
112
+ railties (~> 3.0)
113
+ rspec (~> 2.5.0)
114
+ ruby-debug-base19 (0.11.24)
115
+ columnize (>= 0.3.1)
116
+ linecache19 (>= 0.5.11)
117
+ ruby_core_source (>= 0.1.4)
118
+ ruby-debug19 (0.11.6)
119
+ columnize (>= 0.3.1)
120
+ linecache19 (>= 0.5.11)
121
+ ruby-debug-base19 (>= 0.11.19)
122
+ ruby_core_source (0.1.4)
123
+ archive-tar-minitar (>= 0.5.2)
124
+ simplecov (0.3.9)
125
+ simplecov-html (>= 0.3.7)
126
+ simplecov-html (0.3.9)
127
+ thor (0.14.6)
128
+ timecop (0.3.5)
129
+ treetop (1.4.9)
130
+ polyglot (>= 0.3.1)
131
+ tzinfo (0.3.23)
132
+ will_paginate (3.0.pre2)
133
+
134
+ PLATFORMS
135
+ ruby
136
+
137
+ DEPENDENCIES
138
+ bson_ext (~> 1.3)
139
+ mongoid (~> 2.0)
140
+ rails (= 3.0.3)
141
+ rspec (~> 2.5.0)
142
+ rspec-rails (~> 2.5.0)
143
+ ruby-debug19
144
+ simplecov (>= 0.3.8)
145
+ sorcery (>= 0.1.0)!
146
+ timecop
@@ -0,0 +1,11 @@
1
+ require 'rake'
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc 'Default: Run all specs for a specific rails version.'
5
+ task :default => :spec
6
+
7
+ desc "Run all specs for a specific rails version"
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.pattern = '**/*_spec.rb'
10
+ t.rspec_opts = ["--options #{File.dirname(__FILE__)}/spec/spec.opts"]
11
+ end
@@ -0,0 +1,108 @@
1
+ require 'oauth'
2
+
3
+ class ApplicationController < ActionController::Base
4
+ protect_from_forgery
5
+
6
+ #before_filter :validate_session, :only => [:test_should_be_logged_in] if defined?(:validate_session)
7
+ before_filter :require_login_from_http_basic, :only => [:test_http_basic_auth]
8
+ before_filter :require_login, :only => [:test_logout, :test_should_be_logged_in, :some_action]
9
+
10
+ def index
11
+ @user = User.first
12
+ render :text => @user.attributes.inspect
13
+ end
14
+
15
+ def some_action
16
+ render :nothing => true
17
+ end
18
+
19
+ def test_login
20
+ @user = login(params[:username], params[:password])
21
+ render :text => ""
22
+ end
23
+
24
+ def test_return_to
25
+ @user = login(params[:username], params[:password])
26
+ redirect_back_or_to(:index, :notice => 'haha!')
27
+ end
28
+
29
+ def test_logout
30
+ logout
31
+ render :text => ""
32
+ end
33
+
34
+ def test_logout_with_remember
35
+ remember_me!
36
+ logout
37
+ render :text => ""
38
+ end
39
+
40
+ def test_login_with_remember
41
+ @user = login(params[:username], params[:password])
42
+ remember_me!
43
+
44
+ render :text => ""
45
+ end
46
+
47
+ def test_login_with_remember_in_login
48
+ @user = login(params[:username], params[:password], params[:remember])
49
+
50
+ render :text => ""
51
+ end
52
+
53
+ def test_login_from_cookie
54
+ @user = current_user
55
+ render :text => ""
56
+ end
57
+
58
+ def test_not_authenticated_action
59
+ render :text => "test_not_authenticated_action"
60
+ end
61
+
62
+ def test_should_be_logged_in
63
+ render :text => ""
64
+ end
65
+
66
+ def test_http_basic_auth
67
+ render :text => "HTTP Basic Auth"
68
+ end
69
+
70
+ def login_at_test
71
+ login_at(:twitter)
72
+ end
73
+
74
+ def login_at_test2
75
+ login_at(:facebook)
76
+ end
77
+
78
+ def test_login_from
79
+ if @user = login_from(:twitter)
80
+ redirect_to "bla", :notice => "Success!"
81
+ else
82
+ redirect_to "blu", :alert => "Failed!"
83
+ end
84
+ end
85
+
86
+ def test_login_from2
87
+ if @user = login_from(:facebook)
88
+ redirect_to "bla", :notice => "Success!"
89
+ else
90
+ redirect_to "blu", :alert => "Failed!"
91
+ end
92
+ end
93
+
94
+ def test_create_from_provider
95
+ provider = params[:provider]
96
+ login_from(provider)
97
+ if @user = create_from(provider)
98
+ redirect_to "bla", :notice => "Success!"
99
+ else
100
+ redirect_to "blu", :alert => "Failed!"
101
+ end
102
+ end
103
+
104
+ protected
105
+
106
+
107
+
108
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,25 @@
1
+ class SorceryMailer < ActionMailer::Base
2
+
3
+ default :from => "notifications@example.com"
4
+
5
+ def activation_needed_email(user)
6
+ @user = user
7
+ @url = "http://example.com/login"
8
+ mail(:to => user.email,
9
+ :subject => "Welcome to My Awesome Site")
10
+ end
11
+
12
+ def activation_success_email(user)
13
+ @user = user
14
+ @url = "http://example.com/login"
15
+ mail(:to => user.email,
16
+ :subject => "Your account is now activated")
17
+ end
18
+
19
+ def reset_password_email(user)
20
+ @user = user
21
+ @url = "http://example.com/login"
22
+ mail(:to => user.email,
23
+ :subject => "Your password has been reset")
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ class Authentication
2
+ include Mongoid::Document
3
+ field :user_id, type: Integer
4
+ field :provider, type: String
5
+ field :uid, type: Integer
6
+ belongs_to :user
7
+ end
@@ -0,0 +1,5 @@
1
+ class User
2
+ include Mongoid::Document
3
+
4
+ has_many :authentications, :dependent => :destroy
5
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>AppRoot</title>
5
+ <%= stylesheet_link_tag :all %>
6
+ <%= javascript_include_tag :defaults %>
7
+ <%= csrf_meta_tag %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5
+ </head>
6
+ <body>
7
+ <h1>Welcome to example.com, <%= @user.username %></h1>
8
+ <p>
9
+ You have successfully signed up to example.com,
10
+ your username is: <%= @user.username %>.<br/>
11
+ </p>
12
+ <p>
13
+ To login to the site, just follow this link: <%= @url %>.
14
+ </p>
15
+ <p>Thanks for joining and have a great day!</p>
16
+ </body>
17
+ </html>
@@ -0,0 +1,9 @@
1
+ Welcome to example.com, <%= @user.username %>
2
+ ===============================================
3
+
4
+ You have successfully signed up to example.com,
5
+ your username is: <%= @user.username %>.
6
+
7
+ To login to the site, just follow this link: <%= @url %>.
8
+
9
+ Thanks for joining and have a great day!
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5
+ </head>
6
+ <body>
7
+ <h1>Congratz, <%= @user.username %></h1>
8
+ <p>
9
+ You have successfully activated your example.com account,
10
+ your username is: <%= @user.username %>.<br/>
11
+ </p>
12
+ <p>
13
+ To login to the site, just follow this link: <%= @url %>.
14
+ </p>
15
+ <p>Thanks for joining and have a great day!</p>
16
+ </body>
17
+ </html>
@@ -0,0 +1,9 @@
1
+ Congratz, <%= @user.username %>
2
+ ===============================================
3
+
4
+ You have successfully activated your example.com account,
5
+ your username is: <%= @user.username %>.
6
+
7
+ To login to the site, just follow this link: <%= @url %>.
8
+
9
+ Thanks for joining and have a great day!
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5
+ </head>
6
+ <body>
7
+ <h1>Hello, <%= @user.username %></h1>
8
+ <p>
9
+ You have requested to reset your password.
10
+ </p>
11
+ <p>
12
+ To choose a new password, just follow this link: <%= @url %>.
13
+ </p>
14
+ <p>Have a great day!</p>
15
+ </body>
16
+ </html>