graffititracker_devise 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/CHANGELOG.rdoc +410 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +272 -0
  4. data/Rakefile +53 -0
  5. data/TODO +2 -0
  6. data/app/controllers/confirmations_controller.rb +33 -0
  7. data/app/controllers/passwords_controller.rb +41 -0
  8. data/app/controllers/registrations_controller.rb +53 -0
  9. data/app/controllers/sessions_controller.rb +42 -0
  10. data/app/controllers/unlocks_controller.rb +41 -0
  11. data/app/models/devise_mailer.rb +68 -0
  12. data/app/views/confirmations/new.html.erb +12 -0
  13. data/app/views/devise_mailer/confirmation_instructions.html.erb +5 -0
  14. data/app/views/devise_mailer/reset_password_instructions.html.erb +8 -0
  15. data/app/views/devise_mailer/unlock_instructions.html.erb +7 -0
  16. data/app/views/passwords/edit.html.erb +16 -0
  17. data/app/views/passwords/new.html.erb +12 -0
  18. data/app/views/registrations/edit.html.erb +25 -0
  19. data/app/views/registrations/new.html.erb +17 -0
  20. data/app/views/sessions/new.html.erb +17 -0
  21. data/app/views/shared/_devise_links.erb +19 -0
  22. data/app/views/unlocks/new.html.erb +12 -0
  23. data/generators/devise/USAGE +5 -0
  24. data/generators/devise/devise_generator.rb +15 -0
  25. data/generators/devise/lib/route_devise.rb +32 -0
  26. data/generators/devise/templates/migration.rb +23 -0
  27. data/generators/devise/templates/model.rb +9 -0
  28. data/generators/devise_install/USAGE +3 -0
  29. data/generators/devise_install/devise_install_generator.rb +15 -0
  30. data/generators/devise_install/templates/README +23 -0
  31. data/generators/devise_install/templates/devise.rb +105 -0
  32. data/generators/devise_views/USAGE +3 -0
  33. data/generators/devise_views/devise_views_generator.rb +21 -0
  34. data/lib/devise.rb +277 -0
  35. data/lib/devise/controllers/helpers.rb +226 -0
  36. data/lib/devise/controllers/internal_helpers.rb +129 -0
  37. data/lib/devise/controllers/url_helpers.rb +41 -0
  38. data/lib/devise/encryptors/authlogic_sha512.rb +21 -0
  39. data/lib/devise/encryptors/base.rb +20 -0
  40. data/lib/devise/encryptors/bcrypt.rb +21 -0
  41. data/lib/devise/encryptors/clearance_sha1.rb +19 -0
  42. data/lib/devise/encryptors/restful_authentication_sha1.rb +22 -0
  43. data/lib/devise/encryptors/sha1.rb +27 -0
  44. data/lib/devise/encryptors/sha512.rb +27 -0
  45. data/lib/devise/failure_app.rb +72 -0
  46. data/lib/devise/hooks/activatable.rb +15 -0
  47. data/lib/devise/hooks/rememberable.rb +33 -0
  48. data/lib/devise/hooks/timeoutable.rb +18 -0
  49. data/lib/devise/hooks/trackable.rb +18 -0
  50. data/lib/devise/locales/en.yml +35 -0
  51. data/lib/devise/mapping.rb +130 -0
  52. data/lib/devise/models.rb +117 -0
  53. data/lib/devise/models/activatable.rb +16 -0
  54. data/lib/devise/models/confirmable.rb +167 -0
  55. data/lib/devise/models/database_authenticatable.rb +144 -0
  56. data/lib/devise/models/http_authenticatable.rb +23 -0
  57. data/lib/devise/models/lockable.rb +150 -0
  58. data/lib/devise/models/recoverable.rb +80 -0
  59. data/lib/devise/models/registerable.rb +8 -0
  60. data/lib/devise/models/rememberable.rb +92 -0
  61. data/lib/devise/models/timeoutable.rb +28 -0
  62. data/lib/devise/models/token_authenticatable.rb +89 -0
  63. data/lib/devise/models/trackable.rb +16 -0
  64. data/lib/devise/models/validatable.rb +39 -0
  65. data/lib/devise/orm/active_record.rb +41 -0
  66. data/lib/devise/orm/data_mapper.rb +83 -0
  67. data/lib/devise/orm/mongo_mapper.rb +52 -0
  68. data/lib/devise/rails.rb +14 -0
  69. data/lib/devise/rails/routes.rb +133 -0
  70. data/lib/devise/rails/warden_compat.rb +63 -0
  71. data/lib/devise/schema.rb +73 -0
  72. data/lib/devise/strategies/base.rb +16 -0
  73. data/lib/devise/strategies/database_authenticatable.rb +36 -0
  74. data/lib/devise/strategies/http_authenticatable.rb +59 -0
  75. data/lib/devise/strategies/rememberable.rb +37 -0
  76. data/lib/devise/strategies/token_authenticatable.rb +37 -0
  77. data/lib/devise/test_helpers.rb +90 -0
  78. data/lib/devise/version.rb +3 -0
  79. data/rails/init.rb +2 -0
  80. data/test/controllers/helpers_test.rb +184 -0
  81. data/test/controllers/internal_helpers_test.rb +55 -0
  82. data/test/controllers/url_helpers_test.rb +47 -0
  83. data/test/devise_test.rb +74 -0
  84. data/test/encryptors_test.rb +31 -0
  85. data/test/failure_app_test.rb +44 -0
  86. data/test/integration/authenticatable_test.rb +340 -0
  87. data/test/integration/confirmable_test.rb +97 -0
  88. data/test/integration/http_authenticatable_test.rb +52 -0
  89. data/test/integration/lockable_test.rb +102 -0
  90. data/test/integration/rack_middleware_test.rb +47 -0
  91. data/test/integration/recoverable_test.rb +141 -0
  92. data/test/integration/registerable_test.rb +144 -0
  93. data/test/integration/rememberable_test.rb +82 -0
  94. data/test/integration/timeoutable_test.rb +68 -0
  95. data/test/integration/token_authenticatable_test.rb +55 -0
  96. data/test/integration/trackable_test.rb +64 -0
  97. data/test/mailers/confirmation_instructions_test.rb +86 -0
  98. data/test/mailers/reset_password_instructions_test.rb +68 -0
  99. data/test/mailers/unlock_instructions_test.rb +62 -0
  100. data/test/mapping_test.rb +158 -0
  101. data/test/models/authenticatable_test.rb +180 -0
  102. data/test/models/confirmable_test.rb +228 -0
  103. data/test/models/lockable_test.rb +202 -0
  104. data/test/models/recoverable_test.rb +138 -0
  105. data/test/models/rememberable_test.rb +135 -0
  106. data/test/models/timeoutable_test.rb +28 -0
  107. data/test/models/token_authenticatable_test.rb +51 -0
  108. data/test/models/trackable_test.rb +5 -0
  109. data/test/models/validatable_test.rb +106 -0
  110. data/test/models_test.rb +70 -0
  111. data/test/orm/active_record.rb +31 -0
  112. data/test/orm/mongo_mapper.rb +20 -0
  113. data/test/rails_app/app/active_record/admin.rb +7 -0
  114. data/test/rails_app/app/active_record/user.rb +7 -0
  115. data/test/rails_app/app/controllers/admins_controller.rb +6 -0
  116. data/test/rails_app/app/controllers/application_controller.rb +12 -0
  117. data/test/rails_app/app/controllers/home_controller.rb +4 -0
  118. data/test/rails_app/app/controllers/users_controller.rb +16 -0
  119. data/test/rails_app/app/helpers/application_helper.rb +3 -0
  120. data/test/rails_app/app/mongo_mapper/admin.rb +13 -0
  121. data/test/rails_app/app/mongo_mapper/user.rb +14 -0
  122. data/test/rails_app/config/boot.rb +110 -0
  123. data/test/rails_app/config/environment.rb +42 -0
  124. data/test/rails_app/config/environments/development.rb +17 -0
  125. data/test/rails_app/config/environments/production.rb +28 -0
  126. data/test/rails_app/config/environments/test.rb +28 -0
  127. data/test/rails_app/config/initializers/devise.rb +82 -0
  128. data/test/rails_app/config/initializers/inflections.rb +2 -0
  129. data/test/rails_app/config/initializers/new_rails_defaults.rb +24 -0
  130. data/test/rails_app/config/initializers/session_store.rb +15 -0
  131. data/test/rails_app/config/routes.rb +25 -0
  132. data/test/routes_test.rb +131 -0
  133. data/test/support/assertions_helper.rb +37 -0
  134. data/test/support/integration_tests_helper.rb +71 -0
  135. data/test/support/test_silencer.rb +5 -0
  136. data/test/support/tests_helper.rb +39 -0
  137. data/test/test_helper.rb +21 -0
  138. data/test/test_helpers_test.rb +57 -0
  139. metadata +279 -0
@@ -0,0 +1,410 @@
1
+ == 1.0.11
2
+
3
+ * bug fix
4
+ * Make sure xhr requests do not store urls for redirect
5
+ * Squeeze break lines from cookies to avoid duplicated break lines
6
+
7
+ == 1.0.10
8
+
9
+ * bug fix
10
+ * Use secure compare when comparing passwords
11
+ * Improve email regexp
12
+ * Implement handle_unverified_request for Rails 2.3.11
13
+
14
+ == 1.0.9
15
+
16
+ * enhancements
17
+ * Extracted redirect path from Devise failure app to a new method, allowing override in custom failure apps
18
+ * Added sign_out_via
19
+
20
+ * bug fix
21
+ * Email is now case insensitive
22
+ * Avoid session fixation attacks
23
+
24
+ == 1.0.8
25
+
26
+ * enhancements
27
+ * Support for latest MongoMapper
28
+ * Added anybody_signed_in? helper (by github.com/SSDany)
29
+
30
+ * bug fix
31
+ * confirmation_required? is properly honored on active? calls. (by github.com/paulrosania)
32
+
33
+ == 1.0.7
34
+
35
+ * bug fix
36
+ * Ensure password confirmation is always required
37
+
38
+ * deprecations
39
+ * authenticatable was deprecated and renamed to database_authenticatable
40
+ * confirmable is not included by default on generation
41
+
42
+ == 1.0.6
43
+
44
+ * bug fix
45
+ * Do not allow unlockable strategies based on time to access a controller.
46
+ * Do not send unlockable email several times.
47
+ * Allow controller to upstram custom! failures to Warden.
48
+
49
+ == 1.0.5
50
+
51
+ * bug fix
52
+ * Use prepend_before_filter in require_no_authentication.
53
+ * require_no_authentication on unlockable.
54
+ * Fix a bug when giving an association proxy to devise.
55
+ * Do not use lock! on lockable since it's part of ActiveRecord API.
56
+
57
+ == 1.0.4
58
+
59
+ * bug fix
60
+ * Fixed a bug when deleting an account with rememberable
61
+ * Fixed a bug with custom controllers
62
+
63
+ == 1.0.3
64
+
65
+ * enhancements
66
+ * HTML e-mails now have proper formatting
67
+ * Do not remove MongoMapper options in find
68
+
69
+ == 1.0.2
70
+
71
+ * enhancements
72
+ * Allows you set mailer content type (by github.com/glennr)
73
+
74
+ * bug fix
75
+ * Uses the same content type as request on http authenticatable 401 responses
76
+
77
+ == 1.0.1
78
+
79
+ * enhancements
80
+ * HttpAuthenticatable is not added by default automatically.
81
+ * Avoid mass assignment error messages with current password.
82
+
83
+ * bug fix
84
+ * Fixed encryptors autoload
85
+
86
+ == 1.0.0
87
+
88
+ * deprecation
89
+ * :old_password in update_with_password is deprecated, use :current_password instead
90
+
91
+ * enhancements
92
+ * Added Registerable
93
+ * Added Http Basic Authentication support
94
+ * Allow scoped_views to be customized per controller/mailer class
95
+ * [#99] Allow authenticatable to used in change_table statements
96
+ * Add mailer_content_type configuration parameter (by github.com/glennr)
97
+
98
+ == 0.9.2
99
+
100
+ * bug fix
101
+ * Ensure inactive user cannot sign in
102
+ * Ensure redirect to proper url after sign up
103
+
104
+ * enhancements
105
+ * Added gemspec to repo
106
+ * Added token authenticatable (by github.com/grimen)
107
+
108
+ == 0.9.1
109
+
110
+ * bug fix
111
+ * Allow bigger salt size (by github.com/jgeiger)
112
+ * Fix relative url root
113
+
114
+ == 0.9.0
115
+
116
+ * deprecation
117
+ * devise :all is deprecated
118
+ * :success and :failure flash messages are now :notice and :alert
119
+
120
+ * enhancements
121
+ * Added devise lockable (by github.com/mhfs)
122
+ * Warden 0.9.0 compatibility
123
+ * Mongomapper 0.6.10 compatibility
124
+ * Added Devise.add_module as hooks for extensions (by github.com/grimen)
125
+ * Ruby 1.9.1 compatibility (by github.com/grimen)
126
+
127
+ * bug fix
128
+ * Accept path prefix not starting with slash
129
+ * url helpers should rely on find_scope!
130
+
131
+ == 0.8.2
132
+
133
+ * enhancements
134
+ * Allow Devise.mailer_sender to be a proc (by github.com/grimen)
135
+
136
+ * bug fix
137
+ * Fix bug with passenger, update is required to anyone deploying on passenger (by github.com/dvdpalm)
138
+
139
+ == 0.8.1
140
+
141
+ * enhancements
142
+ * Move salt to encryptors
143
+ * Devise::Lockable
144
+ * Moved view links into partial and I18n'ed them
145
+
146
+ * bug fix
147
+ * Bcrypt generator was not being loaded neither setting the proper salt
148
+
149
+ == 0.8.0
150
+
151
+ * enhancements
152
+ * Warden 0.8.0 compatibility
153
+ * Add an easy for map.connect "sign_in", :controller => "sessions", :action => "new" to work
154
+ * Added :bcrypt encryptor (by github.com/capotej)
155
+
156
+ * bug fix
157
+ * sign_in_count is also increased when user signs in via password change, confirmation, etc..
158
+ * More DataMapper compatibility (by github.com/lancecarlson)
159
+
160
+ * deprecation
161
+ * Removed DeviseMailer.sender
162
+
163
+ == 0.7.5
164
+
165
+ * enhancements
166
+ * Set a default value for mailer to avoid find_template issues
167
+ * Add models configuration to MongoMapper::EmbeddedDocument as well
168
+
169
+ == 0.7.4
170
+
171
+ * enhancements
172
+ * Extract Activatable from Confirmable
173
+ * Decouple Serializers from Devise modules
174
+
175
+ == 0.7.3
176
+
177
+ * bug fix
178
+ * Give scope to the proper model validation
179
+
180
+ * enhancements
181
+ * Mail views are scoped as well
182
+ * Added update_with_password for authenticatable
183
+ * Allow render_with_scope to accept :controller option
184
+
185
+ == 0.7.2
186
+
187
+ * deprecation
188
+ * Renamed reset_confirmation! to resend_confirmation!
189
+ * Copying locale is part of the installation process
190
+
191
+ * bug fix
192
+ * Fixed render_with_scope to work with all controllers
193
+ * Allow sign in with two different users in Devise::TestHelpers
194
+
195
+ == 0.7.1
196
+
197
+ * enhancements
198
+ * Small enhancements for other plugins compatibility (by github.com/grimen)
199
+
200
+ == 0.7.0
201
+
202
+ * deprecations
203
+ * :authenticatable is not included by default anymore
204
+
205
+ * enhancements
206
+ * Improve loading process
207
+ * Extract SessionSerializer from Authenticatable
208
+
209
+ == 0.6.3
210
+
211
+ * bug fix
212
+ * Added trackable to migrations
213
+ * Allow inflections to work
214
+
215
+ == 0.6.2
216
+
217
+ * enhancements
218
+ * More DataMapper compatibility
219
+ * Devise::Trackable - track sign in count, timestamps and ips
220
+
221
+ == 0.6.1
222
+
223
+ * enhancements
224
+ * Devise::Timeoutable - timeout sessions without activity
225
+ * DataMapper now accepts conditions
226
+
227
+ == 0.6.0
228
+
229
+ * deprecations
230
+ * :authenticatable is still included by default, but yields a deprecation warning
231
+
232
+ * enhancements
233
+ * Added DataMapper support
234
+ * Remove store_location from authenticatable strategy and add it to failure app
235
+ * Allow a strategy to be placed after authenticatable
236
+ * [#45] Do not rely attribute? methods, since they are not added on Datamapper
237
+
238
+ == 0.5.6
239
+
240
+ * enhancements
241
+ * [#42] Do not send nil to build (DataMapper compatibility)
242
+ * [#44] Allow to have scoped views
243
+
244
+ == 0.5.5
245
+
246
+ * enhancements
247
+ * Allow overwriting find for authentication method
248
+ * [#38] Remove Ruby 1.8.7 dependency
249
+
250
+ == 0.5.4
251
+
252
+ * deprecations
253
+ * Deprecate :singular in devise_for and use :scope instead
254
+
255
+ * enhancements
256
+ * [#37] Create after_sign_in_path_for and after_sign_out_path_for hooks to be
257
+ overwriten in ApplicationController
258
+ * Create sign_in_and_redirect and sign_out_and_redirect helpers
259
+ * Warden::Manager.default_scope is automatically configured to the first given scope
260
+
261
+ == 0.5.3
262
+
263
+ * bug fix
264
+ * MongoMapper now converts DateTime to Time
265
+ * Ensure all controllers are unloadable
266
+
267
+ * enhancements
268
+ * [#35] Moved friendly_token to Devise
269
+ * Added Devise.all, so you can freeze your app strategies
270
+ * Added Devise.apply_schema, so you can turn it to false in Datamapper or MongoMapper
271
+ in cases you don't want it be handlded automatically
272
+
273
+ == 0.5.2
274
+
275
+ * enhancements
276
+ * [#28] Improved sign_in and sign_out helpers to accepts resources
277
+ * [#28] Added stored_location_for as a helper
278
+ * [#20] Added test helpers
279
+
280
+ == 0.5.1
281
+
282
+ * enhancements
283
+ * Added serializers based on Warden ones
284
+ * Allow authentication keys to be set
285
+
286
+ == 0.5.0
287
+
288
+ * bug fix
289
+ * Fixed a bug where remember me module was not working properly
290
+
291
+ * enhancements
292
+ * Moved encryption strategy into the Encryptors module to allow several algorithms (by github.com/mhfs)
293
+ * Implemented encryptors for Clearance, Authlogic and Restful-Authentication (by github.com/mhfs)
294
+ * Added support for MongoMapper (by github.com/shingara)
295
+
296
+ == 0.4.3
297
+
298
+ * bug fix
299
+ * [#29] Authentication just fails if user cannot be serialized from session, without raising errors;
300
+ * Default configuration values should not overwrite user values;
301
+
302
+ == 0.4.2
303
+
304
+ * deprecations
305
+ * Renamed mail_sender to mailer_sender
306
+
307
+ * enhancements
308
+ * skip_before_filter added in Devise controllers
309
+ * Use home_or_root_path on require_no_authentication as well
310
+ * Added devise_controller?, useful to select or reject filters in ApplicationController
311
+ * Allow :path_prefix to be given to devise_for
312
+ * Allow default_url_options to be configured through devise (:path_prefix => "/:locale" is now supported)
313
+
314
+ == 0.4.1
315
+
316
+ * bug fix
317
+ * [#21] Ensure options can be set even if models were not loaded
318
+
319
+ == 0.4.0
320
+
321
+ * deprecations
322
+ * Notifier is deprecated, use DeviseMailer instead. Remember to rename
323
+ app/views/notifier to app/views/devise_mailer and I18n key from
324
+ devise.notifier to devise.mailer
325
+ * :authenticable calls are deprecated, use :authenticatable instead
326
+
327
+ * enhancements
328
+ * [#16] Allow devise to be more agnostic and do not require ActiveRecord to be loaded
329
+ * Allow Warden::Manager to be configured through Devise
330
+ * Created a generator which creates an initializer
331
+
332
+ == 0.3.0
333
+
334
+ * bug fix
335
+ * [#15] Allow yml messages to be configured by not using engine locales
336
+
337
+ * deprecations
338
+ * Renamed confirm_in to confirm_within
339
+ * [#14] Do not send confirmation messages when user changes his e-mail
340
+ * [#13] Renamed authenticable to authenticatable and added deprecation warnings
341
+
342
+ == 0.2.3
343
+
344
+ * enhancements
345
+ * Ensure fail! works inside strategies
346
+ * [#12] Make unauthenticated message (when you haven't signed in) different from invalid message
347
+
348
+ * bug fix
349
+ * Do not redirect on invalid authenticate
350
+ * Allow model configuration to be set to nil
351
+
352
+ == 0.2.2
353
+
354
+ * bug fix
355
+ * [#9] Fix a bug when using customized resources
356
+
357
+ == 0.2.1
358
+
359
+ * refactor
360
+ * Clean devise_views generator to use devise existing views
361
+
362
+ * enhancements
363
+ * [#7] Create instance variables (like @user) for each devise controller
364
+ * Use Devise::Controller::Helpers only internally
365
+
366
+ * bug fix
367
+ * [#6] Fix a bug with Mongrel and Ruby 1.8.6
368
+
369
+ == 0.2.0
370
+
371
+ * enhancements
372
+ * [#4] Allow option :null => true in authenticable migration
373
+ * [#3] Remove attr_accessible calls from devise modules
374
+ * Customizable time frame for rememberable with :remember_for config
375
+ * Customizable time frame for confirmable with :confirm_in config
376
+ * Generators for creating a resource and copy views
377
+
378
+ * optimize
379
+ * Do not load hooks or strategies if they are not used
380
+
381
+ * bug fixes
382
+ * [#2] Fixed requiring devise strategies
383
+
384
+ == 0.1.1
385
+
386
+ * bug fixes
387
+ * [#1] Fixed requiring devise mapping
388
+
389
+ == 0.1.0
390
+
391
+ * Devise::Authenticable
392
+ * Devise::Confirmable
393
+ * Devise::Recoverable
394
+ * Devise::Validatable
395
+ * Devise::Migratable
396
+ * Devise::Rememberable
397
+
398
+ * SessionsController
399
+ * PasswordsController
400
+ * ConfirmationsController
401
+
402
+ * Create an example app
403
+ * devise :all, :except => :rememberable
404
+ * Use sign_in and sign_out in SessionsController
405
+
406
+ * Mailer subjects namespaced by model
407
+ * Allow stretches and pepper per model
408
+
409
+ * Store session[:return_to] in session
410
+ * Sign user in automatically after confirming or changing it's password
@@ -0,0 +1,20 @@
1
+ Copyright 2009 Plataforma Tecnologia. http://blog.plataformatec.com.br
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,272 @@
1
+ == Devise
2
+
3
+ Devise is a flexible authentication solution for Rails based on Warden. It:
4
+
5
+ * Is Rack based;
6
+ * Is a complete MVC solution based on Rails engines;
7
+ * Allows you to have multiple roles (or models/scopes) signed in at the same time;
8
+ * Is based on a modularity concept: use just what you really need.
9
+
10
+ Right now it's composed of 12 modules:
11
+
12
+ * Database Authenticatable: responsible for encrypting password and validating authenticity of a user while signing in.
13
+ * Token Authenticatable: validates authenticity of a user while signing in using an authentication token (also known as "single access token").
14
+ * HttpAuthenticatable: sign in users using basic HTTP authentication.
15
+ * Confirmable: responsible for verifying whether an account is already confirmed to sign in, and to send emails with confirmation instructions.
16
+ * Recoverable: takes care of reseting the user password and send reset instructions.
17
+ * Registerable: handles signing up users through a registration process.
18
+ * Rememberable: manages generating and clearing token for remember the user from a saved cookie.
19
+ * Trackable: tracks sign in count, timestamps and ip.
20
+ * Timeoutable: expires sessions without activity in a certain period of time.
21
+ * Validatable: creates all needed validations for email and password. It's totally optional, so you're able to to customize validations by yourself.
22
+ * Lockable: takes care of locking an account based on the number of failed sign in attempts. Handles unlock via expire and email.
23
+ * Activatable: if you need to activate accounts by other means, which are not through confirmation, use this module.
24
+
25
+ There's an example application using Devise at http://github.com/plataformatec/devise_example .
26
+
27
+ == Dependencies
28
+
29
+ Devise is based on Warden (http://github.com/hassox/warden), a Rack Authentication Framework so you need to install it as a gem. Please ensure you have it installed in order to use devise (see installation below).
30
+
31
+ == Installation
32
+
33
+ Install warden gem if you don't have it installed:
34
+
35
+ gem install warden
36
+
37
+ Install devise gem:
38
+
39
+ gem install devise --version=1.0.10
40
+
41
+ Configure warden and devise gems inside your app:
42
+
43
+ config.gem 'warden'
44
+ config.gem 'devise'
45
+
46
+ Run the generator:
47
+
48
+ ruby script/generate devise_install
49
+
50
+ And you're ready to go. The generator will install an initializer which describes ALL Devise's configuration options, so be sure to take a look at it and the documentation as well:
51
+
52
+ http://rdoc.info/projects/plataformatec/devise
53
+
54
+ If you want to use Devise with bundler on Rails 2.3, you need to follow the instructions here:
55
+
56
+ http://github.com/carlhuda/bundler/issues/issue/83
57
+
58
+ == Basic Usage
59
+
60
+ This is a walkthrough with all steps you need to setup a devise resource, including model, migration, route files, and optional configuration. You MUST also check out the *Generators* section below to help you start.
61
+
62
+ Devise must be set up within the model (or models) you want to use, and devise routes must be created inside your config/routes.rb file.
63
+
64
+ We're assuming here you want a User model with some modules, as outlined below:
65
+
66
+ class User < ActiveRecord::Base
67
+ devise :database_authenticatable, :confirmable, :recoverable, :rememberable, :trackable, :validatable
68
+ end
69
+
70
+ After you choose which modules to use, you need to setup your migrations. Luckily, devise has some helpers to save you from this boring work:
71
+
72
+ create_table :users do |t|
73
+ t.database_authenticatable
74
+ t.confirmable
75
+ t.recoverable
76
+ t.rememberable
77
+ t.trackable
78
+ t.timestamps
79
+ end
80
+
81
+ Remember that Devise don't rely on _attr_accessible_ or _attr_protected_ inside its modules, so be sure to setup what attributes are accessible or protected in your model.
82
+
83
+ The next setup after setting up your model is to configure your routes. You do this by opening up your config/routes.rb and adding:
84
+
85
+ map.devise_for :users
86
+
87
+ This is going to look inside you User model and create a set of needed routes (you can see them by running `rake routes`).
88
+
89
+ There are also some options available for configuring your routes, as :class_name (to set the class for that route), :path_prefix, :as and :path_names, where the last two have the same meaning as in common routes. The available :path_names are:
90
+
91
+ map.devise_for :users, :as => "usuarios", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification', :unlock => 'unblock' }
92
+
93
+ Be sure to check devise_for documentation for detailed description.
94
+
95
+ After this steps, run your migrations, and you are ready to go! But don't finish reading, we still have a lot to tell you:
96
+
97
+ == Controller filters and helpers
98
+
99
+ Devise is gonna create some helpers to use inside your controllers and views. To setup a controller that needs user authentication, just add this before_filter:
100
+
101
+ before_filter :authenticate_user!
102
+
103
+ To verify if a user is signed in, you have the following helper:
104
+
105
+ user_signed_in?
106
+
107
+ And to get the current signed in user this helper is available:
108
+
109
+ current_user
110
+
111
+ You have also access to the session for this scope:
112
+
113
+ user_session
114
+
115
+ After signing in a user, confirming it's account or updating it's password, devise will look for a scoped root path to redirect. Example: For a :user resource, it will use user_root_path if it exists, otherwise default root_path will be used. This means that you need to set the root inside your routes:
116
+
117
+ map.root :controller => 'home'
118
+
119
+ You can also overwrite after_sign_in_path_for and after_sign_out_path_for to customize better your redirect hooks.
120
+
121
+ Finally, you also need to setup default url options for the mailer in each environment. Here's is the configuration for config/environments/development.rb:
122
+
123
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
124
+
125
+ == Tidying up
126
+
127
+ Devise let's you setup as many roles as you want, so let's say you already have this User model and also want an Admin model with just authentication, trackable, lockable and timeoutable stuff and none of confirmation or password recovery. Just follow the same steps:
128
+
129
+ # Create a migration with the required fields
130
+ create_table :admins do |t|
131
+ t.database_authenticatable
132
+ t.lockable
133
+ t.trackable
134
+ end
135
+
136
+ # Inside your Admin model
137
+ devise :database_authenticatable, :trackable, :timeoutable, :lockable
138
+
139
+ # Inside your routes
140
+ map.devise_for :admin
141
+
142
+ # Inside your protected controller
143
+ before_filter :authenticate_admin!
144
+
145
+ # Inside your controllers and views
146
+ admin_signed_in?
147
+ current_admin
148
+ admin_session
149
+
150
+ == Generators
151
+
152
+ Devise comes with some generators to help you start:
153
+
154
+ ruby script/generate devise_install
155
+
156
+ This will generate an initializer, with a description of all configuration values. You can also generate models through:
157
+
158
+ ruby script/generate devise Model
159
+
160
+ A model configured with all devise modules and attr_accessible for default fields will be created. The generator will also create the migration and configure your routes for devise.
161
+
162
+ == Model configuration
163
+
164
+ The devise method in your models also accept some options to configure its modules. For example, you can chose which encryptor to use in database_authenticatable:
165
+
166
+ devise :database_authenticatable, :confirmable, :recoverable, :encryptor => :bcrypt
167
+
168
+ Besides :encryptor, you can provide :pepper, :stretches, :confirm_within, :remember_for, :timeout_in, :unlock_in and others. All those are describer in the initializer created when you invoke the devise_install generator describer above.
169
+
170
+ == Views
171
+
172
+ Since devise is an engine, it has all default views inside the gem. They are good to get you started, but you will want to customize them at some point. And Devise has a generator to make copy them all to your application:
173
+
174
+ ruby script/generate devise_views
175
+
176
+ By default Devise will use the same views for all roles you have. But what if you need so different views to each of them? Devise also has an easy way to accomplish it: just setup config.scoped_views to true inside "config/initializers/devise.rb".
177
+
178
+ After doing so you will be able to have views based on the scope like 'sessions/users/new' and 'sessions/admin/new'. If no view is found within the scope, Devise will fallback to the default view.
179
+
180
+ Devise uses flash messages to let users know if their login is successful or not. Devise expects your application to call 'flash[:notice]' and 'flash[:alert]' as appropriate.
181
+
182
+ == I18n
183
+
184
+ Devise uses flash messages with I18n with the flash keys :success and :failure. To customize your app, you can setup your locale file this way:
185
+
186
+ en:
187
+ devise:
188
+ sessions:
189
+ signed_in: 'Signed in successfully.'
190
+
191
+ You can also create distinct messages based on the resource you've configured using the singular name given in routes:
192
+
193
+ en:
194
+ devise:
195
+ sessions:
196
+ user:
197
+ signed_in: 'Welcome user, you are signed in.'
198
+ admin:
199
+ signed_in: 'Hello admin!'
200
+
201
+ Devise mailer uses the same pattern to create subject messages:
202
+
203
+ en:
204
+ devise:
205
+ mailer:
206
+ confirmation_instructions: 'Hello everybody!'
207
+ user:
208
+ confirmation_instructions: 'Hello User! Please confirm your email'
209
+ reset_password_instructions: 'Reset instructions'
210
+
211
+ Take a look at our locale file to check all available messages.
212
+
213
+ == Test helpers
214
+
215
+ Devise includes some tests helpers for functional specs. To use them, you just need to include Devise::TestHelpers in your test class and use the sign_in and sign_out method. Such methods have the same signature as in controllers:
216
+
217
+ sign_in :user, @user # sign_in(scope, resource)
218
+ sign_in @user # sign_in(resource)
219
+
220
+ sign_out :user # sign_out(scope)
221
+ sign_out @user # sign_out(resource)
222
+
223
+ You can include the Devise Test Helpers in all of your tests by adding the following to the bottom of your test/test_helper.rb or spec/spec_helper.rb file:
224
+
225
+ class ActionController::TestCase
226
+ include Devise::TestHelpers
227
+ end
228
+
229
+ Do not use such helpers for integration tests like Cucumber, Webrat... Just fill in the form or explicitly set the user in session. For more tips, check the wiki (http://wiki.github.com/plataformatec/devise).
230
+
231
+ == Migrating from other solutions
232
+
233
+ Devise implements encryption strategies for Clearance, Authlogic and Restful-Authentication. To make use of it set the desired encryptor in the encryptor initializer config option. You might also need to rename your encrypted password and salt columns to match Devises's one (encrypted_password and password_salt).
234
+
235
+ == Other ORMs
236
+
237
+ Devise supports both ActiveRecord (default) and MongoMapper, and has experimental Datamapper supports (in a sense that Devise test suite does not run completely with Datamapper). To choose other ORM, you just need to configure it in the initializer file.
238
+
239
+ == TODO
240
+
241
+ Please refer to TODO file.
242
+
243
+ == Security
244
+
245
+ Needless to say, security is extremely important to Devise. If you find yourself in a possible security issue with Devise, please go through the following steps, trying to reproduce the bug:
246
+
247
+ 1) Look at the source code a bit to find out whether your assumptions are correct;
248
+ 2) If possible, provide a way to reproduce the bug: a small app on Github or a step-by-step to reproduce;
249
+ 3) E-mail us or send a Github private message instead of using the normal issues;
250
+
251
+ Being able to reproduce the bug is the first step to fix it. Thanks for your understanding.
252
+
253
+ == Maintainers
254
+
255
+ * José Valim (http://github.com/josevalim)
256
+ * Carlos Antônio da Silva (http://github.com/carlosantoniodasilva)
257
+
258
+ == Contributors
259
+
260
+ We have a long running list of contributors. Check them all here:
261
+
262
+ http://github.com/plataformatec/devise/contributors
263
+
264
+ == Bugs and Feedback
265
+
266
+ If you discover any bugs or want to drop a line, feel free to create an issue on
267
+ GitHub or send an e-mail to the mailing list.
268
+
269
+ http://github.com/plataformatec/devise/issues
270
+ http://groups.google.com/group/plataformatec-devise
271
+
272
+ MIT License. Copyright 2009 Plataforma Tecnologia. http://blog.plataformatec.com.br