devise-secure_password 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,99 +1,70 @@
1
- # Devise Secure Password Extension
1
+ ![Devise Security Password Logo](https://raw.github.com/ValiMail/devise-secure_password/main/devise_security_password.png)
2
2
 
3
3
  [![License](http://img.shields.io/badge/license-MIT-yellowgreen.svg)](#license)
4
+ [![CircleCI](https://dl.circleci.com/status-badge/img/gh/ValiMail/devise-secure_password/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/ValiMail/devise-secure_password/tree/main)
4
5
 
5
6
  The __Devise Secure Password Extension__ is a user account password policy enforcement gem that can be
6
- added to a Rails project to enforce password policies. The gem is implemented as an extension to the Rails
7
+ added to a Rails project to enforce password policies.
8
+
9
+ The gem is implemented as an extension to the Rails
7
10
  [devise](https://github.com/plataformatec/devise) authentication solution gem and requires that __devise__ is installed
8
11
  as well.
9
12
 
10
13
  ## Overview
11
14
 
12
- The __Devise Secure Password Extension__ is composed of the following modules:
15
+ It's composed of the following modules:
13
16
 
14
- - __password_has_required_content__: require that passwords consist of a specific number (configurable) of letters,
17
+ * __password_has_required_content__: require that passwords consist of a specific number (configurable) of letters,
15
18
  numbers, and special characters (symbols)
16
- - __password_disallows_frequent_reuse__: prevent the reuse of a number (configurable) of previous passwords when a user
19
+ * __password_disallows_frequent_reuse__: prevent the reuse of a number (configurable) of previous passwords when a user
17
20
  changes their password
18
- - __password_disallows_frequent_changes__: prevent the user from changing their password more than once within a time
21
+ * __password_disallows_frequent_changes__: prevent the user from changing their password more than once within a time
19
22
  duration (configurable)
20
- - __password_requires_regular_updates__: require that a user change their password following a time duration
23
+ * __password_requires_regular_updates__: require that a user change their password following a time duration
21
24
  (configurable)
22
25
 
23
26
  ## Compatibility
24
27
 
25
- The goal of this project is to provide compatibility for officially supported stable releases of [Ruby](https://www.ruby-lang.org/en/downloads/)
26
- and [Ruby on Rails](http://guides.rubyonrails.org/maintenance_policy.html). More specifically, the following releases
27
- are currently supported by the __Devise Secure Password Extension__:
28
-
29
- - Ruby on Rails: __7.0.x__, __8.0.x__
30
- - Ruby: __3.2.x__, __3.3.x__, __3.4.x__
31
-
32
- ### Updating to a New Rails Version
33
-
34
- This gem uses so-called "dummy" apps in the specs to verify compatibility with a major/minor version of Rails. Adding a new major/minor version of Rails requires us to add a new "dummy" app in the spec folder, and a corresponding Gemfile in the gemfiles directory. While manual, this process is relatively straightforward:
35
-
36
- 1. Create a new Rails app in the directory `spec/rails_<major>_<minor>` by using the Rails generator for that version, ensuring you skip Git setup. (e.g. `cd spec; rails _7.2.2.2_ new rails-app-7_0 --skip-git`)
37
- 2. Move the Gemfile from the newly created app to the `gemfiles` directory and rename it with the major/minor version (e.g. `mv spec/rails_7_0/Gemfile gemfiles/rails_7_0.gemfile`)
38
- 3. Update the Gemfile to include the Rails target and gemspec immediately beneath the source declarations, like this:
39
-
40
- ```ruby
41
- source 'https://rubygems.org'
42
- git_source(:github) { |repo| "https://github.com/#{repo}.git" }
43
-
44
- ENV['RAILS_TARGET'] ||= '7.0'
45
-
46
- gemspec path: '../'
47
- ```
28
+ We provide compatibility for officially and recent stable releases of [Ruby](https://www.ruby-lang.org/en/downloads/)
29
+ and [Ruby on Rails](http://guides.rubyonrails.org/maintenance_policy.html).
48
30
 
49
- 4. Add `gem 'shoulda-matchers'` under the test group in the new Gemfile
50
- 5. Ensure you can bundle by running `bundle` with the `BUNDLE_GEMFILE` variable set to the new Gemfile (i.e. `BUNDLE_GEMFILE=gemfiles/rails_7_0.gemfile bundle`). This should run successfully - fix as needed.
51
- 6. Copy the file `config/initializers/devise.rb` from an existing "dummy" app to the same location in the new app.
52
- 7. Copy the file `config/routes.rb` from an existing "dummy" app to the same location in the new app.
53
- 8. Copy the contents of the `db/migrate` directory from an existing "dummy" app to the same location in the new app. Copy the `db/schema.rb` and `db/test.sqlite3` as well
54
- 9. Copy the `app/controllers/static_pages_controller.rb` from an existing "dummy" app to the same location in the new app.
55
- 10. Copy the `app/models/isolated` directory and the `app/models/user.rb` file from an existing "dummy" app to the same location in the new app.
56
- 11. Copy the `app/views/static_pages` directory from an existing "dummy" app to the same location in the new app.
57
- 12. Update the `app/views/layouts/application.html.erb` in the new app to have the same `<body>` content and `<title>` as the same file in an existing "dummy" app.
58
- 13. At this point you should be able to run specs. (i.e. `BUNDLE_GEMFILE=gemfiles/rails_6_1.gemfile bundle exec rake`). Run specs and fix version specific issues, taking care to maintain backwards compatibility with supported versions.
59
- 14. You should also run Rubocop (i.e. `BUNDLE_GEMFILE=gemfiles/rails_7_0.gemfile bundle exec rubocop`) and fix whatever issues are reported (again, maintaining backwards compatibility)
60
- 15. In the `.circleci/config.yml` file update the `current_rails_gemfile` and `previous_rails_gemfile` to reference the new version and the previous version of Rails to be supported
61
- 16. Delete any files for old Rails versions that are no longer supported - "dummy" apps and the corresponding `gemfiles` Gemfile.
62
- 17. Update the Circle CI badge label in this README to reflect the newly supported Rails version.
31
+ Following releases are currently supported:
63
32
 
33
+ - Ruby on Rails: __8.0.x__, __7.0.x__
34
+ - Ruby: __3.4.x__, __3.3.x__, __3.2.x__ (minimal ruby version required)
64
35
 
65
36
  ## Installation
66
37
 
67
38
  Add this line to your application's Gemfile:
68
39
 
69
40
  ```ruby
70
- gem 'devise', '~> 4.8'
71
- gem 'devise-secure_password', '~> 2.0'
41
+ gem 'devise', '~> 4.9'
42
+ gem 'devise-secure_password', '~> 2.2'
72
43
  ```
73
44
 
74
45
  And then execute:
75
46
 
76
- ```shell
77
- prompt> bundle
47
+ ```bash
48
+ bundle install
78
49
  ```
79
50
 
80
51
  Or install it yourself as:
81
52
 
82
- ```shell
83
- prompt> gem install devise-secure_password
53
+ ```bash
54
+ gem install devise-secure_password
84
55
  ```
85
56
 
86
57
  Finally, run the generator:
87
58
 
88
- ```shell
89
- prompt> rails generate devise:secure_password:install
59
+ ```bash
60
+ rails generate devise:secure_password:install
90
61
  ```
91
62
 
92
63
  ## Usage
93
64
 
94
65
  ### Configuration
95
66
 
96
- The __Devise Secure Password Extension__ exposes configuration parameters as outlined below. Commented out configuration
67
+ The extension exposes configuration parameters as outlined below. Commented out configuration
97
68
  parameters reflect the default settings.
98
69
 
99
70
  ```ruby
@@ -175,15 +146,15 @@ previous passwords memorization implemented by the `:password_disallows_frequent
175
146
 
176
147
  The following database migration needs to be applied:
177
148
 
178
- ```shell
179
- prompt> rails generate migration create_previous_passwords salt:string encrypted_password:string user:references
149
+ ```bash
150
+ rails generate migration create_previous_passwords salt:string encrypted_password:string user:references
180
151
  ```
181
152
 
182
- Edit the resulting file to disallow null values for the hash,add indexes for both hash and user_id fields, and to also
153
+ Edit the resulting file to disallow null values for the hash, add indexes for both hash and user_id fields, and to also
183
154
  add the timestamp (created_at, updated_at) fields:
184
155
 
185
156
  ```ruby
186
- class CreatePreviousPasswords < ActiveRecord::Migration[7.0]
157
+ class CreatePreviousPasswords < ActiveRecord::Migration[8.0]
187
158
  def change
188
159
  create_table :previous_passwords do |t|
189
160
  t.string :salt, null: false
@@ -202,8 +173,8 @@ end
202
173
 
203
174
  And then:
204
175
 
205
- ```shell
206
- prompt> bundle exec rake db:migrate
176
+ ```bash
177
+ bundle exec rake db:migrate
207
178
  ```
208
179
 
209
180
  ### Displaying errors
@@ -231,6 +202,28 @@ and is taken from the default password `edit.html.erb` page:
231
202
  <% end %>
232
203
  ```
233
204
 
205
+ ## Contributing
206
+
207
+ Bug reports and pull requests are welcome on GitHub at https://github.com/valimail/devise-secure_password. This project
208
+ is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
209
+ [Contributor Covenant](http://contributor-covenant.org) code of conduct.
210
+
211
+ ### Basic guidelines for contributors
212
+
213
+ 1. Fork it
214
+
215
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
216
+
217
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
218
+
219
+ 4. Push to the branch (`git push origin my-new-feature`)
220
+
221
+ 5. Create new Pull Request
222
+
223
+ >NOTE: Contributions should always be based on the `main` branch. You may be asked to [rebase](https://git-scm.com/docs/git-rebase)
224
+ your contributions on the tip of the `main` branch, this is normal and is to be expected if the `main` branch has
225
+ moved ahead since your pull request was opened, discussed, and accepted.
226
+
234
227
  <a name="running-tests"></a>
235
228
 
236
229
  ## Running Tests
@@ -239,12 +232,11 @@ This document assumes that you already have a [functioning ruby install](https:/
239
232
 
240
233
  ### Default Rails target
241
234
 
242
- The __Devise Secure Password Extension__ provides compatibility for officially supported stable releases of Ruby on
243
- Rails. To configure and test the default target (the most-recent supported Rails release):
235
+ To configure and test the default target (the most-recent supported Rails release):
244
236
 
245
237
  ```bash
246
- prompt> bundle
247
- prompt> bundle exec rake
238
+ bundle
239
+ bundle exec rake
248
240
  ```
249
241
 
250
242
  ### Selecting an alternate Rails target
@@ -252,17 +244,19 @@ prompt> bundle exec rake
252
244
  To determine the Ruby on Rails versions supported by this release, run the following commands:
253
245
 
254
246
  ```bash
255
- prompt> gem install flay ruby2ruby rubocop rspec
256
- prompt> rake test:spec:targets
247
+ gem install flay ruby2ruby rubocop rspec
248
+ rake test:spec:targets
257
249
 
258
- Available Rails targets: 7.0, 8.0
250
+ Available Rails targets: 8.0, 7.0
259
251
  ```
260
252
 
253
+ For additional Rails versions support, please follow this [guideline](https://github.com/valimail/devise-secure_password/blob/main/docs/upgrading_to_new_rails_version.md)
254
+
261
255
  Reconfigure the project by specifying the correct Gemfile when running bundler, followed by running tests:
262
256
 
263
257
  ```bash
264
- prompt> BUNDLE_GEMFILE=gemfiles/rails_7_0.gemfile bundle
265
- prompt> BUNDLE_GEMFILE=gemfiles/rails_7_0.gemfile bundle exec rake
258
+ BUNDLE_GEMFILE=gemfiles/rails_7_0.gemfile bundle
259
+ BUNDLE_GEMFILE=gemfiles/rails_7_0.gemfile bundle exec rake
266
260
  ```
267
261
 
268
262
  The only time you need to define the `BUNDLE_GEMFILE` environment variable is when testing a non-default target.
@@ -272,7 +266,7 @@ The only time you need to define the `BUNDLE_GEMFILE` environment variable is wh
272
266
  SimpleCov tests are enabled by defining the `test:spec:coverage` rake task:
273
267
 
274
268
  ```bash
275
- prompt> bundle exec rake test:spec:coverage
269
+ bundle exec rake test:spec:coverage
276
270
  ```
277
271
 
278
272
  A brief summary will be output at the end of the run but a more extensive eport will be saved in the `coverage`
@@ -284,7 +278,7 @@ You will need to install the [ChromeDriver >= v2.3.4](https://sites.google.com/a
284
278
  for testing.
285
279
 
286
280
  ```bash
287
- prompt> brew install chromedriver
281
+ brew install chromedriver
288
282
  ```
289
283
 
290
284
  You can always install [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) by downloading and then
@@ -310,9 +304,9 @@ To debug from inside of the dummy rails-app you will need to first install the r
310
304
  migration:
311
305
 
312
306
  ```bash
313
- prompt> cd spec/rails-app-X_y_z
314
- prompt> rake app:update:bin
315
- prompt> RAILS_ENV=development bundle exec rake db:migrate
307
+ cd spec/rails-app-X_y_z
308
+ rake app:update:bin
309
+ RAILS_ENV=development bundle exec rake db:migrate
316
310
  ```
317
311
 
318
312
  Remember, the dummy app is not meant to be a full featured rails app: there is just enough functionality to test the
@@ -323,7 +317,7 @@ gem feature set.
323
317
  Available benchmarks can be run as follows:
324
318
 
325
319
  ```bash
326
- prompt> bundle exec rake test:benchmark
320
+ bundle exec rake test:benchmark
327
321
  ```
328
322
 
329
323
  Benchmarks are run within an RSpec context but are not run along with other tests as benchmarks merely seek to measure
@@ -346,8 +340,8 @@ using [Docker](https://www.docker.com/).
346
340
  To start the container simply build and launch the image:
347
341
 
348
342
  ```bash
349
- prompt> docker build -t secure-password-dev .
350
- prompt> docker run -it --rm secure-password-dev /bin/bash
343
+ docker build -t secure-password-dev .
344
+ docker run -it --rm secure-password-dev /bin/bash
351
345
  ```
352
346
 
353
347
  The above `docker run` command will start the container, connect you to the command line within the project home
@@ -356,12 +350,12 @@ the shell, the container will be removed.
356
350
 
357
351
  ### Running tests in a Docker container
358
352
 
359
- The Docker container is derived from the latest [circleci/ruby](https://hub.docker.com/r/circleci/ruby/) image. It is
353
+ The Docker container is derived from the latest [cimg/ruby](https://circleci.com/developer/images/image/cimg/ruby) image. It is
360
354
  critical that you update the bundler inside of the Docker image as the `circleci` user (i.e. the default user) before
361
355
  initiating any development work including tests.
362
356
 
363
357
  ```bash
364
- prompt> gem update bundler
358
+ gem update bundler
365
359
  ```
366
360
 
367
361
  #### Updating test.sqlite3.db
@@ -369,34 +363,12 @@ prompt> gem update bundler
369
363
  To update or generate a `db/test/sqlite3.db` database file:
370
364
 
371
365
  ```bash
372
- prompt> cd spec/rails-app-X_y_z
373
- prompt> bundle install
374
- prompt> rake app:update:bin
375
- prompt> RAILS_ENV=test bundle exec rake db:migrate
366
+ cd spec/rails-app-X_y_z
367
+ bundle install
368
+ rake app:update:bin
369
+ RAILS_ENV=test bundle exec rake db:migrate
376
370
  ```
377
371
 
378
- ## Contributing
379
-
380
- Bug reports and pull requests are welcome on GitHub at https://github.com/valimail/devise-secure_password. This project
381
- is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the
382
- [Contributor Covenant](http://contributor-covenant.org) code of conduct.
383
-
384
- ### Basic guidelines for contributors
385
-
386
- 1 Fork it
387
-
388
- 2 Create your feature branch (`git checkout -b my-new-feature`)
389
-
390
- 3 Commit your changes (`git commit -am 'Add some feature'`)
391
-
392
- 4 Push to the branch (`git push origin my-new-feature`)
393
-
394
- 5 Create new Pull Request
395
-
396
- >NOTE: Contributions should always be based on the `master` branch. You may be asked to [rebase](https://git-scm.com/docs/git-rebase)
397
- your contributions on the tip of the `master` branch, this is normal and is to be expected if the `master` branch has
398
- moved ahead since your pull request was opened, discussed, and accepted.
399
-
400
372
  ## License
401
373
 
402
374
  The __Devise Secure Password Extension__ gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -404,4 +376,4 @@ The __Devise Secure Password Extension__ gem is available as open source under t
404
376
  ## Code of Conduct
405
377
 
406
378
  Everyone interacting in the __Devise Secure Password Extension__ project’s codebases and issue trackers is expected to
407
- follow the [code of conduct](https://github.com/valimail/devise-secure_password/blob/master/CODE_OF_CONDUCT.md).
379
+ follow the [code of conduct](https://github.com/valimail/devise-secure_password/blob/main/CODE_OF_CONDUCT.md).
@@ -22,11 +22,11 @@ en:
22
22
  password_disallows_frequent_reuse:
23
23
  errors:
24
24
  messages:
25
- password_is_recent: "Last %{count} passwords may not be reused"
25
+ password_is_recent: "must not be reused from the last %{count} passwords."
26
26
  password_disallows_frequent_changes:
27
27
  errors:
28
28
  messages:
29
- password_is_recent: "Password cannot be changed more than once per %{timeframe}"
29
+ password_is_recent: "cannot be changed more than once per %{timeframe}"
30
30
  password_requires_regular_updates:
31
31
  alerts:
32
32
  messages:
Binary file
@@ -12,8 +12,8 @@ Gem::Specification.new do |spec|
12
12
  spec.version = Devise::SecurePassword::VERSION.dup
13
13
  spec.platform = Gem::Platform::RUBY
14
14
 
15
- spec.authors = ['Mark Eissler']
16
- spec.email = ['mark.eissler@valimail.com']
15
+ spec.authors = ['Valimail Engineering']
16
+ spec.email = ['engineering@valimail.com']
17
17
 
18
18
  spec.summary = 'A devise password policy enforcement extension.'
19
19
  spec.description = 'Adds configurable password policy enforcement to devise.'
Binary file
@@ -0,0 +1,46 @@
1
+ ### Upgrading to a New Rails Version
2
+
3
+ This gem uses so-called "dummy" apps in the specs to verify compatibility with a major/minor version of Rails. Adding a new major/minor version of Rails requires us to add a new "dummy" app in the spec folder, and a corresponding Gemfile in the gemfiles directory. While manual, this process is relatively straightforward:
4
+
5
+ 1. Create a new Rails app in the directory `spec/rails_<major>_<minor>` by using the Rails generator for that version, ensuring you skip Git setup. (e.g. `cd spec; rails _7.2.2.2_ new rails-app-7_0 --skip-git`)
6
+
7
+ 2. Move the Gemfile from the newly created app to the `gemfiles` directory and rename it with the major/minor version (e.g. `mv spec/rails_7_0/Gemfile gemfiles/rails_7_0.gemfile`)
8
+
9
+ 3. Update the Gemfile to include the Rails target and gemspec immediately beneath the source declarations, like this:
10
+
11
+ ```ruby
12
+ source 'https://rubygems.org'
13
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
14
+
15
+ ENV['RAILS_TARGET'] ||= '7.0'
16
+
17
+ gemspec path: '../'
18
+ ```
19
+
20
+ 4. Add `gem 'shoulda-matchers'` under the test group in the new Gemfile
21
+
22
+ 5. Ensure you can bundle by running `bundle` with the `BUNDLE_GEMFILE` variable set to the new Gemfile (i.e. `BUNDLE_GEMFILE=gemfiles/rails_7_0.gemfile bundle`). This should run successfully - fix as needed.
23
+
24
+ 6. Copy the file `config/initializers/devise.rb` from an existing "dummy" app to the same location in the new app.
25
+
26
+ 7. Copy the file `config/routes.rb` from an existing "dummy" app to the same location in the new app.
27
+
28
+ 8. Copy the contents of the `db/migrate` directory from an existing "dummy" app to the same location in the new app. Copy the `db/schema.rb` and `db/test.sqlite3` as well
29
+
30
+ 9. Copy the `app/controllers/static_pages_controller.rb` from an existing "dummy" app to the same location in the new app.
31
+
32
+ 10. Copy the `app/models/isolated` directory and the `app/models/user.rb` file from an existing "dummy" app to the same location in the new app.
33
+
34
+ 11. Copy the `app/views/static_pages` directory from an existing "dummy" app to the same location in the new app.
35
+
36
+ 12. Update the `app/views/layouts/application.html.erb` in the new app to have the same `<body>` content and `<title>` as the same file in an existing "dummy" app.
37
+
38
+ 13. At this point you should be able to run specs. (i.e. `BUNDLE_GEMFILE=gemfiles/rails_6_1.gemfile bundle exec rake`). Run specs and fix version specific issues, taking care to maintain backwards compatibility with supported versions.
39
+
40
+ 14. You should also run Rubocop (i.e. `BUNDLE_GEMFILE=gemfiles/rails_7_0.gemfile bundle exec rubocop`) and fix whatever issues are reported (again, maintaining backwards compatibility)
41
+
42
+ 15. In the `.circleci/config.yml` file update the `current_rails_gemfile` and `previous_rails_gemfile` to reference the new version and the previous version of Rails to be supported
43
+
44
+ 16. Delete any files for old Rails versions that are no longer supported - "dummy" apps and the corresponding `gemfiles` Gemfile.
45
+
46
+ 17. Update the Circle CI badge label in this README to reflect the newly supported Rails version.