devise-security 0.14.2 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +125 -59
  3. data/app/controllers/devise/paranoid_verification_code_controller.rb +13 -1
  4. data/app/controllers/devise/password_expired_controller.rb +24 -6
  5. data/app/views/devise/paranoid_verification_code/show.html.erb +3 -3
  6. data/app/views/devise/password_expired/show.html.erb +5 -5
  7. data/config/locales/bg.yml +41 -0
  8. data/config/locales/by.yml +49 -0
  9. data/config/locales/cs.yml +41 -0
  10. data/config/locales/de.yml +15 -2
  11. data/config/locales/en.yml +15 -2
  12. data/config/locales/es.yml +10 -9
  13. data/config/locales/fa.yml +41 -0
  14. data/config/locales/fr.yml +1 -0
  15. data/config/locales/hi.yml +42 -0
  16. data/config/locales/it.yml +35 -4
  17. data/config/locales/ja.yml +2 -1
  18. data/config/locales/nl.yml +41 -0
  19. data/config/locales/pt.yml +41 -0
  20. data/config/locales/ru.yml +49 -0
  21. data/config/locales/tr.yml +1 -0
  22. data/config/locales/uk.yml +49 -0
  23. data/config/locales/zh_CN.yml +41 -0
  24. data/config/locales/zh_TW.yml +41 -0
  25. data/lib/devise-security/controllers/helpers.rb +59 -50
  26. data/lib/devise-security/hooks/password_expirable.rb +2 -0
  27. data/lib/devise-security/hooks/session_limitable.rb +21 -11
  28. data/lib/devise-security/models/database_authenticatable_patch.rb +15 -5
  29. data/lib/devise-security/models/password_archivable.rb +2 -2
  30. data/lib/devise-security/models/password_expirable.rb +5 -1
  31. data/lib/devise-security/models/secure_validatable.rb +56 -6
  32. data/lib/devise-security/models/session_limitable.rb +10 -1
  33. data/lib/devise-security/validators/password_complexity_validator.rb +53 -24
  34. data/lib/devise-security/version.rb +1 -1
  35. data/lib/devise-security.rb +13 -5
  36. data/lib/generators/devise_security/install_generator.rb +3 -3
  37. data/lib/generators/templates/{devise-security.rb → devise_security.rb} +6 -1
  38. data/test/controllers/test_paranoid_verification_code_controller.rb +68 -0
  39. data/test/controllers/test_password_expired_controller.rb +121 -19
  40. data/test/controllers/test_security_question_controller.rb +16 -40
  41. data/test/dummy/app/assets/config/manifest.js +3 -0
  42. data/test/dummy/app/controllers/overrides/paranoid_verification_code_controller.rb +7 -0
  43. data/test/dummy/app/controllers/overrides/password_expired_controller.rb +7 -0
  44. data/test/dummy/app/controllers/widgets_controller.rb +3 -0
  45. data/test/dummy/app/models/application_user_record.rb +2 -1
  46. data/test/dummy/app/models/mongoid/confirmable_fields.rb +2 -0
  47. data/test/dummy/app/models/mongoid/database_authenticable_fields.rb +4 -3
  48. data/test/dummy/app/models/mongoid/expirable_fields.rb +2 -0
  49. data/test/dummy/app/models/mongoid/lockable_fields.rb +2 -0
  50. data/test/dummy/app/models/mongoid/mappings.rb +4 -2
  51. data/test/dummy/app/models/mongoid/omniauthable_fields.rb +2 -0
  52. data/test/dummy/app/models/mongoid/paranoid_verification_fields.rb +2 -0
  53. data/test/dummy/app/models/mongoid/password_archivable_fields.rb +2 -0
  54. data/test/dummy/app/models/mongoid/password_expirable_fields.rb +2 -0
  55. data/test/dummy/app/models/mongoid/recoverable_fields.rb +2 -0
  56. data/test/dummy/app/models/mongoid/registerable_fields.rb +4 -2
  57. data/test/dummy/app/models/mongoid/rememberable_fields.rb +2 -0
  58. data/test/dummy/app/models/mongoid/secure_validatable_fields.rb +2 -0
  59. data/test/dummy/app/models/mongoid/security_questionable_fields.rb +2 -0
  60. data/test/dummy/app/models/mongoid/session_limitable_fields.rb +2 -0
  61. data/test/dummy/app/models/mongoid/timeoutable_fields.rb +2 -0
  62. data/test/dummy/app/models/mongoid/trackable_fields.rb +2 -0
  63. data/test/dummy/app/models/mongoid/validatable_fields.rb +2 -0
  64. data/test/dummy/app/models/paranoid_verification_user.rb +26 -0
  65. data/test/dummy/app/models/password_expired_user.rb +26 -0
  66. data/test/dummy/app/models/user.rb +1 -2
  67. data/test/dummy/app/models/widget.rb +1 -3
  68. data/test/dummy/app/mongoid/one_user.rb +5 -5
  69. data/test/dummy/app/mongoid/user_on_engine.rb +2 -2
  70. data/test/dummy/app/mongoid/user_on_main_app.rb +2 -2
  71. data/test/dummy/app/mongoid/user_with_validations.rb +3 -3
  72. data/test/dummy/app/mongoid/user_without_email.rb +3 -3
  73. data/test/dummy/config/application.rb +4 -4
  74. data/test/dummy/config/boot.rb +1 -1
  75. data/test/dummy/config/environment.rb +1 -1
  76. data/test/dummy/config/environments/test.rb +3 -13
  77. data/test/dummy/config/initializers/migration_class.rb +1 -8
  78. data/test/dummy/config/locales/en.yml +10 -0
  79. data/test/dummy/config/mongoid.yml +1 -1
  80. data/test/dummy/config/routes.rb +5 -3
  81. data/test/dummy/db/migrate/20120508165529_create_tables.rb +3 -3
  82. data/test/dummy/lib/shared_expirable_columns.rb +1 -0
  83. data/test/dummy/lib/shared_security_questions_fields.rb +1 -0
  84. data/test/dummy/lib/shared_user.rb +17 -6
  85. data/test/dummy/lib/shared_user_without_email.rb +2 -1
  86. data/test/dummy/lib/shared_user_without_omniauth.rb +12 -3
  87. data/test/dummy/lib/shared_verification_fields.rb +1 -0
  88. data/test/dummy/{app/models/.gitkeep → log/development.log} +0 -0
  89. data/test/dummy/log/test.log +101533 -0
  90. data/test/integration/test_password_expirable_workflow.rb +53 -0
  91. data/test/integration/test_session_limitable_workflow.rb +2 -0
  92. data/test/orm/active_record.rb +7 -4
  93. data/test/orm/mongoid.rb +2 -1
  94. data/test/support/integration_helpers.rb +15 -33
  95. data/test/support/mongoid.yml +1 -1
  96. data/test/test_compatibility.rb +2 -0
  97. data/test/test_complexity_validator.rb +250 -29
  98. data/test/test_database_authenticatable_patch.rb +146 -0
  99. data/test/test_helper.rb +12 -6
  100. data/test/test_install_generator.rb +12 -2
  101. data/test/test_paranoid_verification.rb +0 -1
  102. data/test/test_password_archivable.rb +34 -11
  103. data/test/test_password_expirable.rb +26 -26
  104. data/test/test_secure_validatable.rb +292 -50
  105. data/test/test_secure_validatable_overrides.rb +185 -0
  106. data/test/test_session_limitable.rb +27 -1
  107. data/test/tmp/config/initializers/devise_security.rb +49 -0
  108. data/test/tmp/config/locales/devise.security_extension.by.yml +49 -0
  109. data/test/tmp/config/locales/devise.security_extension.cs.yml +41 -0
  110. data/test/tmp/config/locales/devise.security_extension.de.yml +41 -0
  111. data/test/tmp/config/locales/devise.security_extension.en.yml +42 -0
  112. data/test/tmp/config/locales/devise.security_extension.es.yml +30 -0
  113. data/test/tmp/config/locales/devise.security_extension.fa.yml +41 -0
  114. data/test/tmp/config/locales/devise.security_extension.fr.yml +30 -0
  115. data/test/tmp/config/locales/devise.security_extension.hi.yml +42 -0
  116. data/test/tmp/config/locales/devise.security_extension.it.yml +41 -0
  117. data/test/tmp/config/locales/devise.security_extension.ja.yml +30 -0
  118. data/test/tmp/config/locales/devise.security_extension.nl.yml +41 -0
  119. data/test/tmp/config/locales/devise.security_extension.pt.yml +41 -0
  120. data/test/tmp/config/locales/devise.security_extension.ru.yml +49 -0
  121. data/test/tmp/config/locales/devise.security_extension.tr.yml +18 -0
  122. data/test/tmp/config/locales/devise.security_extension.uk.yml +49 -0
  123. data/test/tmp/config/locales/devise.security_extension.zh_CN.yml +41 -0
  124. data/test/tmp/config/locales/devise.security_extension.zh_TW.yml +41 -0
  125. metadata +168 -132
  126. data/.codeclimate.yml +0 -63
  127. data/.document +0 -5
  128. data/.gitignore +0 -43
  129. data/.mdlrc +0 -1
  130. data/.rubocop.yml +0 -64
  131. data/.ruby-version +0 -1
  132. data/.travis.yml +0 -39
  133. data/Appraisals +0 -35
  134. data/Gemfile +0 -10
  135. data/Rakefile +0 -27
  136. data/devise-security.gemspec +0 -50
  137. data/gemfiles/rails_4.2_stable.gemfile +0 -16
  138. data/gemfiles/rails_5.0_stable.gemfile +0 -15
  139. data/gemfiles/rails_5.1_stable.gemfile +0 -15
  140. data/gemfiles/rails_5.2_stable.gemfile +0 -15
  141. data/gemfiles/rails_6.0_beta.gemfile +0 -15
  142. data/lib/devise-security/orm/active_record.rb +0 -20
  143. data/lib/devise-security/schema.rb +0 -66
  144. data/test/dummy/app/models/secure_user.rb +0 -9
data/.rubocop.yml DELETED
@@ -1,64 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.4
3
- Include:
4
- - '**/Rakefile'
5
- - '**/config.ru'
6
- - 'lib/tasks/**/*'
7
- Exclude:
8
- - Gemfile*
9
- - README
10
- - 'db/**/*'
11
- - 'config/**/*'
12
- - 'bin/**/*'
13
- - 'vendor/bundle/**/*'
14
- - 'spec/support/**/*' # rspec support helpers have a strange api
15
-
16
- Rails:
17
- Enabled: true
18
-
19
- # We don't care about method length, since we check method cyclomatic
20
- # complexity.
21
- Metrics/MethodLength:
22
- Enabled: false
23
-
24
- Metrics/LineLength:
25
- Enabled: false
26
-
27
- Naming/FileName:
28
- Exclude: ["devise-security.gemspec"]
29
-
30
- Style/ClassAndModuleChildren:
31
- EnforcedStyle: compact
32
- SupportedStyles:
33
- - nested
34
- - compact
35
-
36
- Style/HashSyntax:
37
- EnforcedStyle: ruby19
38
-
39
- Style/SymbolArray:
40
- EnforcedStyle: brackets
41
-
42
- # Trailing commas make for clearer diffs because the last line won't appear
43
- # to have been changed, as it would if it lacked a comma and had one added.
44
- Style/TrailingCommaInArrayLiteral:
45
- EnforcedStyleForMultiline: comma
46
- Style/TrailingCommaInHashLiteral:
47
- EnforcedStyleForMultiline: comma
48
- Style/TrailingCommaInArguments:
49
- EnforcedStyleForMultiline: comma
50
-
51
- # Cop supports --auto-correct.
52
- # Configuration parameters: PreferredDelimiters.
53
- Style/PercentLiteralDelimiters:
54
- PreferredDelimiters:
55
- # Using `[]` for string arrays instead of `()`, since normal arrays are
56
- # indicated with `[]` not `()`.
57
- '%w': '[]'
58
- '%W': '[]'
59
-
60
- Style/AndOr:
61
- # Whether `and` and `or` are banned only in conditionals (conditionals)
62
- # or completely (always).
63
- # They read better, more like normal English.
64
- Enabled: false
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.4.6
data/.travis.yml DELETED
@@ -1,39 +0,0 @@
1
- language: ruby
2
- dist: xenial
3
- before_install:
4
- # install bundler < 2 because Rails 4.2 is incompatible with bundler >= 2
5
- - gem install bundler -v '1.17.3'
6
- install: bundle _1.17.3_ install --jobs=2 --retry=2 --path=${BUNDLE_PATH:-vendor/bundle}
7
- cache: bundler
8
- script: bundle exec rake
9
- rvm:
10
- - 2.4
11
- - 2.5
12
- - 2.6
13
- - ruby-head
14
- env:
15
- matrix:
16
- - DEVISE_ORM=active_record
17
- - DEVISE_ORM=mongoid
18
- services:
19
- - mongodb
20
- matrix:
21
- exclude:
22
- # Skip these combinations because they have incompatible dependencies
23
- # and will always fail.
24
- - rvm: 2.6
25
- gemfile: gemfiles/rails_4.2_stable.gemfile
26
- - rvm: ruby-head
27
- gemfile: gemfiles/rails_4.2_stable.gemfile
28
- - rvm: 2.4
29
- gemfile: gemfiles/rails_6.0_beta.gemfile
30
- allow_failures:
31
- # edge, not expected to pass
32
- - rvm: ruby-head
33
- - gemfile: gemfiles/rails_6.0_beta.gemfile
34
- gemfile:
35
- - gemfiles/rails_4.2_stable.gemfile
36
- - gemfiles/rails_5.0_stable.gemfile
37
- - gemfiles/rails_5.1_stable.gemfile
38
- - gemfiles/rails_5.2_stable.gemfile
39
- - gemfiles/rails_6.0_beta.gemfile
data/Appraisals DELETED
@@ -1,35 +0,0 @@
1
- appraise 'rails-4.2-stable' do
2
- gem 'rails', '~> 4.2.0'
3
- gem 'bundler', '< 2'
4
- group :mongoid do
5
- gem "mongoid", "~> 4.0"
6
- end
7
- end
8
-
9
- appraise 'rails-5.0-stable' do
10
- gem 'rails', '~> 5.0.0'
11
- group :mongoid do
12
- gem "mongoid", "~> 6.0"
13
- end
14
- end
15
-
16
- appraise 'rails-5.1-stable' do
17
- gem 'rails', '~> 5.1.0'
18
- group :mongoid do
19
- gem "mongoid", "~> 6.0"
20
- end
21
- end
22
-
23
- appraise 'rails-5.2-stable' do
24
- gem 'rails', '~> 5.2.0'
25
- group :mongoid do
26
- gem "mongoid", "~> 6.0"
27
- end
28
- end
29
-
30
- appraise 'rails-6.0-beta' do
31
- gem 'rails', '~> 6.0.0.beta3'
32
- group :mongoid do
33
- gem "mongoid", "~> 6.0"
34
- end
35
- end
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- source "https://rubygems.org"
2
- gemspec
3
-
4
- group :active_record do
5
- gem 'sqlite3', '~> 1.3.0'
6
- end
7
-
8
- group :mongoid do
9
- gem 'mongoid'
10
- end
data/Rakefile DELETED
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
4
- require 'bundler/gem_tasks'
5
- require 'rake/testtask'
6
- require 'rdoc/task'
7
- require 'devise-security/version'
8
-
9
- desc 'Default: Run DeviseSecurity unit tests'
10
- task default: :test
11
-
12
- Rake::TestTask.new(:test) do |t|
13
- t.libs << 'lib'
14
- t.libs << 'test'
15
- t.test_files = FileList['test/*test*.rb', 'test/**/*test*.rb']
16
- t.verbose = true
17
- t.warning = false
18
- end
19
-
20
- Rake::RDocTask.new do |rdoc|
21
- version = DeviseSecurity::VERSION.dup
22
-
23
- rdoc.rdoc_dir = 'rdoc'
24
- rdoc.title = "devise-security #{version}"
25
- rdoc.rdoc_files.include('README*')
26
- rdoc.rdoc_files.include('lib/**/*.rb')
27
- end
@@ -1,50 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- # frozen_string_literal: true
3
-
4
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
5
- require 'devise-security/version'
6
-
7
- Gem::Specification.new do |s|
8
- s.name = 'devise-security'
9
- s.version = DeviseSecurity::VERSION.dup
10
- s.platform = Gem::Platform::RUBY
11
- s.licenses = ['MIT']
12
- s.summary = 'Security extension for devise'
13
- s.email = 'natebird@gmail.com'
14
- s.homepage = 'https://github.com/devise-security/devise-security'
15
- s.description = 'An enterprise security extension for devise.'
16
- s.authors = [
17
- 'Marco Scholl',
18
- 'Alexander Dreher',
19
- 'Nate Bird',
20
- 'Dillon Welch',
21
- 'Kevin Olbrich'
22
- ]
23
-
24
- s.files = `git ls-files`.split("\n")
25
- s.test_files = `git ls-files -- test/*`.split("\n")
26
- s.require_paths = ['lib']
27
- s.required_ruby_version = '>= 2.3.0'
28
-
29
- if RUBY_VERSION >= '2.4'
30
- s.add_runtime_dependency 'rails', '>= 4.2.0', '< 7.0'
31
- else
32
- s.add_runtime_dependency 'railties', '>= 4.2.0', '< 6.0'
33
- end
34
- s.add_runtime_dependency 'devise', '>= 4.3.0', '< 5.0'
35
-
36
- s.add_development_dependency 'appraisal'
37
- s.add_development_dependency 'bundler'
38
- s.add_development_dependency 'coveralls'
39
- s.add_development_dependency 'database_cleaner'
40
- s.add_development_dependency 'easy_captcha'
41
- s.add_development_dependency 'm'
42
- s.add_development_dependency 'minitest'
43
- s.add_development_dependency 'omniauth'
44
- s.add_development_dependency 'pry-byebug'
45
- s.add_development_dependency 'pry-rescue'
46
- s.add_development_dependency 'rails_email_validator'
47
- s.add_development_dependency 'rubocop', '~> 0.66.0'
48
- s.add_development_dependency 'sqlite3'
49
- s.add_development_dependency 'wwtd'
50
- end
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.2.0"
6
- gem "bundler", "< 2"
7
-
8
- group :active_record do
9
- gem "sqlite3", "~> 1.3.0"
10
- end
11
-
12
- group :mongoid do
13
- gem "mongoid", "~> 4.0"
14
- end
15
-
16
- gemspec path: "../"
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.0.0"
6
-
7
- group :active_record do
8
- gem "sqlite3", "~> 1.3.0"
9
- end
10
-
11
- group :mongoid do
12
- gem "mongoid", "~> 6.0"
13
- end
14
-
15
- gemspec path: "../"
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.1.0"
6
-
7
- group :active_record do
8
- gem "sqlite3", "~> 1.3.0"
9
- end
10
-
11
- group :mongoid do
12
- gem "mongoid", "~> 6.0"
13
- end
14
-
15
- gemspec path: "../"
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.2.0"
6
-
7
- group :active_record do
8
- gem "sqlite3", "~> 1.3.0"
9
- end
10
-
11
- group :mongoid do
12
- gem "mongoid", "~> 6.0"
13
- end
14
-
15
- gemspec path: "../"
@@ -1,15 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 6.0.0.rc1"
6
-
7
- group :active_record do
8
- gem "sqlite3", "~> 1.3.0"
9
- end
10
-
11
- group :mongoid do
12
- gem "mongoid", "~> 6.0"
13
- end
14
-
15
- gemspec path: "../"
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DeviseSecurity
4
- module Orm
5
- # This module contains some helpers and handle schema (migrations):
6
- #
7
- # create_table :accounts do |t|
8
- # t.password_expirable
9
- # end
10
- #
11
- module ActiveRecord
12
- module Schema
13
- include DeviseSecurity::Schema
14
- end
15
- end
16
- end
17
- end
18
-
19
- ActiveRecord::ConnectionAdapters::Table.send :include, DeviseSecurity::Orm::ActiveRecord::Schema
20
- ActiveRecord::ConnectionAdapters::TableDefinition.send :include, DeviseSecurity::Orm::ActiveRecord::Schema
@@ -1,66 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DeviseSecurity
4
- # add schema helper for migrations
5
- module Schema
6
- # Add password_changed_at columns in the resource's database table.
7
- #
8
- # Examples
9
- #
10
- # # For a new resource migration:
11
- # create_table :the_resources do |t|
12
- # t.password_expirable
13
- # ...
14
- # end
15
- #
16
- # # or if the resource's table already exists, define a migration and put this in:
17
- # change_table :the_resources do |t|
18
- # t.datetime :password_changed_at
19
- # end
20
- #
21
- def password_expirable
22
- apply_devise_schema :password_changed_at, DateTime
23
- end
24
-
25
- # Add password_archivable columns
26
- #
27
- # Examples
28
- #
29
- # create_table :old_passwords do
30
- # t.password_archivable
31
- # end
32
- # add_index :old_passwords, [:password_archivable_type, :password_archivable_id], name: 'index_password_archivable'
33
- #
34
- def password_archivable
35
- apply_devise_schema :encrypted_password, String, limit: 128, null: false
36
- apply_devise_schema :password_salt, String
37
- apply_devise_schema :password_archivable_id, Integer, null: false
38
- apply_devise_schema :password_archivable_type, String, null: false
39
- apply_devise_schema :created_at, DateTime
40
- end
41
-
42
- # Add session_limitable columns in the resource's database table.
43
- #
44
- # Examples
45
- #
46
- # # For a new resource migration:
47
- # create_table :the_resources do |t|
48
- # t.session_limitable
49
- # ...
50
- # end
51
- #
52
- # # or if the resource's table already exists, define a migration and put this in:
53
- # change_table :the_resources do |t|
54
- # t.string :unique_session_id, limit: 20
55
- # end
56
- #
57
- def session_limitable
58
- apply_devise_schema :unique_session_id, String, limit: 20
59
- end
60
-
61
- def expirable
62
- apply_devise_schema :expired_at, DateTime
63
- apply_devise_schema :last_activity_at, DateTime
64
- end
65
- end
66
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class SecureUser < ApplicationUserRecord
4
- devise :database_authenticatable, :secure_validatable, email_validation: false
5
- if DEVISE_ORM == :mongoid
6
- require './test/dummy/app/models/mongoid/mappings'
7
- include ::Mongoid::Mappings
8
- end
9
- end