sorcery 0.1.0 → 0.2.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 (75) hide show
  1. data/Gemfile +4 -3
  2. data/Gemfile.lock +16 -13
  3. data/LICENSE.txt +1 -1
  4. data/README.rdoc +77 -63
  5. data/Rakefile +7 -12
  6. data/VERSION +1 -1
  7. data/lib/sorcery/controller/submodules/activity_logging.rb +58 -0
  8. data/lib/sorcery/controller/submodules/brute_force_protection.rb +15 -69
  9. data/lib/sorcery/controller/submodules/http_basic_auth.rb +65 -0
  10. data/lib/sorcery/controller/submodules/oauth/oauth1.rb +25 -0
  11. data/lib/sorcery/controller/submodules/oauth/oauth2.rb +23 -0
  12. data/lib/sorcery/controller/submodules/oauth/providers/facebook.rb +64 -0
  13. data/lib/sorcery/controller/submodules/oauth/providers/twitter.rb +61 -0
  14. data/lib/sorcery/controller/submodules/oauth.rb +95 -0
  15. data/lib/sorcery/controller/submodules/remember_me.rb +14 -5
  16. data/lib/sorcery/controller/submodules/session_timeout.rb +10 -2
  17. data/lib/sorcery/controller.rb +40 -22
  18. data/lib/sorcery/crypto_providers/bcrypt.rb +2 -6
  19. data/lib/sorcery/engine.rb +9 -2
  20. data/lib/sorcery/model/submodules/activity_logging.rb +40 -0
  21. data/lib/sorcery/model/submodules/brute_force_protection.rb +79 -0
  22. data/lib/sorcery/model/submodules/oauth.rb +53 -0
  23. data/lib/sorcery/model/submodules/remember_me.rb +6 -2
  24. data/lib/sorcery/model/submodules/reset_password.rb +96 -0
  25. data/lib/sorcery/model/submodules/user_activation.rb +44 -23
  26. data/lib/sorcery/model/temporary_token.rb +22 -0
  27. data/lib/sorcery/model.rb +22 -9
  28. data/lib/sorcery/test_helpers.rb +84 -0
  29. data/lib/sorcery.rb +17 -1
  30. data/sorcery.gemspec +250 -0
  31. data/spec/Gemfile +3 -2
  32. data/spec/Gemfile.lock +15 -2
  33. data/spec/rails3/app_root/.rspec +1 -0
  34. data/spec/rails3/{Gemfile → app_root/Gemfile} +6 -3
  35. data/spec/rails3/{Gemfile.lock → app_root/Gemfile.lock} +27 -2
  36. data/spec/rails3/app_root/app/controllers/application_controller.rb +48 -2
  37. data/spec/rails3/app_root/app/models/authentication.rb +3 -0
  38. data/spec/rails3/app_root/app/models/user.rb +4 -1
  39. data/spec/rails3/app_root/config/application.rb +1 -3
  40. data/spec/rails3/app_root/config/routes.rb +1 -9
  41. data/spec/rails3/app_root/db/migrate/activation/20101224223622_add_activation_to_users.rb +6 -4
  42. data/spec/rails3/app_root/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +17 -0
  43. data/spec/rails3/app_root/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +11 -0
  44. data/spec/rails3/app_root/db/migrate/core/20101224223620_create_users.rb +4 -4
  45. data/spec/rails3/app_root/db/migrate/oauth/20101224223628_create_authentications.rb +14 -0
  46. data/spec/rails3/app_root/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +13 -0
  47. data/spec/rails3/app_root/spec/controller_activity_logging_spec.rb +84 -0
  48. data/spec/rails3/app_root/spec/controller_brute_force_protection_spec.rb +65 -0
  49. data/spec/rails3/app_root/spec/controller_http_basic_auth_spec.rb +50 -0
  50. data/spec/rails3/app_root/spec/controller_oauth2_spec.rb +117 -0
  51. data/spec/rails3/app_root/spec/controller_oauth_spec.rb +117 -0
  52. data/spec/rails3/{controller_remember_me_spec.rb → app_root/spec/controller_remember_me_spec.rb} +4 -4
  53. data/spec/rails3/{controller_session_timeout_spec.rb → app_root/spec/controller_session_timeout_spec.rb} +5 -4
  54. data/spec/rails3/{controller_spec.rb → app_root/spec/controller_spec.rb} +23 -16
  55. data/spec/rails3/app_root/spec/spec_helper.orig.rb +27 -0
  56. data/spec/rails3/app_root/spec/spec_helper.rb +61 -0
  57. data/spec/rails3/{user_activation_spec.rb → app_root/spec/user_activation_spec.rb} +62 -22
  58. data/spec/rails3/app_root/spec/user_activity_logging_spec.rb +36 -0
  59. data/spec/rails3/app_root/spec/user_brute_force_protection_spec.rb +76 -0
  60. data/spec/rails3/app_root/spec/user_oauth_spec.rb +39 -0
  61. data/spec/rails3/{user_remember_me_spec.rb → app_root/spec/user_remember_me_spec.rb} +4 -4
  62. data/spec/rails3/app_root/spec/user_reset_password_spec.rb +178 -0
  63. data/spec/rails3/{user_spec.rb → app_root/spec/user_spec.rb} +75 -41
  64. metadata +147 -102
  65. data/features/support/env.rb +0 -13
  66. data/lib/sorcery/model/submodules/password_reset.rb +0 -64
  67. data/spec/rails3/app_root/db/migrate/password_reset/20101224223622_add_password_reset_to_users.rb +0 -9
  68. data/spec/rails3/app_root/test/fixtures/users.yml +0 -9
  69. data/spec/rails3/app_root/test/performance/browsing_test.rb +0 -9
  70. data/spec/rails3/app_root/test/test_helper.rb +0 -13
  71. data/spec/rails3/app_root/test/unit/user_test.rb +0 -8
  72. data/spec/rails3/controller_brute_force_protection_spec.rb +0 -72
  73. data/spec/rails3/spec_helper.rb +0 -115
  74. data/spec/rails3/user_password_reset_spec.rb +0 -76
  75. /data/spec/rails3/{Rakefile → app_root/Rakefile} +0 -0
data/sorcery.gemspec ADDED
@@ -0,0 +1,250 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{sorcery}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Noam Ben Ari"]
12
+ s.date = %q{2011-03-13}
13
+ s.description = %q{Provides common authentication needs such as signing in/out, activating by email and resetting password.}
14
+ s.email = %q{nbenari@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/sorcery.rb",
29
+ "lib/sorcery/controller.rb",
30
+ "lib/sorcery/controller/submodules/activity_logging.rb",
31
+ "lib/sorcery/controller/submodules/brute_force_protection.rb",
32
+ "lib/sorcery/controller/submodules/http_basic_auth.rb",
33
+ "lib/sorcery/controller/submodules/oauth.rb",
34
+ "lib/sorcery/controller/submodules/oauth/oauth1.rb",
35
+ "lib/sorcery/controller/submodules/oauth/oauth2.rb",
36
+ "lib/sorcery/controller/submodules/oauth/providers/facebook.rb",
37
+ "lib/sorcery/controller/submodules/oauth/providers/twitter.rb",
38
+ "lib/sorcery/controller/submodules/remember_me.rb",
39
+ "lib/sorcery/controller/submodules/session_timeout.rb",
40
+ "lib/sorcery/crypto_providers/aes256.rb",
41
+ "lib/sorcery/crypto_providers/bcrypt.rb",
42
+ "lib/sorcery/crypto_providers/md5.rb",
43
+ "lib/sorcery/crypto_providers/sha1.rb",
44
+ "lib/sorcery/crypto_providers/sha256.rb",
45
+ "lib/sorcery/crypto_providers/sha512.rb",
46
+ "lib/sorcery/engine.rb",
47
+ "lib/sorcery/model.rb",
48
+ "lib/sorcery/model/submodules/activity_logging.rb",
49
+ "lib/sorcery/model/submodules/brute_force_protection.rb",
50
+ "lib/sorcery/model/submodules/oauth.rb",
51
+ "lib/sorcery/model/submodules/remember_me.rb",
52
+ "lib/sorcery/model/submodules/reset_password.rb",
53
+ "lib/sorcery/model/submodules/user_activation.rb",
54
+ "lib/sorcery/model/temporary_token.rb",
55
+ "lib/sorcery/test_helpers.rb",
56
+ "sorcery.gemspec",
57
+ "spec/Gemfile",
58
+ "spec/Gemfile.lock",
59
+ "spec/Rakefile",
60
+ "spec/rails3/.rspec",
61
+ "spec/rails3/app_root/.gitignore",
62
+ "spec/rails3/app_root/.rspec",
63
+ "spec/rails3/app_root/Gemfile",
64
+ "spec/rails3/app_root/Gemfile.lock",
65
+ "spec/rails3/app_root/README",
66
+ "spec/rails3/app_root/Rakefile",
67
+ "spec/rails3/app_root/Rakefile.unused",
68
+ "spec/rails3/app_root/app/controllers/application_controller.rb",
69
+ "spec/rails3/app_root/app/helpers/application_helper.rb",
70
+ "spec/rails3/app_root/app/mailers/sorcery_mailer.rb",
71
+ "spec/rails3/app_root/app/models/authentication.rb",
72
+ "spec/rails3/app_root/app/models/user.rb",
73
+ "spec/rails3/app_root/app/views/layouts/application.html.erb",
74
+ "spec/rails3/app_root/app/views/sorcery_mailer/activation_email.html.erb",
75
+ "spec/rails3/app_root/app/views/sorcery_mailer/activation_email.text.erb",
76
+ "spec/rails3/app_root/app/views/sorcery_mailer/activation_success_email.html.erb",
77
+ "spec/rails3/app_root/app/views/sorcery_mailer/activation_success_email.text.erb",
78
+ "spec/rails3/app_root/app/views/sorcery_mailer/reset_password_email.html.erb",
79
+ "spec/rails3/app_root/app/views/sorcery_mailer/reset_password_email.text.erb",
80
+ "spec/rails3/app_root/config.ru",
81
+ "spec/rails3/app_root/config/application.rb",
82
+ "spec/rails3/app_root/config/boot.rb",
83
+ "spec/rails3/app_root/config/database.yml",
84
+ "spec/rails3/app_root/config/environment.rb",
85
+ "spec/rails3/app_root/config/environments/development.rb",
86
+ "spec/rails3/app_root/config/environments/in_memory.rb",
87
+ "spec/rails3/app_root/config/environments/production.rb",
88
+ "spec/rails3/app_root/config/environments/test.rb",
89
+ "spec/rails3/app_root/config/initializers/backtrace_silencers.rb",
90
+ "spec/rails3/app_root/config/initializers/inflections.rb",
91
+ "spec/rails3/app_root/config/initializers/mime_types.rb",
92
+ "spec/rails3/app_root/config/initializers/secret_token.rb",
93
+ "spec/rails3/app_root/config/initializers/session_store.rb",
94
+ "spec/rails3/app_root/config/locales/en.yml",
95
+ "spec/rails3/app_root/config/routes.rb",
96
+ "spec/rails3/app_root/db/migrate/activation/20101224223622_add_activation_to_users.rb",
97
+ "spec/rails3/app_root/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
98
+ "spec/rails3/app_root/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb",
99
+ "spec/rails3/app_root/db/migrate/core/20101224223620_create_users.rb",
100
+ "spec/rails3/app_root/db/migrate/oauth/20101224223628_create_authentications.rb",
101
+ "spec/rails3/app_root/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
102
+ "spec/rails3/app_root/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
103
+ "spec/rails3/app_root/db/schema.rb",
104
+ "spec/rails3/app_root/db/seeds.rb",
105
+ "spec/rails3/app_root/lib/tasks/.gitkeep",
106
+ "spec/rails3/app_root/public/404.html",
107
+ "spec/rails3/app_root/public/422.html",
108
+ "spec/rails3/app_root/public/500.html",
109
+ "spec/rails3/app_root/public/favicon.ico",
110
+ "spec/rails3/app_root/public/images/rails.png",
111
+ "spec/rails3/app_root/public/index.html",
112
+ "spec/rails3/app_root/public/javascripts/application.js",
113
+ "spec/rails3/app_root/public/javascripts/controls.js",
114
+ "spec/rails3/app_root/public/javascripts/dragdrop.js",
115
+ "spec/rails3/app_root/public/javascripts/effects.js",
116
+ "spec/rails3/app_root/public/javascripts/prototype.js",
117
+ "spec/rails3/app_root/public/javascripts/rails.js",
118
+ "spec/rails3/app_root/public/robots.txt",
119
+ "spec/rails3/app_root/public/stylesheets/.gitkeep",
120
+ "spec/rails3/app_root/script/rails",
121
+ "spec/rails3/app_root/spec/controller_activity_logging_spec.rb",
122
+ "spec/rails3/app_root/spec/controller_brute_force_protection_spec.rb",
123
+ "spec/rails3/app_root/spec/controller_http_basic_auth_spec.rb",
124
+ "spec/rails3/app_root/spec/controller_oauth2_spec.rb",
125
+ "spec/rails3/app_root/spec/controller_oauth_spec.rb",
126
+ "spec/rails3/app_root/spec/controller_remember_me_spec.rb",
127
+ "spec/rails3/app_root/spec/controller_session_timeout_spec.rb",
128
+ "spec/rails3/app_root/spec/controller_spec.rb",
129
+ "spec/rails3/app_root/spec/spec_helper.orig.rb",
130
+ "spec/rails3/app_root/spec/spec_helper.rb",
131
+ "spec/rails3/app_root/spec/user_activation_spec.rb",
132
+ "spec/rails3/app_root/spec/user_activity_logging_spec.rb",
133
+ "spec/rails3/app_root/spec/user_brute_force_protection_spec.rb",
134
+ "spec/rails3/app_root/spec/user_oauth_spec.rb",
135
+ "spec/rails3/app_root/spec/user_remember_me_spec.rb",
136
+ "spec/rails3/app_root/spec/user_reset_password_spec.rb",
137
+ "spec/rails3/app_root/spec/user_spec.rb",
138
+ "spec/rails3/app_root/vendor/plugins/.gitkeep",
139
+ "spec/sorcery_crypto_providers_spec.rb",
140
+ "spec/spec_helper.rb"
141
+ ]
142
+ s.homepage = %q{http://github.com/NoamB/sorcery}
143
+ s.licenses = ["MIT"]
144
+ s.require_paths = ["lib"]
145
+ s.rubygems_version = %q{1.6.2}
146
+ s.summary = %q{Magical authentication for Rails 3 applications}
147
+ s.test_files = [
148
+ "spec/rails3/app_root/app/controllers/application_controller.rb",
149
+ "spec/rails3/app_root/app/helpers/application_helper.rb",
150
+ "spec/rails3/app_root/app/mailers/sorcery_mailer.rb",
151
+ "spec/rails3/app_root/app/models/authentication.rb",
152
+ "spec/rails3/app_root/app/models/user.rb",
153
+ "spec/rails3/app_root/config/application.rb",
154
+ "spec/rails3/app_root/config/boot.rb",
155
+ "spec/rails3/app_root/config/environment.rb",
156
+ "spec/rails3/app_root/config/environments/development.rb",
157
+ "spec/rails3/app_root/config/environments/in_memory.rb",
158
+ "spec/rails3/app_root/config/environments/production.rb",
159
+ "spec/rails3/app_root/config/environments/test.rb",
160
+ "spec/rails3/app_root/config/initializers/backtrace_silencers.rb",
161
+ "spec/rails3/app_root/config/initializers/inflections.rb",
162
+ "spec/rails3/app_root/config/initializers/mime_types.rb",
163
+ "spec/rails3/app_root/config/initializers/secret_token.rb",
164
+ "spec/rails3/app_root/config/initializers/session_store.rb",
165
+ "spec/rails3/app_root/config/routes.rb",
166
+ "spec/rails3/app_root/db/migrate/activation/20101224223622_add_activation_to_users.rb",
167
+ "spec/rails3/app_root/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
168
+ "spec/rails3/app_root/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb",
169
+ "spec/rails3/app_root/db/migrate/core/20101224223620_create_users.rb",
170
+ "spec/rails3/app_root/db/migrate/oauth/20101224223628_create_authentications.rb",
171
+ "spec/rails3/app_root/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb",
172
+ "spec/rails3/app_root/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb",
173
+ "spec/rails3/app_root/db/schema.rb",
174
+ "spec/rails3/app_root/db/seeds.rb",
175
+ "spec/rails3/app_root/spec/controller_activity_logging_spec.rb",
176
+ "spec/rails3/app_root/spec/controller_brute_force_protection_spec.rb",
177
+ "spec/rails3/app_root/spec/controller_http_basic_auth_spec.rb",
178
+ "spec/rails3/app_root/spec/controller_oauth2_spec.rb",
179
+ "spec/rails3/app_root/spec/controller_oauth_spec.rb",
180
+ "spec/rails3/app_root/spec/controller_remember_me_spec.rb",
181
+ "spec/rails3/app_root/spec/controller_session_timeout_spec.rb",
182
+ "spec/rails3/app_root/spec/controller_spec.rb",
183
+ "spec/rails3/app_root/spec/spec_helper.orig.rb",
184
+ "spec/rails3/app_root/spec/spec_helper.rb",
185
+ "spec/rails3/app_root/spec/user_activation_spec.rb",
186
+ "spec/rails3/app_root/spec/user_activity_logging_spec.rb",
187
+ "spec/rails3/app_root/spec/user_brute_force_protection_spec.rb",
188
+ "spec/rails3/app_root/spec/user_oauth_spec.rb",
189
+ "spec/rails3/app_root/spec/user_remember_me_spec.rb",
190
+ "spec/rails3/app_root/spec/user_reset_password_spec.rb",
191
+ "spec/rails3/app_root/spec/user_spec.rb",
192
+ "spec/sorcery_crypto_providers_spec.rb",
193
+ "spec/spec_helper.rb"
194
+ ]
195
+
196
+ if s.respond_to? :specification_version then
197
+ s.specification_version = 3
198
+
199
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
200
+ s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
201
+ s.add_runtime_dependency(%q<json>, [">= 1.5.1"])
202
+ s.add_runtime_dependency(%q<oauth>, [">= 0.4.4"])
203
+ s.add_runtime_dependency(%q<oauth2>, [">= 0.1.1"])
204
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
205
+ s.add_development_dependency(%q<rspec-rails>, [">= 0"])
206
+ s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
207
+ s.add_development_dependency(%q<sqlite3-ruby>, [">= 0"])
208
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
209
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
210
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
211
+ s.add_development_dependency(%q<simplecov>, [">= 0.3.8"])
212
+ s.add_runtime_dependency(%q<bcrypt-ruby>, ["~> 2.1.4"])
213
+ s.add_runtime_dependency(%q<oauth>, [">= 0.4.4"])
214
+ s.add_runtime_dependency(%q<oauth2>, [">= 0.1.1"])
215
+ else
216
+ s.add_dependency(%q<rails>, [">= 3.0.0"])
217
+ s.add_dependency(%q<json>, [">= 1.5.1"])
218
+ s.add_dependency(%q<oauth>, [">= 0.4.4"])
219
+ s.add_dependency(%q<oauth2>, [">= 0.1.1"])
220
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
221
+ s.add_dependency(%q<rspec-rails>, [">= 0"])
222
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
223
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
224
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
225
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
226
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
227
+ s.add_dependency(%q<simplecov>, [">= 0.3.8"])
228
+ s.add_dependency(%q<bcrypt-ruby>, ["~> 2.1.4"])
229
+ s.add_dependency(%q<oauth>, [">= 0.4.4"])
230
+ s.add_dependency(%q<oauth2>, [">= 0.1.1"])
231
+ end
232
+ else
233
+ s.add_dependency(%q<rails>, [">= 3.0.0"])
234
+ s.add_dependency(%q<json>, [">= 1.5.1"])
235
+ s.add_dependency(%q<oauth>, [">= 0.4.4"])
236
+ s.add_dependency(%q<oauth2>, [">= 0.1.1"])
237
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
238
+ s.add_dependency(%q<rspec-rails>, [">= 0"])
239
+ s.add_dependency(%q<ruby-debug19>, [">= 0"])
240
+ s.add_dependency(%q<sqlite3-ruby>, [">= 0"])
241
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
242
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
243
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
244
+ s.add_dependency(%q<simplecov>, [">= 0.3.8"])
245
+ s.add_dependency(%q<bcrypt-ruby>, ["~> 2.1.4"])
246
+ s.add_dependency(%q<oauth>, [">= 0.4.4"])
247
+ s.add_dependency(%q<oauth2>, [">= 0.1.1"])
248
+ end
249
+ end
250
+
data/spec/Gemfile CHANGED
@@ -2,8 +2,9 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem "rails", '3.0.3'
4
4
  gem 'bcrypt-ruby', :require => 'bcrypt'
5
- gem "sorcery", '0.1.0', :path => '../../../'
6
-
5
+ gem "sorcery", '0.1.4', :path => '../../../'
6
+ gem 'oauth', ">= 0.4.4"
7
+ gem 'oauth2', ">= 0.1.1"
7
8
  group :development do
8
9
  gem 'rspec'
9
10
  gem 'ruby-debug19'
data/spec/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../../
3
3
  specs:
4
- sorcery (0.1.0)
4
+ sorcery (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -33,6 +33,7 @@ GEM
33
33
  activemodel (= 3.0.3)
34
34
  activesupport (= 3.0.3)
35
35
  activesupport (3.0.3)
36
+ addressable (2.2.4)
36
37
  archive-tar-minitar (0.5.2)
37
38
  arel (2.0.6)
38
39
  bcrypt-ruby (2.1.3)
@@ -41,6 +42,10 @@ GEM
41
42
  diff-lcs (1.1.2)
42
43
  erubis (2.6.6)
43
44
  abstract (>= 1.0.0)
45
+ faraday (0.5.5)
46
+ addressable (~> 2.2.4)
47
+ multipart-post (~> 1.1.0)
48
+ rack (< 2, >= 1.1.0)
44
49
  i18n (0.5.0)
45
50
  linecache19 (0.5.11)
46
51
  ruby_core_source (>= 0.1.4)
@@ -50,6 +55,12 @@ GEM
50
55
  mime-types (~> 1.16)
51
56
  treetop (~> 1.4.8)
52
57
  mime-types (1.16)
58
+ multi_json (0.0.5)
59
+ multipart-post (1.1.0)
60
+ oauth (0.4.4)
61
+ oauth2 (0.1.1)
62
+ faraday (~> 0.5.0)
63
+ multi_json (~> 0.0.4)
53
64
  polyglot (0.3.1)
54
65
  rack (1.2.1)
55
66
  rack-mount (0.6.13)
@@ -101,8 +112,10 @@ PLATFORMS
101
112
 
102
113
  DEPENDENCIES
103
114
  bcrypt-ruby
115
+ oauth (>= 0.4.4)
116
+ oauth2 (>= 0.1.1)
104
117
  rails (= 3.0.3)
105
118
  rspec
106
119
  ruby-debug19
107
120
  simplecov (>= 0.3.8)
108
- sorcery (= 0.1.0)!
121
+ sorcery (= 0.1.4)!
@@ -0,0 +1 @@
1
+ --colour
@@ -2,11 +2,14 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'rails', '3.0.3'
4
4
  gem 'sqlite3-ruby', :require => 'sqlite3'
5
- gem "sorcery", '0.1.0', :path => '../../../'
6
-
7
- group :development do
5
+ gem "sorcery", '0.1.4', :path => '../../../'
6
+ gem 'bcrypt-ruby', '~> 2.1.4', :require => 'bcrypt'
7
+ gem 'oauth', ">= 0.4.4"
8
+ gem 'oauth2', ">= 0.1.1"
9
+ group :development, :test do
8
10
  gem 'rspec'
9
11
  gem 'rspec-rails'
10
12
  gem 'ruby-debug19'
11
13
  gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
14
+ gem 'spork', '~> 0.9.0.rc'
12
15
  end
@@ -1,7 +1,14 @@
1
1
  PATH
2
2
  remote: ../../../
3
3
  specs:
4
- sorcery (0.1.0)
4
+ sorcery (0.1.4)
5
+ bcrypt-ruby (~> 2.1.4)
6
+ json (>= 1.5.1)
7
+ oauth (>= 0.4.4)
8
+ oauth (>= 0.4.4)
9
+ oauth2 (>= 0.1.1)
10
+ oauth2 (>= 0.1.1)
11
+ rails (>= 3.0.0)
5
12
 
6
13
  GEM
7
14
  remote: http://rubygems.org/
@@ -33,14 +40,21 @@ GEM
33
40
  activemodel (= 3.0.3)
34
41
  activesupport (= 3.0.3)
35
42
  activesupport (3.0.3)
43
+ addressable (2.2.4)
36
44
  archive-tar-minitar (0.5.2)
37
45
  arel (2.0.6)
46
+ bcrypt-ruby (2.1.4)
38
47
  builder (2.1.2)
39
48
  columnize (0.3.2)
40
49
  diff-lcs (1.1.2)
41
50
  erubis (2.6.6)
42
51
  abstract (>= 1.0.0)
52
+ faraday (0.5.5)
53
+ addressable (~> 2.2.4)
54
+ multipart-post (~> 1.1.0)
55
+ rack (< 2, >= 1.1.0)
43
56
  i18n (0.5.0)
57
+ json (1.5.1)
44
58
  linecache19 (0.5.11)
45
59
  ruby_core_source (>= 0.1.4)
46
60
  mail (2.2.13)
@@ -49,6 +63,12 @@ GEM
49
63
  mime-types (~> 1.16)
50
64
  treetop (~> 1.4.8)
51
65
  mime-types (1.16)
66
+ multi_json (0.0.5)
67
+ multipart-post (1.1.0)
68
+ oauth (0.4.4)
69
+ oauth2 (0.1.1)
70
+ faraday (~> 0.5.0)
71
+ multi_json (~> 0.0.4)
52
72
  polyglot (0.3.1)
53
73
  rack (1.2.1)
54
74
  rack-mount (0.6.13)
@@ -95,6 +115,7 @@ GEM
95
115
  simplecov (0.3.9)
96
116
  simplecov-html (>= 0.3.7)
97
117
  simplecov-html (0.3.9)
118
+ spork (0.9.0.rc3)
98
119
  sqlite3-ruby (1.3.2)
99
120
  thor (0.14.6)
100
121
  treetop (1.4.9)
@@ -105,10 +126,14 @@ PLATFORMS
105
126
  ruby
106
127
 
107
128
  DEPENDENCIES
129
+ bcrypt-ruby (~> 2.1.4)
130
+ oauth (>= 0.4.4)
131
+ oauth2 (>= 0.1.1)
108
132
  rails (= 3.0.3)
109
133
  rspec
110
134
  rspec-rails
111
135
  ruby-debug19
112
136
  simplecov (>= 0.3.8)
113
- sorcery (= 0.1.0)!
137
+ sorcery (= 0.1.4)!
138
+ spork (~> 0.9.0.rc)
114
139
  sqlite3-ruby
@@ -1,8 +1,11 @@
1
+ require 'oauth'
2
+
1
3
  class ApplicationController < ActionController::Base
2
4
  protect_from_forgery
3
5
 
4
6
  #before_filter :validate_session, :only => [:test_should_be_logged_in] if defined?(:validate_session)
5
- before_filter :require_user_login, :only => [:test_logout, :test_should_be_logged_in, :some_action]
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]
6
9
 
7
10
  def index
8
11
  render :text => ""
@@ -17,6 +20,11 @@ class ApplicationController < ActionController::Base
17
20
  render :text => ""
18
21
  end
19
22
 
23
+ def test_return_to
24
+ @user = login(params[:username], params[:password])
25
+ return_or_redirect_to(:index, :notice => 'haha!')
26
+ end
27
+
20
28
  def test_logout
21
29
  logout
22
30
  render :text => ""
@@ -42,7 +50,7 @@ class ApplicationController < ActionController::Base
42
50
  end
43
51
 
44
52
  def test_login_from_cookie
45
- @user = logged_in_user
53
+ @user = current_user
46
54
  render :text => ""
47
55
  end
48
56
 
@@ -54,6 +62,44 @@ class ApplicationController < ActionController::Base
54
62
  render :text => ""
55
63
  end
56
64
 
65
+ def test_http_basic_auth
66
+ render :text => "HTTP Basic Auth"
67
+ end
68
+
69
+ def auth_at_provider_test
70
+ auth_at_provider(:twitter)
71
+ end
72
+
73
+ def auth_at_provider_test2
74
+ auth_at_provider(:facebook)
75
+ end
76
+
77
+ def test_login_from_access_token
78
+ if @user = login_from_access_token(:twitter)
79
+ redirect_to "bla", :notice => "Success!"
80
+ else
81
+ redirect_to "blu", :alert => "Failed!"
82
+ end
83
+ end
84
+
85
+ def test_login_from_access_token2
86
+ if @user = login_from_access_token(:facebook)
87
+ redirect_to "bla", :notice => "Success!"
88
+ else
89
+ redirect_to "blu", :alert => "Failed!"
90
+ end
91
+ end
92
+
93
+ def test_create_from_provider
94
+ provider = params[:provider]
95
+ login_from_access_token(provider)
96
+ if @user = create_from_provider!(provider)
97
+ redirect_to "bla", :notice => "Success!"
98
+ else
99
+ redirect_to "blu", :alert => "Failed!"
100
+ end
101
+ end
102
+
57
103
  protected
58
104
 
59
105
 
@@ -0,0 +1,3 @@
1
+ class Authentication < ActiveRecord::Base
2
+ belongs_to :user
3
+ end
@@ -1,3 +1,6 @@
1
1
  class User < ActiveRecord::Base
2
- #activate_sorcery!
2
+ attr_accessible :email, :password, :password_confirmation, :authentications_attributes
3
+
4
+ has_many :authentications, :dependent => :destroy
5
+ accepts_nested_attributes_for :authentications
3
6
  end
@@ -38,9 +38,7 @@ module AppRoot
38
38
 
39
39
  # Configure sensitive parameters which will be filtered from the log file.
40
40
  config.filter_parameters += [:password]
41
-
42
- config.root = File.expand_path('../..', __FILE__)
43
-
41
+
44
42
  config.action_mailer.delivery_method = :test
45
43
 
46
44
  config.active_support.deprecation = :stderr
@@ -1,13 +1,5 @@
1
1
  AppRoot::Application.routes.draw do
2
2
  root :to => "application#index"
3
- match '/test_login', :to => "application#test_login"
4
- match '/test_logout', :to => "application#test_logout"
5
- match '/some_action', :to => "application#some_action"
6
- match '/test_logout_with_remember', :to => "application#test_logout_with_remember"
7
- match '/test_login_with_remember', :to => 'application#test_login_with_remember'
8
- match '/test_login_with_remember_in_login', :to => 'application#test_login_with_remember_in_login'
9
- match '/test_login_from_cookie', :to => 'application#test_login_from_cookie'
10
- match '/test_should_be_logged_in', :to => 'application#test_should_be_logged_in'
11
3
  # The priority is based upon order of creation:
12
4
  # first created -> highest priority.
13
5
 
@@ -63,5 +55,5 @@ AppRoot::Application.routes.draw do
63
55
 
64
56
  # This is a legacy wild controller route that's not recommended for RESTful applications.
65
57
  # Note: This route will make all actions in every controller accessible via GET requests.
66
- # match ':controller(/:action(/:id(.:format)))'
58
+ match ':controller(/:action(/:id(.:format)))'
67
59
  end
@@ -1,15 +1,17 @@
1
1
  class AddActivationToUsers < ActiveRecord::Migration
2
2
  def self.up
3
3
  add_column :users, :activation_state, :string, :default => nil
4
- add_column :users, :activation_code, :string, :default => nil
4
+ add_column :users, :activation_token, :string, :default => nil
5
+ add_column :users, :activation_token_expires_at, :datetime, :default => nil
5
6
 
6
- add_index :users, :activation_code
7
+ add_index :users, :activation_token
7
8
  end
8
9
 
9
10
  def self.down
10
- remove_index :users, :activation_code
11
+ remove_index :users, :activation_token
11
12
 
12
- remove_column :users, :activation_code
13
+ remove_column :users, :activation_token_expires_at
14
+ remove_column :users, :activation_token
13
15
  remove_column :users, :activation_state
14
16
  end
15
17
  end
@@ -0,0 +1,17 @@
1
+ class AddActivityLoggingToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :users, :last_login_at, :datetime, :default => nil
4
+ add_column :users, :last_logout_at, :datetime, :default => nil
5
+ add_column :users, :last_activity_at, :datetime, :default => nil
6
+
7
+ add_index :users, [:last_logout_at, :last_activity_at]
8
+ end
9
+
10
+ def self.down
11
+ remove_index :users, [:last_logout_at, :last_activity_at]
12
+
13
+ remove_column :users, :last_activity_at
14
+ remove_column :users, :last_logout_at
15
+ remove_column :users, :last_login_at
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ class AddBruteForceProtectionToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :users, :failed_logins_count, :integer, :default => 0
4
+ add_column :users, :lock_expires_at, :datetime, :default => nil
5
+ end
6
+
7
+ def self.down
8
+ remove_column :users, :lock_expires_at
9
+ remove_column :users, :failed_logins_count
10
+ end
11
+ end
@@ -1,10 +1,10 @@
1
1
  class CreateUsers < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :users do |t|
4
- t.string :username
5
- t.string :email, :null => false
6
- t.string :crypted_password
7
- t.string :salt
4
+ t.string :username, :null => false
5
+ t.string :email, :default => nil
6
+ t.string :crypted_password, :default => nil
7
+ t.string :salt, :default => nil
8
8
 
9
9
  t.timestamps
10
10
  end
@@ -0,0 +1,14 @@
1
+ class CreateAuthentications < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :authentications do |t|
4
+ t.integer :user_id, :null => false
5
+ t.string :provider, :uid, :null => false
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :authentications
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ class AddResetPasswordToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :users, :reset_password_token, :string, :default => nil
4
+ add_column :users, :reset_password_token_expires_at, :datetime, :default => nil
5
+ add_column :users, :reset_password_email_sent_at, :datetime, :default => nil
6
+ end
7
+
8
+ def self.down
9
+ remove_column :users, :reset_password_email_sent_at
10
+ remove_column :users, :reset_password_token_expires_at
11
+ remove_column :users, :reset_password_token
12
+ end
13
+ end