devise 4.7.1 → 4.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -4
- data/MIT-LICENSE +2 -1
- data/README.md +63 -54
- data/app/controllers/devise_controller.rb +2 -2
- data/config/locales/en.yml +1 -1
- data/lib/devise.rb +1 -5
- data/lib/devise/controllers/sign_in_out.rb +1 -1
- data/lib/devise/failure_app.rb +2 -2
- data/lib/devise/hooks/timeoutable.rb +2 -2
- data/lib/devise/models/authenticatable.rb +2 -1
- data/lib/devise/models/database_authenticatable.rb +5 -1
- data/lib/devise/models/rememberable.rb +1 -1
- data/lib/devise/models/trackable.rb +1 -1
- data/lib/devise/test/controller_helpers.rb +2 -0
- data/lib/devise/test/integration_helpers.rb +1 -1
- data/lib/devise/version.rb +1 -1
- data/lib/generators/devise/devise_generator.rb +1 -1
- data/lib/generators/devise/install_generator.rb +0 -4
- data/lib/generators/devise/views_generator.rb +1 -1
- data/lib/generators/templates/README +9 -1
- data/lib/generators/templates/controllers/omniauth_callbacks_controller.rb +1 -1
- data/lib/generators/templates/devise.rb +15 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66728973d95b80cb0029344f3ea6e86d0c01d692f8a363e54e85e2ebe29bcdb4
|
4
|
+
data.tar.gz: b41344b9a521d72d48f8b1e8618767ddb237a10f81b9d272376e9c09afc1da54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '03294fe66db7023bac9f5940ccf4aecd65af65329485e4eb7cb864b71729feffc965b144125310c4b5654273e1b2275b31b260b09040d5c58c6e0e907de347a1'
|
7
|
+
data.tar.gz: f599102d1558b3dcf1ccc68f8665b3229400f6e4d4da861c67173bbcddb9b6c0b15e6f36d43ff48eb8f89edcd8bf15d3767c4f3252a8739926aca979002336de
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,12 @@
|
|
1
|
-
###
|
1
|
+
### 4.7.1 - 2020-06-10
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Increase default stretches to 12 (by @sergey-alekseev)
|
5
|
+
* Ruby 2.7 support (kwarg warnings removed)
|
6
|
+
|
7
|
+
* bug fixes
|
8
|
+
* Generate scoped views with proper scoped errors partial (by @shobhitic)
|
9
|
+
* Allow to set scoped `already_authenticated` error messages (by @gurgelrenan)
|
2
10
|
|
3
11
|
### 4.7.1 - 2019-09-06
|
4
12
|
|
@@ -21,7 +29,7 @@
|
|
21
29
|
### 4.6.2 - 2019-03-26
|
22
30
|
|
23
31
|
* bug fixes
|
24
|
-
* Revert "Set `encrypted_password` to `nil` when `password` is set to `nil`" since it broke backward compatibility with existing applications. See more on https://github.com/
|
32
|
+
* Revert "Set `encrypted_password` to `nil` when `password` is set to `nil`" since it broke backward compatibility with existing applications. See more on https://github.com/heartcombo/devise/issues/5033#issuecomment-476386275 (by @mracos)
|
25
33
|
|
26
34
|
### 4.6.1 - 2019-02-11
|
27
35
|
|
@@ -68,7 +76,7 @@
|
|
68
76
|
* Add `autocomplete="new-password"` to new password fields (by @gssbzn)
|
69
77
|
* Add `autocomplete="current-password"` to current password fields (by @gssbzn)
|
70
78
|
* Remove redundant `self` from `database_authenticatable` module (by @abhishekkanojia)
|
71
|
-
* Update `simple_form` templates with changes from https://github.com/
|
79
|
+
* Update `simple_form` templates with changes from https://github.com/heartcombo/devise/commit/16b3d6d67c7e017d461ea17ed29ea9738dc77e83 and https://github.com/heartcombo/devise/commit/6260c29a867b9a656f1e1557abe347a523178fab (by @gssbzn)
|
72
80
|
* Remove `:trackable` from the default modules in the generators, to be more GDPR-friendly (by @fakenine)
|
73
81
|
|
74
82
|
* bug fixes
|
@@ -315,5 +323,5 @@ configured (by @joshpencheon)
|
|
315
323
|
You can check more examples and explanations on the [README section](README.md#strong-parameters)
|
316
324
|
and on the [ParameterSanitizer docs](lib/devise/parameter_sanitizer.rb).
|
317
325
|
|
318
|
-
Please check [3-stable](https://github.com/
|
326
|
+
Please check [3-stable](https://github.com/heartcombo/devise/blob/3-stable/CHANGELOG.md)
|
319
327
|
for previous changes.
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
Copyright
|
1
|
+
Copyright 2020 Rafael França, Leonardo Tegon, Carlos Antônio da Silva.
|
2
|
+
Copyright 2009-2019 Plataformatec.
|
2
3
|
|
3
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
5
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -1,11 +1,7 @@
|
|
1
|
-
![Devise Logo](https://raw.github.com/
|
1
|
+
![Devise Logo](https://raw.github.com/heartcombo/devise/master/devise.png)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
[![Build Status](https://api.travis-ci.org/plataformatec/devise.svg?branch=master)](http://travis-ci.org/plataformatec/devise)
|
6
|
-
[![Code Climate](https://codeclimate.com/github/plataformatec/devise.svg)](https://codeclimate.com/github/plataformatec/devise)
|
7
|
-
|
8
|
-
This README is [also available in a friendly navigable format](http://devise.plataformatec.com.br/).
|
3
|
+
[![Build Status](https://api.travis-ci.org/heartcombo/devise.svg?branch=master)](http://travis-ci.org/heartcombo/devise)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/heartcombo/devise.svg)](https://codeclimate.com/github/heartcombo/devise)
|
9
5
|
|
10
6
|
Devise is a flexible authentication solution for Rails based on Warden. It:
|
11
7
|
|
@@ -16,16 +12,16 @@ Devise is a flexible authentication solution for Rails based on Warden. It:
|
|
16
12
|
|
17
13
|
It's composed of 10 modules:
|
18
14
|
|
19
|
-
* [Database Authenticatable](http://www.rubydoc.info/github/
|
20
|
-
* [Omniauthable](http://www.rubydoc.info/github/
|
21
|
-
* [Confirmable](http://www.rubydoc.info/github/
|
22
|
-
* [Recoverable](http://www.rubydoc.info/github/
|
23
|
-
* [Registerable](http://www.rubydoc.info/github/
|
24
|
-
* [Rememberable](http://www.rubydoc.info/github/
|
25
|
-
* [Trackable](http://www.rubydoc.info/github/
|
26
|
-
* [Timeoutable](http://www.rubydoc.info/github/
|
27
|
-
* [Validatable](http://www.rubydoc.info/github/
|
28
|
-
* [Lockable](http://www.rubydoc.info/github/
|
15
|
+
* [Database Authenticatable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/DatabaseAuthenticatable): hashes 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.
|
16
|
+
* [Omniauthable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Omniauthable): adds OmniAuth (https://github.com/omniauth/omniauth) support.
|
17
|
+
* [Confirmable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Confirmable): sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
|
18
|
+
* [Recoverable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Recoverable): resets the user password and sends reset instructions.
|
19
|
+
* [Registerable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Registerable): handles signing up users through a registration process, also allowing them to edit and destroy their account.
|
20
|
+
* [Rememberable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Rememberable): manages generating and clearing a token for remembering the user from a saved cookie.
|
21
|
+
* [Trackable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Trackable): tracks sign in count, timestamps and IP address.
|
22
|
+
* [Timeoutable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Timeoutable): expires sessions that have not been active in a specified period of time.
|
23
|
+
* [Validatable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Validatable): provides validations of email and password. It's optional and can be customized, so you're able to define your own validations.
|
24
|
+
* [Lockable](http://www.rubydoc.info/github/heartcombo/devise/master/Devise/Models/Lockable): locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
|
29
25
|
|
30
26
|
## Table of Contents
|
31
27
|
|
@@ -73,15 +69,15 @@ It's composed of 10 modules:
|
|
73
69
|
|
74
70
|
The Devise Wiki has lots of additional information about Devise including many "how-to" articles and answers to the most frequently asked questions. Please browse the Wiki after finishing this README:
|
75
71
|
|
76
|
-
https://github.com/
|
72
|
+
https://github.com/heartcombo/devise/wiki
|
77
73
|
|
78
74
|
### Bug reports
|
79
75
|
|
80
76
|
If you discover a problem with Devise, we would like to know about it. However, we ask that you please review these guidelines before submitting a bug report:
|
81
77
|
|
82
|
-
https://github.com/
|
78
|
+
https://github.com/heartcombo/devise/wiki/Bug-reports
|
83
79
|
|
84
|
-
If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to
|
80
|
+
If you have discovered a security related bug, please do *NOT* use the GitHub issue tracker. Send an email to heartcombo@googlegroups.com.
|
85
81
|
|
86
82
|
### StackOverflow and Mailing List
|
87
83
|
|
@@ -97,7 +93,7 @@ https://groups.google.com/group/plataformatec-devise
|
|
97
93
|
|
98
94
|
You can view the Devise documentation in RDoc format here:
|
99
95
|
|
100
|
-
http://rubydoc.info/github/
|
96
|
+
http://rubydoc.info/github/heartcombo/devise/master/frames
|
101
97
|
|
102
98
|
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.
|
103
99
|
|
@@ -105,19 +101,19 @@ If you need to use Devise with previous versions of Rails, you can always run "g
|
|
105
101
|
|
106
102
|
There are a few example applications available on GitHub that demonstrate various features of Devise with different versions of Rails. You can view them here:
|
107
103
|
|
108
|
-
https://github.com/
|
104
|
+
https://github.com/heartcombo/devise/wiki/Example-Applications
|
109
105
|
|
110
106
|
### Extensions
|
111
107
|
|
112
108
|
Our community has created a number of extensions that add functionality above and beyond what is included with Devise. You can view a list of available extensions and add your own here:
|
113
109
|
|
114
|
-
https://github.com/
|
110
|
+
https://github.com/heartcombo/devise/wiki/Extensions
|
115
111
|
|
116
112
|
### Contributing
|
117
113
|
|
118
114
|
We hope that you will consider contributing to Devise. Please read this short overview for some information about how to get started:
|
119
115
|
|
120
|
-
https://github.com/
|
116
|
+
https://github.com/heartcombo/devise/wiki/Contributing
|
121
117
|
|
122
118
|
You will usually want to write tests for your changes. To run the test suite, go into Devise's top-level directory and run `bundle install` and `bin/test`.
|
123
119
|
Devise works with multiple Ruby and Rails versions, and ActiveRecord and Mongoid ORMs, which means you can run the test suite with some modifiers: `DEVISE_ORM` and `BUNDLE_GEMFILE`.
|
@@ -136,7 +132,7 @@ Please note that the command output will show the variable value being used.
|
|
136
132
|
|
137
133
|
### BUNDLE_GEMFILE
|
138
134
|
We can use this variable to tell bundler what Gemfile it should use (instead of the one in the current directory).
|
139
|
-
Inside the [gemfiles](https://github.com/
|
135
|
+
Inside the [gemfiles](https://github.com/heartcombo/devise/tree/master/gemfiles) directory, we have one for each version of Rails we support. When you send us a pull request, it may happen that the test suite breaks on Travis using some of them. If that's the case, you can simulate the same environment using the `BUNDLE_GEMFILE` variable.
|
140
136
|
For example, if the tests broke using Ruby 2.4.2 and Rails 4.1, you can do the following:
|
141
137
|
```bash
|
142
138
|
rbenv shell 2.4.2 # or rvm use 2.4.2
|
@@ -170,10 +166,10 @@ bin/test test/models/trackable_test.rb:16
|
|
170
166
|
|
171
167
|
## Starting with Rails?
|
172
168
|
|
173
|
-
If you are building your first Rails application, we recommend you *do not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch.
|
169
|
+
If you are building your first Rails application, we recommend you *do not* use Devise. Devise requires a good understanding of the Rails Framework. In such cases, we advise you to start a simple authentication system from scratch. Here's a few resources that should help you get started:
|
174
170
|
|
175
171
|
* Michael Hartl's online book: https://www.railstutorial.org/book/modeling_users
|
176
|
-
* Ryan Bates'
|
172
|
+
* Ryan Bates' Railscasts: http://railscasts.com/episodes/250-authentication-from-scratch and http://railscasts.com/episodes/250-authentication-from-scratch-revised
|
177
173
|
* Codecademy's Ruby on Rails: Authentication and Authorization: https://www.codecademy.com/learn/rails-auth
|
178
174
|
|
179
175
|
Once you have solidified your understanding of Rails and authentication mechanisms, we assure you Devise will be very pleasant to work with. :smiley:
|
@@ -270,7 +266,7 @@ member_session
|
|
270
266
|
The Devise method in your models also accepts some options to configure its modules. For example, you can choose the cost of the hashing algorithm with:
|
271
267
|
|
272
268
|
```ruby
|
273
|
-
devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches:
|
269
|
+
devise :database_authenticatable, :registerable, :confirmable, :recoverable, stretches: 13
|
274
270
|
```
|
275
271
|
|
276
272
|
Besides `:stretches`, you can define `:pepper`, `:encryptor`, `:confirm_within`, `:remember_for`, `:timeout_in`, `:unlock_in` among other options. For more details, see the initializer file that was created when you invoked the "devise:install" generator described above. This file is usually located at `/config/initializers/devise.rb`.
|
@@ -279,7 +275,7 @@ Besides `:stretches`, you can define `:pepper`, `:encryptor`, `:confirm_within`,
|
|
279
275
|
|
280
276
|
![The Parameter Sanitizer API has changed for Devise 4](http://messages.hellobits.com/warning.svg?message=The%20Parameter%20Sanitizer%20API%20has%20changed%20for%20Devise%204)
|
281
277
|
|
282
|
-
*For previous Devise versions see https://github.com/
|
278
|
+
*For previous Devise versions see https://github.com/heartcombo/devise/tree/3-stable#strong-parameters*
|
283
279
|
|
284
280
|
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.
|
285
281
|
|
@@ -289,7 +285,7 @@ There are just three actions in Devise that allow any set of parameters to be pa
|
|
289
285
|
* `sign_up` (`Devise::RegistrationsController#create`) - Permits authentication keys plus `password` and `password_confirmation`
|
290
286
|
* `account_update` (`Devise::RegistrationsController#update`) - Permits authentication keys plus `password`, `password_confirmation` and `current_password`
|
291
287
|
|
292
|
-
In case you want to permit additional parameters (the lazy way™), you can do so using a simple before
|
288
|
+
In case you want to permit additional parameters (the lazy way™), you can do so using a simple before action in your `ApplicationController`:
|
293
289
|
|
294
290
|
```ruby
|
295
291
|
class ApplicationController < ActionController::Base
|
@@ -464,7 +460,7 @@ Devise also ships with default routes. If you need to customize them, you should
|
|
464
460
|
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' }
|
465
461
|
```
|
466
462
|
|
467
|
-
Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/
|
463
|
+
Be sure to check `devise_for` [documentation](http://www.rubydoc.info/github/heartcombo/devise/master/ActionDispatch/Routing/Mapper%3Adevise_for) for details.
|
468
464
|
|
469
465
|
If you have the need for more deep customization, for instance to also allow "/sign_in" besides "/users/sign_in", all you need to do is create your routes normally and wrap them in a `devise_scope` block in the router:
|
470
466
|
|
@@ -520,7 +516,7 @@ en:
|
|
520
516
|
|
521
517
|
Take a look at our locale file to check all available messages. You may also be interested in one of the many translations that are available on our wiki:
|
522
518
|
|
523
|
-
https://github.com/
|
519
|
+
https://github.com/heartcombo/devise/wiki/I18n
|
524
520
|
|
525
521
|
Caution: Devise Controllers inherit from ApplicationController. If your app uses multiple locales, you should be sure to set I18n.locale in ApplicationController.
|
526
522
|
|
@@ -532,15 +528,21 @@ cases/specs.
|
|
532
528
|
|
533
529
|
### Controller tests
|
534
530
|
|
535
|
-
Controller tests require that you include `Devise::Test::
|
531
|
+
Controller tests require that you include `Devise::Test::IntegrationHelpers` on
|
536
532
|
your test case or its parent `ActionController::TestCase` superclass.
|
537
|
-
For Rails 5, include `Devise::Test::
|
538
|
-
for controller tests
|
533
|
+
For Rails versions prior to 5, include `Devise::Test::ControllerHelpers` instead, since the superclass
|
534
|
+
for controller tests was changed to ActionDispatch::IntegrationTest
|
539
535
|
(for more details, see the [Integration tests](#integration-tests) section).
|
540
536
|
|
541
537
|
```ruby
|
542
538
|
class PostsControllerTest < ActionController::TestCase
|
543
|
-
include Devise::Test::
|
539
|
+
include Devise::Test::IntegrationHelpers # Rails >= 5
|
540
|
+
end
|
541
|
+
```
|
542
|
+
|
543
|
+
```ruby
|
544
|
+
class PostsControllerTest < ActionController::TestCase
|
545
|
+
include Devise::Test::ControllerHelpers # Rails < 5
|
544
546
|
end
|
545
547
|
```
|
546
548
|
|
@@ -620,7 +622,7 @@ are executed in your tests.
|
|
620
622
|
|
621
623
|
You can read more about testing your Rails 3 - Rails 4 controllers with RSpec in the wiki:
|
622
624
|
|
623
|
-
* https://github.com/
|
625
|
+
* https://github.com/heartcombo/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)
|
624
626
|
|
625
627
|
### OmniAuth
|
626
628
|
|
@@ -632,7 +634,7 @@ config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
|
|
632
634
|
|
633
635
|
You can read more about OmniAuth support in the wiki:
|
634
636
|
|
635
|
-
* https://github.com/
|
637
|
+
* https://github.com/heartcombo/devise/wiki/OmniAuth:-Overview
|
636
638
|
|
637
639
|
### Configuring multiple models
|
638
640
|
|
@@ -679,7 +681,7 @@ end
|
|
679
681
|
|
680
682
|
### Password reset tokens and Rails logs
|
681
683
|
|
682
|
-
If you enable the [Recoverable](http://rubydoc.info/github/
|
684
|
+
If you enable the [Recoverable](http://rubydoc.info/github/heartcombo/devise/master/Devise/Models/Recoverable) module, note that a stolen password reset token could give an attacker access to your application. Devise takes effort to generate random, secure tokens, and stores only token digests in the database, never plaintext. However the default logging behavior in Rails can cause plaintext tokens to leak into log files:
|
683
685
|
|
684
686
|
1. Action Mailer logs the entire contents of all outgoing emails to the DEBUG level. Password reset tokens delivered to users in email will be leaked.
|
685
687
|
2. Active Job logs all arguments to every enqueued job at the INFO level. If you configure Devise to use `deliver_later` to send password reset emails, password reset tokens will be leaked.
|
@@ -697,41 +699,48 @@ Devise supports ActiveRecord (default) and Mongoid. To select another ORM, simpl
|
|
697
699
|
|
698
700
|
### Rails API Mode
|
699
701
|
|
700
|
-
Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only).
|
702
|
+
Rails 5+ has a built-in [API Mode](https://edgeguides.rubyonrails.org/api_app.html) which optimizes Rails for use as an API (only). Devise is _somewhat_ able to handle applications that are built in this mode without additional modifications in the sense that it should not raise exceptions and the like. But some issues may still arise during `development`/`testing`, as we still don't know the full extent of this compatibility. (For more information, see [issue #4947](https://github.com/heartcombo/devise/issues/4947/))
|
701
703
|
|
702
|
-
|
703
|
-
|
704
|
-
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
|
705
|
-
```
|
704
|
+
#### Supported Authentication Strategies
|
705
|
+
API-only applications don't support browser-based authentication via cookies, which is devise's default. Yet, devise can still provide authentication out of the box in those cases with the `http_authenticatable` strategy, which uses HTTP Basic Auth and authenticates the user on each request. (For more info, see this wiki article for [How To: Use HTTP Basic Authentication](https://github.com/heartcombo/devise/wiki/How-To:-Use-HTTP-Basic-Authentication))
|
706
706
|
|
707
|
-
|
707
|
+
The devise default for HTTP Auth is disabled, so it will need to be enabled in the devise initializer for the database strategy:
|
708
708
|
|
709
|
-
|
709
|
+
```ruby
|
710
|
+
config.http_authenticatable = [:database]
|
711
|
+
```
|
710
712
|
|
711
|
-
|
713
|
+
This restriction does not limit you from implementing custom warden strategies, either in your application or via gem-based extensions for devise.
|
714
|
+
A common authentication strategy for APIs is token-based authentication. For more information on extending devise to support this type of authentication and others, see the wiki article for [Simple Token Authentication Examples and alternatives](https://github.com/heartcombo/devise/wiki/How-To:-Simple-Token-Authentication-Example#alternatives) or this blog post on [Custom authentication methods with Devise](http://blog.plataformatec.com.br/2019/01/custom-authentication-methods-with-devise/).
|
712
715
|
|
713
|
-
|
716
|
+
#### Testing
|
717
|
+
API Mode changes the order of the middleware stack, and this can cause problems for `Devise::Test::IntegrationHelpers`. This problem usually surfaces as an ```undefined method `[]=' for nil:NilClass``` error when using integration test helpers, such as `#sign_in`. The solution is simply to reorder the middlewares by adding the following to test.rb:
|
714
718
|
|
715
719
|
```ruby
|
716
|
-
config.
|
720
|
+
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
|
721
|
+
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore
|
717
722
|
```
|
718
723
|
|
719
|
-
|
724
|
+
For a deeper understanding of this, review [this issue](https://github.com/heartcombo/devise/issues/4696).
|
725
|
+
|
726
|
+
Additionally be mindful that without views supported, some email-based flows from Confirmable, Recoverable and Lockable are not supported directly at this time.
|
727
|
+
|
728
|
+
## Additional information
|
720
729
|
|
721
730
|
### Warden
|
722
731
|
|
723
732
|
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:
|
724
733
|
|
725
|
-
https://github.com/
|
734
|
+
https://github.com/wardencommunity/warden
|
726
735
|
|
727
736
|
### Contributors
|
728
737
|
|
729
738
|
We have a long list of valued contributors. Check them all at:
|
730
739
|
|
731
|
-
https://github.com/
|
740
|
+
https://github.com/heartcombo/devise/graphs/contributors
|
732
741
|
|
733
742
|
## License
|
734
743
|
|
735
|
-
MIT License. Copyright 2009-2019 Plataformatec.
|
744
|
+
MIT License. Copyright 2020 Rafael França, Leaonardo Tegon, Carlos Antônio da Silva. Copyright 2009-2019 Plataformatec.
|
736
745
|
|
737
|
-
|
746
|
+
The Devise logo is licensed under [Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License](https://creativecommons.org/licenses/by-nc-nd/4.0/).
|
@@ -112,7 +112,7 @@ MESSAGE
|
|
112
112
|
end
|
113
113
|
|
114
114
|
if authenticated && resource = warden.user(resource_name)
|
115
|
-
|
115
|
+
set_flash_message(:alert, 'already_authenticated', scope: 'devise.failure')
|
116
116
|
redirect_to after_sign_in_path_for(resource)
|
117
117
|
end
|
118
118
|
end
|
@@ -184,7 +184,7 @@ MESSAGE
|
|
184
184
|
options[:default] = Array(options[:default]).unshift(kind.to_sym)
|
185
185
|
options[:resource_name] = resource_name
|
186
186
|
options = devise_i18n_options(options)
|
187
|
-
I18n.t("#{options[:resource_name]}.#{kind}", options)
|
187
|
+
I18n.t("#{options[:resource_name]}.#{kind}", **options)
|
188
188
|
end
|
189
189
|
|
190
190
|
# Controllers inheriting DeviseController are advised to override this
|
data/config/locales/en.yml
CHANGED
data/lib/devise.rb
CHANGED
@@ -71,7 +71,7 @@ module Devise
|
|
71
71
|
|
72
72
|
# The number of times to hash the password.
|
73
73
|
mattr_accessor :stretches
|
74
|
-
@@stretches =
|
74
|
+
@@stretches = 12
|
75
75
|
|
76
76
|
# The default key used when authenticating over http auth.
|
77
77
|
mattr_accessor :http_authentication_key
|
@@ -297,10 +297,6 @@ module Devise
|
|
297
297
|
mattr_accessor :sign_in_after_change_password
|
298
298
|
@@sign_in_after_change_password = true
|
299
299
|
|
300
|
-
def self.rails51? # :nodoc:
|
301
|
-
Rails.gem_version >= Gem::Version.new("5.1.x")
|
302
|
-
end
|
303
|
-
|
304
300
|
def self.activerecord51? # :nodoc:
|
305
301
|
defined?(ActiveRecord) && ActiveRecord.gem_version >= Gem::Version.new("5.1.x")
|
306
302
|
end
|
@@ -21,7 +21,7 @@ module Devise
|
|
21
21
|
# to the set_user method in warden.
|
22
22
|
# If you are using a custom warden strategy and the timeoutable module, you have to
|
23
23
|
# set `env["devise.skip_timeout"] = true` in the request to use this method, like we do
|
24
|
-
# in the sessions controller: https://github.com/
|
24
|
+
# in the sessions controller: https://github.com/heartcombo/devise/blob/master/app/controllers/devise/sessions_controller.rb#L7
|
25
25
|
#
|
26
26
|
# Examples:
|
27
27
|
#
|
data/lib/devise/failure_app.rb
CHANGED
@@ -107,7 +107,7 @@ module Devise
|
|
107
107
|
options[:authentication_keys] = keys.join(I18n.translate(:"support.array.words_connector"))
|
108
108
|
options = i18n_options(options)
|
109
109
|
|
110
|
-
I18n.t(:"#{scope}.#{message}", options)
|
110
|
+
I18n.t(:"#{scope}.#{message}", **options)
|
111
111
|
else
|
112
112
|
message.to_s
|
113
113
|
end
|
@@ -152,7 +152,7 @@ module Devise
|
|
152
152
|
|
153
153
|
# We need to add the rootpath to `script_name` manually for applications that use a Rails
|
154
154
|
# version lower than 5.1. Otherwise, it is going to generate a wrong path for Engines
|
155
|
-
# that use Devise. Remove it when the support of Rails 5.0 is
|
155
|
+
# that use Devise. Remove it when the support of Rails 5.0 is dropped.
|
156
156
|
elsif root_path_defined?(context) && !rails_51_and_up?
|
157
157
|
rootpath = context.routes.url_helpers.root_path
|
158
158
|
opts[:script_name] = rootpath.chomp('/') if rootpath.length > 1
|
@@ -21,8 +21,8 @@ Warden::Manager.after_set_user do |record, warden, options|
|
|
21
21
|
|
22
22
|
proxy = Devise::Hooks::Proxy.new(warden)
|
23
23
|
|
24
|
-
if
|
25
|
-
|
24
|
+
if !env['devise.skip_timeout'] &&
|
25
|
+
record.timedout?(last_request_at) &&
|
26
26
|
!proxy.remember_me_is_active?(record)
|
27
27
|
Devise.sign_out_all_scopes ? proxy.sign_out : proxy.sign_out(scope)
|
28
28
|
throw :warden, scope: scope, message: :timeout
|
@@ -152,7 +152,8 @@ module Devise
|
|
152
152
|
# # If the record is new or changed then delay the
|
153
153
|
# # delivery until the after_commit callback otherwise
|
154
154
|
# # send now because after_commit will not be called.
|
155
|
-
#
|
155
|
+
# # For Rails < 6 use `changed?` instead of `saved_changes?`.
|
156
|
+
# if new_record? || saved_changes?
|
156
157
|
# pending_devise_notifications << [notification, args]
|
157
158
|
# else
|
158
159
|
# render_and_send_devise_message(notification, *args)
|
@@ -7,6 +7,10 @@ module Devise
|
|
7
7
|
# Authenticatable Module, responsible for hashing the password and
|
8
8
|
# validating the authenticity of a user while signing in.
|
9
9
|
#
|
10
|
+
# This module defines a `password=` method. This method will hash the argument
|
11
|
+
# and store it in the `encrypted_password` column, bypassing any pre-existing
|
12
|
+
# `password` column if it exists.
|
13
|
+
#
|
10
14
|
# == Options
|
11
15
|
#
|
12
16
|
# DatabaseAuthenticatable adds the following options to devise_for:
|
@@ -195,7 +199,7 @@ module Devise
|
|
195
199
|
# Hashes the password using bcrypt. Custom hash functions should override
|
196
200
|
# this method to apply their own algorithm.
|
197
201
|
#
|
198
|
-
# See https://github.com/
|
202
|
+
# See https://github.com/heartcombo/devise-encryptable for examples
|
199
203
|
# of other hashing engines.
|
200
204
|
def password_digest(password)
|
201
205
|
Devise::Encryptor.digest(self.class, password)
|
@@ -102,7 +102,7 @@ module Devise
|
|
102
102
|
|
103
103
|
def remember_me?(token, generated_at)
|
104
104
|
# TODO: Normalize the JSON type coercion along with the Timeoutable hook
|
105
|
-
# in a single place https://github.com/
|
105
|
+
# in a single place https://github.com/heartcombo/devise/blob/ffe9d6d406e79108cf32a2c6a1d0b3828849c40b/lib/devise/hooks/timeoutable.rb#L14-L18
|
106
106
|
if generated_at.is_a?(String)
|
107
107
|
generated_at = time_from_json(generated_at)
|
108
108
|
end
|
@@ -33,7 +33,7 @@ module Devise
|
|
33
33
|
def update_tracked_fields!(request)
|
34
34
|
# We have to check if the user is already persisted before running
|
35
35
|
# `save` here because invalid users can be saved if we don't.
|
36
|
-
# See https://github.com/
|
36
|
+
# See https://github.com/heartcombo/devise/issues/4673 for more details.
|
37
37
|
return if new_record?
|
38
38
|
|
39
39
|
update_tracked_fields(request)
|
@@ -37,6 +37,8 @@ module Devise
|
|
37
37
|
@response
|
38
38
|
end
|
39
39
|
|
40
|
+
ruby2_keywords(:process) if respond_to?(:ruby2_keywords, true)
|
41
|
+
|
40
42
|
# We need to set up the environment variables and the response in the controller.
|
41
43
|
def setup_controller_for_warden #:nodoc:
|
42
44
|
@request.env['action_controller.instance'] = @controller
|
@@ -28,7 +28,7 @@ module Devise
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
# Signs in a specific resource, mimicking a
|
31
|
+
# Signs in a specific resource, mimicking a successful sign in
|
32
32
|
# operation through +Devise::SessionsController#create+.
|
33
33
|
#
|
34
34
|
# * +resource+ - The resource that should be authenticated
|
data/lib/devise/version.rb
CHANGED
@@ -13,7 +13,7 @@ module Devise
|
|
13
13
|
desc "Generates a model with the given NAME (if one does not exist) with devise " \
|
14
14
|
"configuration plus a migration file and devise routes."
|
15
15
|
|
16
|
-
hook_for :orm
|
16
|
+
hook_for :orm, type: :boolean
|
17
17
|
|
18
18
|
class_option :routes, desc: "Generate routes", type: :boolean, default: true
|
19
19
|
|
@@ -42,7 +42,7 @@ module Devise
|
|
42
42
|
def view_directory(name, _target_path = nil)
|
43
43
|
directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
|
44
44
|
if scope
|
45
|
-
content.gsub
|
45
|
+
content.gsub("devise/shared", "#{plural_scope}/shared")
|
46
46
|
else
|
47
47
|
content
|
48
48
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
===============================================================================
|
2
2
|
|
3
|
-
|
3
|
+
Depending on your application's configuration some manual setup may be required:
|
4
4
|
|
5
5
|
1. Ensure you have defined default url options in your environments files. Here
|
6
6
|
is an example of default_url_options appropriate for a development environment
|
@@ -10,10 +10,14 @@ Some setup you must do manually if you haven't yet:
|
|
10
10
|
|
11
11
|
In production, :host should be set to the actual host of your application.
|
12
12
|
|
13
|
+
* Required for all applications. *
|
14
|
+
|
13
15
|
2. Ensure you have defined root_url to *something* in your config/routes.rb.
|
14
16
|
For example:
|
15
17
|
|
16
18
|
root to: "home#index"
|
19
|
+
|
20
|
+
* Not required for API-only Applications *
|
17
21
|
|
18
22
|
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
|
19
23
|
For example:
|
@@ -21,8 +25,12 @@ Some setup you must do manually if you haven't yet:
|
|
21
25
|
<p class="notice"><%= notice %></p>
|
22
26
|
<p class="alert"><%= alert %></p>
|
23
27
|
|
28
|
+
* Not required for API-only Applications *
|
29
|
+
|
24
30
|
4. You can copy Devise views (for customization) to your app by running:
|
25
31
|
|
26
32
|
rails g devise:views
|
33
|
+
|
34
|
+
* Not required *
|
27
35
|
|
28
36
|
===============================================================================
|
@@ -9,7 +9,7 @@ class <%= @scope_prefix %>OmniauthCallbacksController < Devise::OmniauthCallback
|
|
9
9
|
# end
|
10
10
|
|
11
11
|
# More info at:
|
12
|
-
# https://github.com/
|
12
|
+
# https://github.com/heartcombo/devise#omniauth
|
13
13
|
|
14
14
|
# GET|POST /resource/auth/twitter
|
15
15
|
# def passthru
|
@@ -1,5 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# Assuming you have not yet modified this file, each configuration option below
|
4
|
+
# is set to its default value. Note that some are commented out while others
|
5
|
+
# are not: uncommented lines are intended to protect your configuration from
|
6
|
+
# breaking changes in upgrades (i.e., in the event that future versions of
|
7
|
+
# Devise change the default values for those options).
|
8
|
+
#
|
3
9
|
# Use this hook to configure devise mailer, warden hooks and so forth.
|
4
10
|
# Many of these configuration options can be set straight in your model.
|
5
11
|
Devise.setup do |config|
|
@@ -68,7 +74,10 @@ Devise.setup do |config|
|
|
68
74
|
# Tell if authentication through HTTP Auth is enabled. False by default.
|
69
75
|
# It can be set to an array that will enable http authentication only for the
|
70
76
|
# given strategies, for example, `config.http_authenticatable = [:database]` will
|
71
|
-
# enable it only for database authentication.
|
77
|
+
# enable it only for database authentication.
|
78
|
+
# For API-only applications to support authentication "out-of-the-box", you will likely want to
|
79
|
+
# enable this with :database unless you are using a custom strategy.
|
80
|
+
# The supported strategies are:
|
72
81
|
# :database = Support basic authentication with authentication key + password
|
73
82
|
# config.http_authenticatable = false
|
74
83
|
|
@@ -103,15 +112,18 @@ Devise.setup do |config|
|
|
103
112
|
# config.reload_routes = true
|
104
113
|
|
105
114
|
# ==> Configuration for :database_authenticatable
|
106
|
-
# For bcrypt, this is the cost for hashing the password and defaults to
|
115
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 12. If
|
107
116
|
# using other algorithms, it sets how many times you want the password to be hashed.
|
117
|
+
# The number of stretches used for generating the hashed password are stored
|
118
|
+
# with the hashed password. This allows you to change the stretches without
|
119
|
+
# invalidating existing passwords.
|
108
120
|
#
|
109
121
|
# Limiting the stretches to just one in testing will increase the performance of
|
110
122
|
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
111
123
|
# a value less than 10 in other environments. Note that, for bcrypt (the default
|
112
124
|
# algorithm), the cost increases exponentially with the number of stretches (e.g.
|
113
125
|
# a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
|
114
|
-
config.stretches = Rails.env.test? ? 1 :
|
126
|
+
config.stretches = Rails.env.test? ? 1 : 12
|
115
127
|
|
116
128
|
# Set up a pepper to generate the hashed password.
|
117
129
|
# config.pepper = '<%= SecureRandom.hex(64) %>'
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.7.
|
4
|
+
version: 4.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
8
8
|
- Carlos Antônio
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-06-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: warden
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
description: Flexible authentication solution for Rails with Warden
|
85
|
-
email:
|
85
|
+
email: heartcombo@googlegroups.com
|
86
86
|
executables: []
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
@@ -198,11 +198,11 @@ files:
|
|
198
198
|
- lib/generators/templates/simple_form_for/registrations/new.html.erb
|
199
199
|
- lib/generators/templates/simple_form_for/sessions/new.html.erb
|
200
200
|
- lib/generators/templates/simple_form_for/unlocks/new.html.erb
|
201
|
-
homepage: https://github.com/
|
201
|
+
homepage: https://github.com/heartcombo/devise
|
202
202
|
licenses:
|
203
203
|
- MIT
|
204
204
|
metadata: {}
|
205
|
-
post_install_message:
|
205
|
+
post_install_message:
|
206
206
|
rdoc_options: []
|
207
207
|
require_paths:
|
208
208
|
- lib
|
@@ -217,8 +217,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
217
|
- !ruby/object:Gem::Version
|
218
218
|
version: '0'
|
219
219
|
requirements: []
|
220
|
-
rubygems_version: 3.0.
|
221
|
-
signing_key:
|
220
|
+
rubygems_version: 3.0.3
|
221
|
+
signing_key:
|
222
222
|
specification_version: 4
|
223
223
|
summary: Flexible authentication solution for Rails with Warden
|
224
224
|
test_files: []
|