loyal_devise 2.1.2 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +14 -9
- data/.yardopts +9 -0
- data/CHANGELOG.rdoc +60 -5
- data/CONTRIBUTING.md +4 -2
- data/Gemfile +7 -7
- data/Gemfile.lock +107 -101
- data/MIT-LICENSE +1 -1
- data/README.md +110 -48
- data/Rakefile +1 -0
- data/app/controllers/devise/confirmations_controller.rb +2 -4
- data/app/controllers/devise/omniauth_callbacks_controller.rb +0 -1
- data/app/controllers/devise/passwords_controller.rb +16 -5
- data/app/controllers/devise/registrations_controller.rb +13 -7
- data/app/controllers/devise/sessions_controller.rb +6 -6
- data/app/controllers/devise/unlocks_controller.rb +3 -4
- data/app/controllers/devise_controller.rb +12 -33
- data/app/helpers/devise_helper.rb +0 -1
- data/app/mailers/devise/mailer.rb +7 -8
- data/app/views/devise/mailer/confirmation_instructions.html.erb +1 -1
- data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
- data/app/views/devise/registrations/edit.html.erb +5 -1
- data/config/locales/en.yml +48 -48
- data/devise.gemspec +6 -6
- data/devise.png +0 -0
- data/gemfiles/{Gemfile.rails-3.1.x → Gemfile.rails-3.2.x} +8 -12
- data/gemfiles/Gemfile.rails-3.2.x.lock +156 -0
- data/lib/devise.rb +34 -11
- data/lib/devise/controllers/helpers.rb +33 -7
- data/lib/devise/controllers/rememberable.rb +6 -3
- data/lib/devise/controllers/scoped_views.rb +1 -2
- data/lib/devise/controllers/url_helpers.rb +0 -1
- data/lib/devise/delegator.rb +0 -1
- data/lib/devise/failure_app.rb +8 -2
- data/lib/devise/hooks/activatable.rb +1 -2
- data/lib/devise/hooks/forgetable.rb +0 -1
- data/lib/devise/hooks/lockable.rb +1 -2
- data/lib/devise/hooks/rememberable.rb +1 -2
- data/lib/devise/hooks/timeoutable.rb +0 -1
- data/lib/devise/hooks/trackable.rb +0 -1
- data/lib/devise/mailers/helpers.rb +18 -14
- data/lib/devise/mapping.rb +6 -7
- data/lib/devise/models.rb +0 -1
- data/lib/devise/models/authenticatable.rb +50 -27
- data/lib/devise/models/confirmable.rb +37 -16
- data/lib/devise/models/database_authenticatable.rb +17 -3
- data/lib/devise/models/lockable.rb +1 -2
- data/lib/devise/models/omniauthable.rb +1 -2
- data/lib/devise/models/recoverable.rb +10 -6
- data/lib/devise/models/registerable.rb +0 -1
- data/lib/devise/models/rememberable.rb +1 -2
- data/lib/devise/models/timeoutable.rb +1 -2
- data/lib/devise/models/token_authenticatable.rb +0 -1
- data/lib/devise/models/trackable.rb +0 -1
- data/lib/devise/models/validatable.rb +0 -1
- data/lib/devise/modules.rb +1 -2
- data/lib/devise/omniauth.rb +0 -1
- data/lib/devise/omniauth/config.rb +0 -1
- data/lib/devise/omniauth/url_helpers.rb +0 -1
- data/lib/devise/orm/active_record.rb +1 -2
- data/lib/devise/orm/mongoid.rb +1 -2
- data/lib/devise/{param_filter.rb → parameter_filter.rb} +10 -12
- data/lib/devise/parameter_sanitizer.rb +59 -0
- data/lib/devise/rails.rb +0 -1
- data/lib/devise/rails/routes.rb +22 -18
- data/lib/devise/rails/warden_compat.rb +0 -30
- data/lib/devise/strategies/authenticatable.rb +8 -6
- data/lib/devise/strategies/base.rb +1 -2
- data/lib/devise/strategies/database_authenticatable.rb +1 -2
- data/lib/devise/strategies/rememberable.rb +1 -2
- data/lib/devise/strategies/token_authenticatable.rb +38 -4
- data/lib/devise/test_helpers.rb +0 -1
- data/lib/devise/time_inflector.rb +1 -2
- data/lib/devise/version.rb +1 -2
- data/lib/generators/active_record/devise_generator.rb +1 -5
- data/lib/generators/active_record/templates/migration.rb +0 -1
- data/lib/generators/active_record/templates/migration_existing.rb +0 -1
- data/lib/generators/devise/devise_generator.rb +0 -1
- data/lib/generators/devise/install_generator.rb +0 -1
- data/lib/generators/devise/orm_helpers.rb +1 -2
- data/lib/generators/devise/views_generator.rb +8 -3
- data/lib/generators/mongoid/devise_generator.rb +1 -2
- data/lib/generators/templates/README +1 -1
- data/lib/generators/templates/devise.rb +10 -5
- data/lib/generators/templates/markerb/confirmation_instructions.markerb +1 -1
- data/lib/generators/templates/simple_form_for/confirmations/new.html.erb +1 -0
- data/lib/generators/templates/simple_form_for/registrations/edit.html.erb +6 -1
- data/lib/generators/templates/simple_form_for/unlocks/new.html.erb +1 -0
- data/loyal_devise.gemspec +27 -0
- data/test/controllers/custom_strategy_test.rb +0 -1
- data/test/controllers/helpers_test.rb +0 -1
- data/test/controllers/internal_helpers_test.rb +13 -4
- data/test/controllers/passwords_controller_test.rb +32 -0
- data/test/controllers/sessions_controller_test.rb +28 -1
- data/test/controllers/url_helpers_test.rb +0 -1
- data/test/delegator_test.rb +0 -1
- data/test/devise_test.rb +12 -2
- data/test/failure_app_test.rb +3 -4
- data/test/generators/active_record_generator_test.rb +1 -4
- data/test/generators/devise_generator_test.rb +0 -1
- data/test/generators/install_generator_test.rb +0 -1
- data/test/generators/mongoid_generator_test.rb +0 -1
- data/test/generators/views_generator_test.rb +16 -2
- data/test/helpers/devise_helper_test.rb +1 -2
- data/test/integration/authenticatable_test.rb +92 -27
- data/test/integration/confirmable_test.rb +7 -7
- data/test/integration/database_authenticatable_test.rb +8 -7
- data/test/integration/http_authenticatable_test.rb +19 -2
- data/test/integration/lockable_test.rb +1 -2
- data/test/integration/omniauthable_test.rb +2 -3
- data/test/integration/recoverable_test.rb +40 -12
- data/test/integration/registerable_test.rb +17 -14
- data/test/integration/rememberable_test.rb +16 -10
- data/test/integration/timeoutable_test.rb +11 -2
- data/test/integration/token_authenticatable_test.rb +45 -2
- data/test/integration/trackable_test.rb +1 -2
- data/test/mailers/confirmation_instructions_test.rb +11 -3
- data/test/mailers/reset_password_instructions_test.rb +11 -3
- data/test/mailers/unlock_instructions_test.rb +11 -2
- data/test/mapping_test.rb +0 -1
- data/test/models/authenticatable_test.rb +6 -1
- data/test/models/confirmable_test.rb +53 -2
- data/test/models/database_authenticatable_test.rb +57 -21
- data/test/models/lockable_test.rb +1 -2
- data/test/models/omniauthable_test.rb +0 -1
- data/test/models/recoverable_test.rb +21 -5
- data/test/models/registerable_test.rb +0 -1
- data/test/models/rememberable_test.rb +4 -4
- data/test/models/serializable_test.rb +8 -8
- data/test/models/timeoutable_test.rb +0 -1
- data/test/models/token_authenticatable_test.rb +0 -1
- data/test/models/trackable_test.rb +0 -1
- data/test/models/validatable_test.rb +16 -6
- data/test/models_test.rb +7 -24
- data/test/omniauth/config_test.rb +1 -2
- data/test/omniauth/url_helpers_test.rb +4 -2
- data/test/orm/active_record.rb +1 -1
- data/test/orm/mongoid.rb +2 -4
- data/test/parameter_sanitizer_test.rb +51 -0
- data/test/rails_app/Rakefile +0 -4
- data/test/rails_app/app/active_record/admin.rb +0 -1
- data/test/rails_app/app/active_record/shim.rb +1 -2
- data/test/rails_app/app/active_record/user.rb +0 -1
- data/test/rails_app/app/controllers/admins/sessions_controller.rb +1 -2
- data/test/rails_app/app/controllers/admins_controller.rb +0 -1
- data/test/rails_app/app/controllers/application_controller.rb +1 -1
- data/test/rails_app/app/controllers/home_controller.rb +0 -1
- data/test/rails_app/app/controllers/publisher/registrations_controller.rb +1 -2
- data/test/rails_app/app/controllers/publisher/sessions_controller.rb +1 -2
- data/test/rails_app/app/controllers/users/omniauth_callbacks_controller.rb +1 -2
- data/test/rails_app/app/controllers/users_controller.rb +8 -1
- data/test/rails_app/app/helpers/application_helper.rb +0 -1
- data/test/rails_app/app/mailers/users/mailer.rb +4 -1
- data/test/rails_app/app/mongoid/admin.rb +4 -3
- data/test/rails_app/app/mongoid/shim.rb +3 -5
- data/test/rails_app/app/mongoid/user.rb +2 -3
- data/test/rails_app/app/views/users/edit_form.html.erb +1 -0
- data/test/rails_app/bin/bundle +3 -0
- data/test/rails_app/bin/rails +4 -0
- data/test/rails_app/bin/rake +4 -0
- data/test/rails_app/config/application.rb +1 -3
- data/test/rails_app/config/boot.rb +3 -4
- data/test/rails_app/config/environment.rb +2 -3
- data/test/rails_app/config/environments/development.rb +23 -8
- data/test/rails_app/config/environments/production.rb +68 -18
- data/test/rails_app/config/environments/test.rb +18 -16
- data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -1
- data/test/rails_app/config/initializers/devise.rb +0 -1
- data/test/rails_app/config/initializers/inflections.rb +0 -1
- data/test/rails_app/config/initializers/secret_token.rb +8 -3
- data/test/rails_app/config/initializers/session_store.rb +1 -0
- data/test/rails_app/config/routes.rb +20 -17
- data/test/rails_app/db/migrate/20100401102949_create_tables.rb +0 -1
- data/test/rails_app/db/schema.rb +0 -1
- data/test/rails_app/lib/shared_admin.rb +0 -1
- data/test/rails_app/lib/shared_user.rb +0 -2
- data/test/routes_test.rb +22 -21
- data/test/support/assertions.rb +0 -1
- data/test/support/helpers.rb +1 -2
- data/test/support/integration.rb +0 -1
- data/test/support/webrat/integrations/rails.rb +0 -1
- data/test/test_helper.rb +8 -2
- data/test/test_helpers_test.rb +0 -1
- data/test/test_models.rb +26 -0
- metadata +65 -27
- data/gemfiles/Gemfile.rails-3.1.x.lock +0 -167
- data/test/indifferent_hash.rb +0 -34
- data/test/rails_app/script/rails +0 -10
data/.travis.yml
CHANGED
@@ -1,15 +1,20 @@
|
|
1
|
+
language: ruby
|
1
2
|
script: "bundle exec rake test"
|
2
3
|
rvm:
|
3
|
-
- 1.8.7
|
4
|
-
- 1.9.2
|
5
4
|
- 1.9.3
|
6
|
-
-
|
5
|
+
- 2.0.0
|
6
|
+
env:
|
7
|
+
- DEVISE_ORM=mongoid
|
8
|
+
- DEVISE_ORM=active_record
|
7
9
|
gemfile:
|
8
|
-
- gemfiles/Gemfile.rails-3.
|
10
|
+
- gemfiles/Gemfile.rails-3.2.x
|
9
11
|
- Gemfile
|
12
|
+
services:
|
13
|
+
- mongodb
|
10
14
|
notifications:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
email: false
|
16
|
+
campfire:
|
17
|
+
on_success: change
|
18
|
+
on_failure: always
|
19
|
+
rooms:
|
20
|
+
- secure: "TRiqvuM4i/QmRDWjUSNitE5/P91BOzDkNl53+bZjjtxcISCswZtmECWBR7n9\n3xwqCOU1o2lfohxZ32OHOj/Nj7o+90zWJfWxcv+if0hIXRiil62M5pg0lZUd\nyJ4M5VQ0lSWo5he1OUrXhSabPJeaK3B8yT/tdh+qO5yzR+vb/jc="
|
data/.yardopts
ADDED
data/CHANGELOG.rdoc
CHANGED
@@ -1,18 +1,73 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
== 3.0.0.rc
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Rails 4 and Strong Parameters compatibility. (@carlosantoniodasilva, @josevalim, @latortuga, @lucasmazza, @nashby, @rafaelfranca, @spastorino)
|
5
|
+
* Drop support for Rails < 3.2 and Ruby < 1.9.3.
|
6
|
+
|
7
|
+
== 2.2.4
|
8
|
+
|
9
|
+
* enhancements
|
10
|
+
* Add `destroy_with_password` to `DatabaseAuthenticatable`. Allows destroying a record when `:current_password` matches, similarly to how `update_with_password` works. (by @michiel3)
|
11
|
+
* Allow to override path after password resetting (by @worker8)
|
12
|
+
* Add `#skip_confirmation_notification!` method to `Confirmable`. Allows skipping confirmation email without auto-confirming. (by @gregates)
|
13
|
+
* allow_unconfirmed_access_for config from `:confirmable` module can be set to `nil` that means unconfirmed access for unlimited time. (by @nashby)
|
14
|
+
* Support Rails' token strategy on authentication (by @robhurring)
|
15
|
+
* Support explicitly setting the http authentication key via `config.http_authentication_key` (by @neo)
|
16
|
+
|
17
|
+
* bug fix
|
18
|
+
* Do not redirect when accessing devise API via JSON. (by @sebastianwr)
|
19
|
+
* Generating scoped devise views now uses the correct scoped shared links partial instead of the default devise one (by @nashby)
|
20
|
+
* Fix inheriting mailer templates from `Devise::Mailer`
|
21
|
+
* Fix a bug when procs are used as default mailer in Devise (by @tomasv)
|
22
|
+
|
23
|
+
== 2.2.3
|
24
|
+
|
25
|
+
Security announcement: http://blog.plataformatec.com.br/2013/01/security-announcement-devise-v2-2-3-v2-1-3-v2-0-5-and-v1-5-3-released/
|
26
|
+
|
27
|
+
* bug fix
|
28
|
+
* Require string conversion for all values
|
29
|
+
|
30
|
+
== 2.2.2
|
31
|
+
|
32
|
+
* bug fix
|
33
|
+
* Fix bug when checking for reconfirmable in templates
|
34
|
+
|
35
|
+
== 2.2.1
|
36
|
+
|
37
|
+
* bug fix
|
38
|
+
* Fix regression with case_insensitive_keys
|
39
|
+
* Fix regression when password is blank when it is invalid
|
40
|
+
|
41
|
+
== 2.2.0
|
42
|
+
|
43
|
+
* backwards incompatible changes
|
44
|
+
* `headers_for` is deprecated, customize the mailer directly instead
|
45
|
+
* All mailer methods now expect a second argument with delivery options
|
46
|
+
* Default minimum password length is now 8 (by @carlosgaldino)
|
47
|
+
* Support alternate sign in error message when email record does not exist (this adds a new I18n key to the locale file) (by @gabetax)
|
48
|
+
* DeviseController responds only to HTML requests by default (call `DeviseController.respond_to` or `ApplicationController.respond_to` to add new formats)
|
49
|
+
* Support Mongoid 3 onwards (by @durran)
|
50
|
+
|
51
|
+
* enhancements
|
52
|
+
* Fix unlockable which could leak account existence on paranoid mode (by @latortuga)
|
3
53
|
* Confirmable now has a confirm_within option to set a period while the confirmation token is still valid (by @promisedlandt)
|
4
|
-
*
|
54
|
+
* Flash messages in controller now respects `resource_name` (by @latortuga)
|
5
55
|
* Separate `sign_in` and `sign_up` on RegistrationsController (by @rubynortheast)
|
6
56
|
* Add autofocus to default views (by @Radagaisus)
|
57
|
+
* Unlock user on password reset (by @marcinb)
|
58
|
+
* Allow validation callbacks to apply to virtual attributes (by @latortuga)
|
7
59
|
|
8
60
|
* bug fix
|
61
|
+
* unconfirmed_email now uses the proper e-mail on salutation
|
62
|
+
* Fix default email_regexp config to not allow spaces (by @kukula)
|
9
63
|
* Fix a regression introduced on warden 1.2.1 (by @ejfinneran)
|
10
64
|
* Properly camelize omniauth strategies (by @saizai)
|
11
65
|
* Do not set flash messages for non navigational requests on session sign out (by @mathieul)
|
12
66
|
* Set the proper fields as required on the lockable module (by @nickhoffman)
|
13
67
|
* Respects Devise mailer default's reply_to (by @mrchrisadams)
|
14
|
-
* Properly assign resource on sign_in action (by @adammcnamara)
|
15
|
-
*
|
68
|
+
* Properly assign resource on `sign_in` related action (by @adammcnamara)
|
69
|
+
* `update_with_password` doesn't change encrypted password when it is invalid (by @nashby)
|
70
|
+
* Properly handle namespaced models on Active Record generator (by @nashby)
|
16
71
|
|
17
72
|
== 2.1.2
|
18
73
|
|
data/CONTRIBUTING.md
CHANGED
@@ -4,9 +4,11 @@
|
|
4
4
|
|
5
5
|
2) If you find a security bug, **DO NOT** submit an issue here. Please send an e-mail to [developers@plataformatec.com.br](mailto:developers@plataformatec.com.br) instead.
|
6
6
|
|
7
|
-
3) Do a small search on the issues tracker before submitting your issue to see if it was already reported / fixed.
|
7
|
+
3) Do a small search on the issues tracker before submitting your issue to see if it was already reported / fixed.
|
8
8
|
|
9
|
-
|
9
|
+
4) When reporting an issue, include Rails, Devise and Warden versions. If you are getting exceptions, please include the full backtrace.
|
10
|
+
|
11
|
+
That's it! The more information you give, the easier it becomes for us to track it down and fix it.
|
10
12
|
Ideally, you should provide an application that reproduces the error or a test case to Devise's suite.
|
11
13
|
|
12
14
|
Thanks!
|
data/Gemfile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
source "
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem "rails", "~>
|
5
|
+
gem "rails", "~> 4.0.0.rc1"
|
6
6
|
gem "omniauth", "~> 1.0.0"
|
7
7
|
gem "omniauth-oauth2", "~> 1.0.0"
|
8
8
|
gem "rdoc"
|
@@ -10,8 +10,8 @@ gem "rdoc"
|
|
10
10
|
group :test do
|
11
11
|
gem "omniauth-facebook"
|
12
12
|
gem "omniauth-openid", "~> 1.0.1"
|
13
|
-
gem "webrat", "0.7.
|
14
|
-
gem "mocha", :require => false
|
13
|
+
gem "webrat", "0.7.3", :require => false
|
14
|
+
gem "mocha", "~> 0.13.1", :require => false
|
15
15
|
end
|
16
16
|
|
17
17
|
platforms :jruby do
|
@@ -22,10 +22,10 @@ end
|
|
22
22
|
|
23
23
|
platforms :ruby do
|
24
24
|
gem "sqlite3"
|
25
|
+
end
|
25
26
|
|
27
|
+
platforms :mri_19, :mri_20 do
|
26
28
|
group :mongoid do
|
27
|
-
gem "
|
28
|
-
gem "mongoid", "~> 2.0"
|
29
|
-
gem "bson_ext", "~> 1.3.0"
|
29
|
+
gem "mongoid", github: "mongoid/mongoid", branch: "master"
|
30
30
|
end
|
31
31
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,133 +1,141 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/mongoid/mongoid.git
|
3
|
+
revision: fe7f43430580860db6d1d89cea27eda24ab60ab1
|
4
|
+
branch: master
|
5
|
+
specs:
|
6
|
+
mongoid (4.0.0)
|
7
|
+
activemodel (~> 4.0.0.rc1)
|
8
|
+
moped (~> 1.4.2)
|
9
|
+
origin (~> 1.0)
|
10
|
+
tzinfo (~> 0.3.22)
|
11
|
+
|
1
12
|
PATH
|
2
13
|
remote: .
|
3
14
|
specs:
|
4
|
-
|
15
|
+
devise (3.0.0.rc)
|
5
16
|
bcrypt-ruby (~> 3.0)
|
6
|
-
loyal_warden (~> 2.0.0)
|
7
17
|
orm_adapter (~> 0.1)
|
18
|
+
railties (>= 3.2.6, < 5)
|
19
|
+
warden (~> 1.2.1)
|
8
20
|
|
9
21
|
GEM
|
10
|
-
remote:
|
22
|
+
remote: https://rubygems.org/
|
11
23
|
specs:
|
12
|
-
actionmailer (
|
13
|
-
actionpack (=
|
14
|
-
mail (~> 2.
|
15
|
-
actionpack (
|
16
|
-
|
17
|
-
|
18
|
-
builder (~> 3.0.0)
|
24
|
+
actionmailer (4.0.0.rc1)
|
25
|
+
actionpack (= 4.0.0.rc1)
|
26
|
+
mail (~> 2.5.3)
|
27
|
+
actionpack (4.0.0.rc1)
|
28
|
+
activesupport (= 4.0.0.rc1)
|
29
|
+
builder (~> 3.1.0)
|
19
30
|
erubis (~> 2.7.0)
|
20
|
-
|
21
|
-
rack (~>
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
addressable (2.2.6)
|
40
|
-
arel (3.0.2)
|
31
|
+
rack (~> 1.5.2)
|
32
|
+
rack-test (~> 0.6.2)
|
33
|
+
activemodel (4.0.0.rc1)
|
34
|
+
activesupport (= 4.0.0.rc1)
|
35
|
+
builder (~> 3.1.0)
|
36
|
+
activerecord (4.0.0.rc1)
|
37
|
+
activemodel (= 4.0.0.rc1)
|
38
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
39
|
+
activesupport (= 4.0.0.rc1)
|
40
|
+
arel (~> 4.0.0)
|
41
|
+
activerecord-deprecated_finders (1.0.2)
|
42
|
+
activesupport (4.0.0.rc1)
|
43
|
+
i18n (~> 0.6, >= 0.6.4)
|
44
|
+
minitest (~> 4.2)
|
45
|
+
multi_json (~> 1.3)
|
46
|
+
thread_safe (~> 0.1)
|
47
|
+
tzinfo (~> 0.3.37)
|
48
|
+
arel (4.0.0)
|
49
|
+
atomic (1.1.8)
|
41
50
|
bcrypt-ruby (3.0.1)
|
42
|
-
|
43
|
-
bson_ext (1.3.1)
|
44
|
-
builder (3.0.0)
|
51
|
+
builder (3.1.4)
|
45
52
|
erubis (2.7.0)
|
46
|
-
faraday (0.7
|
47
|
-
|
48
|
-
multipart-post (~> 1.1.3)
|
49
|
-
rack (>= 1.1.0, < 2)
|
53
|
+
faraday (0.8.7)
|
54
|
+
multipart-post (~> 1.1)
|
50
55
|
hashie (1.2.0)
|
51
|
-
hike (1.2.
|
52
|
-
|
53
|
-
|
54
|
-
json (1.7.
|
55
|
-
|
56
|
-
|
57
|
-
mail (2.
|
56
|
+
hike (1.2.2)
|
57
|
+
httpauth (0.2.0)
|
58
|
+
i18n (0.6.4)
|
59
|
+
json (1.7.7)
|
60
|
+
jwt (0.1.8)
|
61
|
+
multi_json (>= 1.5)
|
62
|
+
mail (2.5.3)
|
58
63
|
i18n (>= 0.4.0)
|
59
64
|
mime-types (~> 1.16)
|
60
65
|
treetop (~> 1.4.8)
|
61
66
|
metaclass (0.0.1)
|
62
|
-
mime-types (1.
|
63
|
-
|
67
|
+
mime-types (1.23)
|
68
|
+
minitest (4.7.4)
|
69
|
+
mocha (0.13.3)
|
64
70
|
metaclass (~> 0.0.1)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
multi_json (~> 1.0.3)
|
77
|
-
omniauth (1.0.1)
|
71
|
+
moped (1.4.5)
|
72
|
+
multi_json (1.7.2)
|
73
|
+
multipart-post (1.2.0)
|
74
|
+
nokogiri (1.5.9)
|
75
|
+
oauth2 (0.8.1)
|
76
|
+
faraday (~> 0.8)
|
77
|
+
httpauth (~> 0.1)
|
78
|
+
jwt (~> 0.1.4)
|
79
|
+
multi_json (~> 1.0)
|
80
|
+
rack (~> 1.2)
|
81
|
+
omniauth (1.0.3)
|
78
82
|
hashie (~> 1.2)
|
79
83
|
rack
|
80
|
-
omniauth-facebook (1.
|
81
|
-
omniauth-oauth2 (~> 1.0.
|
82
|
-
omniauth-oauth2 (1.0.
|
83
|
-
oauth2 (~> 0.
|
84
|
+
omniauth-facebook (1.4.0)
|
85
|
+
omniauth-oauth2 (~> 1.0.2)
|
86
|
+
omniauth-oauth2 (1.0.3)
|
87
|
+
oauth2 (~> 0.8.0)
|
84
88
|
omniauth (~> 1.0)
|
85
89
|
omniauth-openid (1.0.1)
|
86
90
|
omniauth (~> 1.0)
|
87
91
|
rack-openid (~> 1.3.1)
|
92
|
+
origin (1.1.0)
|
88
93
|
orm_adapter (0.4.0)
|
89
94
|
polyglot (0.3.3)
|
90
|
-
rack (1.
|
91
|
-
rack-cache (1.2)
|
92
|
-
rack (>= 0.4)
|
95
|
+
rack (1.5.2)
|
93
96
|
rack-openid (1.3.1)
|
94
97
|
rack (>= 1.1.0)
|
95
98
|
ruby-openid (>= 2.1.8)
|
96
|
-
rack-
|
97
|
-
rack
|
98
|
-
rack-test (0.6.1)
|
99
|
+
rack-test (0.6.2)
|
99
100
|
rack (>= 1.0)
|
100
|
-
rails (
|
101
|
-
actionmailer (=
|
102
|
-
actionpack (=
|
103
|
-
activerecord (=
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
railties (
|
109
|
-
actionpack (=
|
110
|
-
activesupport (=
|
111
|
-
rack-ssl (~> 1.3.2)
|
101
|
+
rails (4.0.0.rc1)
|
102
|
+
actionmailer (= 4.0.0.rc1)
|
103
|
+
actionpack (= 4.0.0.rc1)
|
104
|
+
activerecord (= 4.0.0.rc1)
|
105
|
+
activesupport (= 4.0.0.rc1)
|
106
|
+
bundler (>= 1.3.0, < 2.0)
|
107
|
+
railties (= 4.0.0.rc1)
|
108
|
+
sprockets-rails (~> 2.0.0.rc4)
|
109
|
+
railties (4.0.0.rc1)
|
110
|
+
actionpack (= 4.0.0.rc1)
|
111
|
+
activesupport (= 4.0.0.rc1)
|
112
112
|
rake (>= 0.8.7)
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
rdoc (3.12)
|
113
|
+
thor (>= 0.18.1, < 2.0)
|
114
|
+
rake (10.0.4)
|
115
|
+
rdoc (4.0.1)
|
117
116
|
json (~> 1.4)
|
118
|
-
ruby-openid (2.
|
119
|
-
sprockets (2.
|
117
|
+
ruby-openid (2.2.3)
|
118
|
+
sprockets (2.9.3)
|
120
119
|
hike (~> 1.2)
|
120
|
+
multi_json (~> 1.0)
|
121
121
|
rack (~> 1.0)
|
122
122
|
tilt (~> 1.1, != 1.3.0)
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
123
|
+
sprockets-rails (2.0.0.rc4)
|
124
|
+
actionpack (>= 3.0)
|
125
|
+
activesupport (>= 3.0)
|
126
|
+
sprockets (~> 2.8)
|
127
|
+
sqlite3 (1.3.7)
|
128
|
+
thor (0.18.1)
|
129
|
+
thread_safe (0.1.0)
|
130
|
+
atomic
|
131
|
+
tilt (1.4.0)
|
132
|
+
treetop (1.4.12)
|
127
133
|
polyglot
|
128
134
|
polyglot (>= 0.3.1)
|
129
|
-
tzinfo (0.3.
|
130
|
-
|
135
|
+
tzinfo (0.3.37)
|
136
|
+
warden (1.2.1)
|
137
|
+
rack (>= 1.0)
|
138
|
+
webrat (0.7.3)
|
131
139
|
nokogiri (>= 1.2.0)
|
132
140
|
rack (>= 1.0)
|
133
141
|
rack-test (>= 0.5.3)
|
@@ -138,17 +146,15 @@ PLATFORMS
|
|
138
146
|
DEPENDENCIES
|
139
147
|
activerecord-jdbc-adapter
|
140
148
|
activerecord-jdbcsqlite3-adapter
|
141
|
-
|
149
|
+
devise!
|
142
150
|
jruby-openssl
|
143
|
-
|
144
|
-
|
145
|
-
mongo (~> 1.3.0)
|
146
|
-
mongoid (~> 2.0)
|
151
|
+
mocha (~> 0.13.1)
|
152
|
+
mongoid!
|
147
153
|
omniauth (~> 1.0.0)
|
148
154
|
omniauth-facebook
|
149
155
|
omniauth-oauth2 (~> 1.0.0)
|
150
156
|
omniauth-openid (~> 1.0.1)
|
151
|
-
rails (~>
|
157
|
+
rails (~> 4.0.0.rc1)
|
152
158
|
rdoc
|
153
159
|
sqlite3
|
154
|
-
webrat (= 0.7.
|
160
|
+
webrat (= 0.7.3)
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
|
1
|
+
![Devise Logo](https://raw.github.com/plataformatec/devise/master/devise.png)
|
2
2
|
|
3
|
-
[
|
3
|
+
By [Plataformatec](http://plataformatec.com.br/).
|
4
|
+
|
5
|
+
[![Gem Version](https://fury-badge.herokuapp.com/rb/devise.png)](http://badge.fury.io/rb/devise)
|
6
|
+
[![Build Status](https://api.travis-ci.org/plataformatec/devise.png?branch=master)](http://travis-ci.org/plataformatec/devise)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/plataformatec/devise.png)](https://codeclimate.com/github/plataformatec/devise)
|
4
8
|
|
5
9
|
This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
|
6
10
|
|
@@ -11,7 +15,7 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
|
|
11
15
|
* Allows you to have multiple roles (or models/scopes) signed in at the same time;
|
12
16
|
* Is based on a modularity concept: use just what you really need.
|
13
17
|
|
14
|
-
It's composed of
|
18
|
+
It's composed of 11 modules:
|
15
19
|
|
16
20
|
* [Database Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/DatabaseAuthenticatable): encrypts and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
|
17
21
|
* [Token Authenticatable](http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/TokenAuthenticatable): signs in a user based on an authentication token (also known as "single access token"). The token can be given both through query string or HTTP Basic Authentication.
|
@@ -53,7 +57,7 @@ You can view the Devise documentation in RDoc format here:
|
|
53
57
|
|
54
58
|
http://rubydoc.info/github/plataformatec/devise/master/frames
|
55
59
|
|
56
|
-
If you need to use Devise with Rails
|
60
|
+
If you need to use Devise with previous versions of Rails, you can always run "gem server" from the command line after you install the gem to access the old documentation.
|
57
61
|
|
58
62
|
### Example applications
|
59
63
|
|
@@ -86,7 +90,7 @@ Once you have solidified your understanding of Rails and authentication mechanis
|
|
86
90
|
|
87
91
|
## Getting started
|
88
92
|
|
89
|
-
Devise
|
93
|
+
Devise 3.0 works with Rails 3.2 onwards. You can add it to your Gemfile with:
|
90
94
|
|
91
95
|
```ruby
|
92
96
|
gem 'devise'
|
@@ -106,7 +110,7 @@ The generator will install an initializer which describes ALL Devise's configura
|
|
106
110
|
rails generate devise MODEL
|
107
111
|
```
|
108
112
|
|
109
|
-
Replace MODEL by the class name used for the applications users, it's frequently
|
113
|
+
Replace MODEL by the class name used for the applications users, it's frequently `User` but could also be `Admin`. This will create a model (if one does not exist) and configure it with default Devise modules. Next, you'll usually run `rake db:migrate` as the generator will have created a migration file (if your ORM supports them). This generator also configures your config/routes.rb file to point to the Devise controller.
|
110
114
|
|
111
115
|
Note that you should re-start your app here if you've already started it. Otherwise you'll run into strange errors like users being unable to login and the route helpers being undefined.
|
112
116
|
|
@@ -139,7 +143,7 @@ user_session
|
|
139
143
|
After signing in a user, confirming the account or updating the 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:
|
140
144
|
|
141
145
|
```ruby
|
142
|
-
root :
|
146
|
+
root to: "home#index"
|
143
147
|
```
|
144
148
|
|
145
149
|
You can also overwrite `after_sign_in_path_for` and `after_sign_out_path_for` to customize your redirect hooks.
|
@@ -172,34 +176,57 @@ devise :database_authenticatable, :registerable, :confirmable, :recoverable, :st
|
|
172
176
|
|
173
177
|
Besides :stretches, you can define :pepper, :encryptor, :confirm_within, :remember_for, :timeout_in, :unlock_in and other values. For details, see the initializer file that was created when you invoked the "devise:install" generator described above.
|
174
178
|
|
175
|
-
###
|
179
|
+
### Strong Parameters
|
176
180
|
|
177
|
-
|
181
|
+
When you customize your own views, you may end up adding new attributes to forms. Rails 4 moved the parameter sanitization from the model to the controller, causing Devise to handle this concern at the controller as well.
|
182
|
+
|
183
|
+
There are just three actions in Devise that allows any set of parameters to be passed down to the model, therefore requiring sanitization. Their names and the permited parameters by default are:
|
184
|
+
|
185
|
+
* `sign_in` (`Devise::SessionsController#new`) - Permits only the authentication keys (like `email`)
|
186
|
+
* `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
|
187
|
+
* `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
|
188
|
+
|
189
|
+
In case you want to customize the permitted parameters (the lazy way™) you can do with a simple before filter in your `ApplicationController`:
|
178
190
|
|
179
191
|
```ruby
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
192
|
+
class ApplicationController < ActionController::Base
|
193
|
+
before_filter :configure_permitted_parameters, if: :devise_controller?
|
194
|
+
|
195
|
+
protected
|
196
|
+
|
197
|
+
def configure_permitted_parameters
|
198
|
+
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:username, :email) }
|
199
|
+
end
|
185
200
|
end
|
201
|
+
```
|
186
202
|
|
187
|
-
|
188
|
-
devise :database_authenticatable, :timeoutable
|
203
|
+
If you have multiple roles, you may want to set up different parameter sanitizer per role. In this case, we recommend inheriting from `Devise::ParameterSanitizer` and add your own logic:
|
189
204
|
|
190
|
-
|
191
|
-
|
205
|
+
```ruby
|
206
|
+
class User::ParameterSanitizer < Devise::ParameterSanitizer
|
207
|
+
def sign_in
|
208
|
+
default_params.permit(:username, :email)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
```
|
192
212
|
|
193
|
-
|
194
|
-
before_filter :authenticate_admin!
|
213
|
+
And then configure your controllers to use it:
|
195
214
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
215
|
+
```ruby
|
216
|
+
class ApplicationController < ActionController::Base
|
217
|
+
protected
|
218
|
+
|
219
|
+
def devise_parameter_sanitizer
|
220
|
+
if resource_class.is_a?(User)
|
221
|
+
User::ParameterSanitizer.new(User, :user, params)
|
222
|
+
else
|
223
|
+
super # Use the default one
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
200
227
|
```
|
201
228
|
|
202
|
-
|
229
|
+
The example above overrides the permitted parameters for the user to be both `:username` and `:email`. The non-lazy way to configure parameters would be by defining the before filter above in a custom controller. We detail how to configure and customize controllers in some sections below.
|
203
230
|
|
204
231
|
### Configuring views
|
205
232
|
|
@@ -223,29 +250,31 @@ rails generate devise:views users
|
|
223
250
|
|
224
251
|
If the customization at the views level is not enough, you can customize each controller by following these steps:
|
225
252
|
|
226
|
-
1
|
253
|
+
1. Create your custom controller, for example a `Admins::SessionsController`:
|
227
254
|
|
228
|
-
```ruby
|
229
|
-
class Admins::SessionsController < Devise::SessionsController
|
230
|
-
end
|
231
|
-
```
|
255
|
+
```ruby
|
256
|
+
class Admins::SessionsController < Devise::SessionsController
|
257
|
+
end
|
258
|
+
```
|
232
259
|
|
233
|
-
|
260
|
+
Note that in the above example, the controller needs to be created in the `app/controller/admins/` directory.
|
234
261
|
|
235
|
-
|
236
|
-
|
237
|
-
```
|
262
|
+
2. Tell the router to use this controller:
|
263
|
+
|
264
|
+
```ruby
|
265
|
+
devise_for :admins, :controllers => { :sessions => "admins/sessions" }
|
266
|
+
```
|
238
267
|
|
239
|
-
3
|
268
|
+
3. And since we changed the controller, it won't use the `"devise/sessions"` views, so remember to copy `"devise/sessions"` to `"admin/sessions"`.
|
240
269
|
|
241
|
-
Remember that Devise uses flash messages to let users know if sign in was successful or failed. Devise expects your application to call "flash[:notice]" and "flash[:alert]" as appropriate. Do not print the entire flash hash, print specific keys or at least remove the `:timedout` key from the hash as Devise adds this key in some circumstances, this key is not meant for display.
|
270
|
+
Remember that Devise uses flash messages to let users know if sign in was successful or failed. Devise expects your application to call `"flash[:notice]"` and `"flash[:alert]"` as appropriate. Do not print the entire flash hash, print specific keys or at least remove the `:timedout` key from the hash as Devise adds this key in some circumstances, this key is not meant for display.
|
242
271
|
|
243
272
|
### Configuring routes
|
244
273
|
|
245
274
|
Devise also ships with default routes. If you need to customize them, you should probably be able to do it through the devise_for method. It accepts several options like :class_name, :path_prefix and so on, including the possibility to change path names for I18n:
|
246
275
|
|
247
276
|
```ruby
|
248
|
-
devise_for :users, :path => "
|
277
|
+
devise_for :users, :path => "auth", :path_names => { :sign_in => 'login', :sign_out => 'logout', :password => 'secret', :confirmation => 'verification', :unlock => 'unblock', :registration => 'register', :sign_up => 'cmon_let_me_in' }
|
249
278
|
```
|
250
279
|
|
251
280
|
Be sure to check `devise_for` documentation for details.
|
@@ -330,28 +359,61 @@ sign_out @user # sign_out(resource)
|
|
330
359
|
|
331
360
|
There are two things that is important to keep in mind:
|
332
361
|
|
333
|
-
1
|
362
|
+
1. These helpers are not going to work for integration tests driven by Capybara or Webrat. They are meant to be used with functional tests only. Instead, fill in the form or explicitly set the user in session;
|
334
363
|
|
335
|
-
2
|
364
|
+
2. If you are testing Devise internal controllers or a controller that inherits from Devise's, you need to tell Devise which mapping should be used before a request. This is necessary because Devise gets this information from router, but since functional tests do not pass through the router, it needs to be told explicitly. For example, if you are testing the user scope, simply do:
|
336
365
|
|
366
|
+
```ruby
|
337
367
|
@request.env["devise.mapping"] = Devise.mappings[:user]
|
338
368
|
get :new
|
369
|
+
```
|
339
370
|
|
340
371
|
### Omniauth
|
341
372
|
|
342
|
-
Devise comes with Omniauth support out of the box to authenticate
|
373
|
+
Devise comes with Omniauth support out of the box to authenticate with other providers. To use it, just specify your omniauth configuration in `config/initializers/devise.rb`:
|
374
|
+
|
375
|
+
```ruby
|
376
|
+
config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
377
|
+
```
|
378
|
+
|
379
|
+
You can read more about Omniauth support in the wiki:
|
343
380
|
|
344
381
|
* https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
|
345
382
|
|
346
|
-
###
|
383
|
+
### Configuring multiple models
|
347
384
|
|
348
|
-
Devise
|
385
|
+
Devise allows you to set up as many roles as you want. For example, you may have a User model and also want an Admin model with just authentication and timeoutable features. If so, just follow these steps:
|
349
386
|
|
350
|
-
|
387
|
+
```ruby
|
388
|
+
# Create a migration with the required fields
|
389
|
+
create_table :admins do |t|
|
390
|
+
t.string :email
|
391
|
+
t.string :encrypted_password
|
392
|
+
t.timestamps
|
393
|
+
end
|
351
394
|
|
352
|
-
|
395
|
+
# Inside your Admin model
|
396
|
+
devise :database_authenticatable, :timeoutable
|
353
397
|
|
354
|
-
|
398
|
+
# Inside your routes
|
399
|
+
devise_for :admins
|
400
|
+
|
401
|
+
# Inside your protected controller
|
402
|
+
before_filter :authenticate_admin!
|
403
|
+
|
404
|
+
# Inside your controllers and views
|
405
|
+
admin_signed_in?
|
406
|
+
current_admin
|
407
|
+
admin_session
|
408
|
+
```
|
409
|
+
|
410
|
+
On the other hand, you can simply run the generator!
|
411
|
+
|
412
|
+
### Other ORMs
|
413
|
+
|
414
|
+
Devise supports ActiveRecord (default) and Mongoid. To choose other ORM, you just need to require it in the initializer file.
|
415
|
+
|
416
|
+
## Additional information
|
355
417
|
|
356
418
|
### Heroku
|
357
419
|
|
@@ -363,8 +425,6 @@ config.assets.initialize_on_precompile = false
|
|
363
425
|
|
364
426
|
Read more about the potential issues at http://guides.rubyonrails.org/asset_pipeline.html
|
365
427
|
|
366
|
-
## Additional information
|
367
|
-
|
368
428
|
### Warden
|
369
429
|
|
370
430
|
Devise is based on Warden, which is a general Rack authentication framework created by Daniel Neighman. We encourage you to read more about Warden here:
|
@@ -385,4 +445,6 @@ https://github.com/plataformatec/devise/contributors
|
|
385
445
|
|
386
446
|
## License
|
387
447
|
|
388
|
-
MIT License. Copyright
|
448
|
+
MIT License. Copyright 2009-2013 Plataformatec. http://plataformatec.com.br
|
449
|
+
|
450
|
+
You are not granted rights or licenses to the trademarks of the Plataformatec, including without limitation the Devise name or logo.
|