devise-security 0.14.1 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +3 -1
- data/README.md +136 -61
- data/app/controllers/devise/paranoid_verification_code_controller.rb +26 -12
- data/app/controllers/devise/password_expired_controller.rb +32 -10
- data/app/views/devise/paranoid_verification_code/show.html.erb +3 -3
- data/app/views/devise/password_expired/show.html.erb +5 -5
- data/config/locales/bg.yml +42 -0
- data/config/locales/by.yml +50 -0
- data/config/locales/cs.yml +46 -0
- data/config/locales/de.yml +16 -2
- data/config/locales/en.yml +15 -2
- data/config/locales/es.yml +22 -9
- data/config/locales/fa.yml +42 -0
- data/config/locales/fr.yml +15 -2
- data/config/locales/hi.yml +43 -0
- data/config/locales/it.yml +36 -4
- data/config/locales/ja.yml +14 -1
- data/config/locales/nl.yml +42 -0
- data/config/locales/pt.yml +42 -0
- data/config/locales/ru.yml +50 -0
- data/config/locales/tr.yml +26 -1
- data/config/locales/uk.yml +50 -0
- data/config/locales/zh_CN.yml +42 -0
- data/config/locales/zh_TW.yml +42 -0
- data/lib/devise-security/controllers/helpers.rb +72 -51
- data/lib/devise-security/hooks/expirable.rb +3 -3
- data/lib/devise-security/hooks/paranoid_verification.rb +1 -3
- data/lib/devise-security/hooks/password_expirable.rb +3 -3
- data/lib/devise-security/hooks/session_limitable.rb +29 -14
- data/lib/devise-security/models/compatibility/{active_record.rb → active_record_patch.rb} +14 -2
- data/lib/devise-security/models/compatibility/{mongoid.rb → mongoid_patch.rb} +12 -1
- data/lib/devise-security/models/compatibility.rb +2 -2
- data/lib/devise-security/models/database_authenticatable_patch.rb +18 -10
- data/lib/devise-security/models/expirable.rb +6 -5
- data/lib/devise-security/models/paranoid_verification.rb +2 -2
- data/lib/devise-security/models/password_archivable.rb +3 -3
- data/lib/devise-security/models/password_expirable.rb +5 -1
- data/lib/devise-security/models/secure_validatable.rb +62 -11
- data/lib/devise-security/models/session_limitable.rb +17 -2
- data/lib/devise-security/orm/mongoid.rb +1 -1
- data/lib/devise-security/patches.rb +14 -8
- data/lib/devise-security/routes.rb +2 -3
- data/lib/devise-security/validators/password_complexity_validator.rb +53 -24
- data/lib/devise-security/version.rb +1 -1
- data/lib/devise-security.rb +15 -6
- data/lib/generators/devise_security/install_generator.rb +4 -6
- data/lib/generators/templates/{devise-security.rb → devise_security.rb} +9 -1
- data/test/controllers/test_paranoid_verification_code_controller.rb +133 -0
- data/test/controllers/test_password_expired_controller.rb +164 -0
- data/test/{test_security_question_controller.rb → controllers/test_security_question_controller.rb} +19 -37
- data/test/dummy/app/assets/config/manifest.js +3 -0
- data/test/dummy/app/controllers/overrides/paranoid_verification_code_controller.rb +7 -0
- data/test/dummy/app/controllers/overrides/password_expired_controller.rb +17 -0
- data/test/dummy/app/controllers/widgets_controller.rb +9 -0
- data/test/dummy/app/models/application_user_record.rb +2 -1
- data/test/dummy/app/models/mongoid/confirmable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/database_authenticable_fields.rb +4 -3
- data/test/dummy/app/models/mongoid/expirable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/lockable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/mappings.rb +4 -2
- data/test/dummy/app/models/mongoid/omniauthable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/paranoid_verification_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/password_archivable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/password_expirable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/recoverable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/registerable_fields.rb +4 -2
- data/test/dummy/app/models/mongoid/rememberable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/secure_validatable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/security_questionable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/session_limitable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/timeoutable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/trackable_fields.rb +2 -0
- data/test/dummy/app/models/mongoid/validatable_fields.rb +2 -0
- data/test/dummy/app/models/paranoid_verification_user.rb +26 -0
- data/test/dummy/app/models/password_expired_user.rb +26 -0
- data/test/dummy/app/models/user.rb +10 -2
- data/test/dummy/app/models/widget.rb +1 -3
- data/test/dummy/app/mongoid/one_user.rb +5 -5
- data/test/dummy/app/mongoid/user_on_engine.rb +2 -2
- data/test/dummy/app/mongoid/user_on_main_app.rb +2 -2
- data/test/dummy/app/mongoid/user_with_validations.rb +3 -3
- data/test/dummy/app/mongoid/user_without_email.rb +7 -4
- data/test/dummy/config/application.rb +3 -7
- data/test/dummy/config/boot.rb +1 -1
- data/test/dummy/config/environment.rb +1 -1
- data/test/dummy/config/environments/test.rb +4 -13
- data/test/dummy/config/initializers/devise.rb +1 -5
- data/test/dummy/config/initializers/migration_class.rb +1 -8
- data/test/dummy/config/locales/en.yml +10 -0
- data/test/dummy/config/mongoid.yml +1 -1
- data/test/dummy/config/routes.rb +6 -3
- data/test/dummy/config.ru +1 -1
- data/test/dummy/db/migrate/20120508165529_create_tables.rb +15 -6
- data/test/dummy/lib/shared_expirable_columns.rb +1 -0
- data/test/dummy/lib/shared_security_questions_fields.rb +1 -0
- data/test/dummy/lib/shared_user.rb +17 -6
- data/test/dummy/lib/shared_user_without_omniauth.rb +12 -3
- data/test/dummy/lib/shared_verification_fields.rb +1 -0
- data/test/dummy/log/test.log +45240 -0
- data/test/i18n_test.rb +22 -0
- data/test/integration/test_paranoid_verification_code_workflow.rb +53 -0
- data/test/integration/test_password_expirable_workflow.rb +53 -0
- data/test/integration/test_session_limitable_workflow.rb +69 -0
- data/test/orm/active_record.rb +7 -4
- data/test/orm/mongoid.rb +2 -1
- data/test/support/integration_helpers.rb +35 -0
- data/test/support/mongoid.yml +1 -1
- data/test/test_compatibility.rb +15 -0
- data/test/test_complexity_validator.rb +251 -29
- data/test/test_database_authenticatable_patch.rb +146 -0
- data/test/test_helper.rb +23 -8
- data/test/test_install_generator.rb +12 -2
- data/test/test_paranoid_verification.rb +8 -9
- data/test/test_password_archivable.rb +34 -11
- data/test/test_password_expirable.rb +27 -27
- data/test/test_secure_validatable.rb +284 -50
- data/test/test_secure_validatable_overrides.rb +185 -0
- data/test/test_session_limitable.rb +57 -0
- data/test/tmp/config/initializers/devise_security.rb +52 -0
- data/test/tmp/config/locales/devise.security_extension.by.yml +50 -0
- data/test/tmp/config/locales/devise.security_extension.cs.yml +46 -0
- data/test/tmp/config/locales/devise.security_extension.de.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.en.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.es.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.fa.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.fr.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.hi.yml +43 -0
- data/test/tmp/config/locales/devise.security_extension.it.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.ja.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.nl.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.pt.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.ru.yml +50 -0
- data/test/tmp/config/locales/devise.security_extension.tr.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.uk.yml +50 -0
- data/test/tmp/config/locales/devise.security_extension.zh_CN.yml +42 -0
- data/test/tmp/config/locales/devise.security_extension.zh_TW.yml +42 -0
- metadata +202 -138
- data/.codeclimate.yml +0 -63
- data/.document +0 -5
- data/.gitignore +0 -43
- data/.mdlrc +0 -1
- data/.rubocop.yml +0 -64
- data/.ruby-version +0 -1
- data/.travis.yml +0 -39
- data/Appraisals +0 -35
- data/Gemfile +0 -10
- data/Rakefile +0 -27
- data/devise-security.gemspec +0 -50
- data/gemfiles/rails_4.2_stable.gemfile +0 -16
- data/gemfiles/rails_5.0_stable.gemfile +0 -15
- data/gemfiles/rails_5.1_stable.gemfile +0 -15
- data/gemfiles/rails_5.2_stable.gemfile +0 -15
- data/gemfiles/rails_6.0_beta.gemfile +0 -15
- data/lib/devise-security/orm/active_record.rb +0 -20
- data/lib/devise-security/patches/confirmations_controller_captcha.rb +0 -23
- data/lib/devise-security/patches/confirmations_controller_security_question.rb +0 -26
- data/lib/devise-security/patches/passwords_controller_captcha.rb +0 -22
- data/lib/devise-security/patches/passwords_controller_security_question.rb +0 -25
- data/lib/devise-security/patches/registrations_controller_captcha.rb +0 -35
- data/lib/devise-security/patches/sessions_controller_captcha.rb +0 -26
- data/lib/devise-security/patches/unlocks_controller_captcha.rb +0 -22
- data/lib/devise-security/patches/unlocks_controller_security_question.rb +0 -25
- data/lib/devise-security/schema.rb +0 -66
- data/test/dummy/app/controllers/foos_controller.rb +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/secure_user.rb +0 -9
- data/test/dummy/lib/shared_user_without_email.rb +0 -28
- data/test/test_password_expired_controller.rb +0 -46
- /data/test/{test_captcha_controller.rb → controllers/test_captcha_controller.rb} +0 -0
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
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']
|
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
|
data/devise-security.gemspec
DELETED
@@ -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", "~> 6.0.0.beta1"
|
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,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DeviseSecurity::Patches
|
4
|
-
module ConfirmationsControllerCaptcha
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
define_method :create do
|
8
|
-
if valid_captcha_if_defined?(params[:captcha])
|
9
|
-
self.resource = resource_class.send_confirmation_instructions(params[resource_name])
|
10
|
-
|
11
|
-
if successfully_sent?(resource)
|
12
|
-
respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
|
13
|
-
else
|
14
|
-
respond_with(resource)
|
15
|
-
end
|
16
|
-
else
|
17
|
-
flash[:alert] = t('devise.invalid_captcha') if is_navigational_format?
|
18
|
-
respond_with({}, location: new_confirmation_path(resource_name))
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DeviseSecurity::Patches
|
4
|
-
module ConfirmationsControllerSecurityQuestion
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
define_method :create do
|
8
|
-
# only find via email, not login
|
9
|
-
resource = resource_class.find_or_initialize_with_error_by(:email, params[resource_name][:email], :not_found)
|
10
|
-
|
11
|
-
if valid_captcha_or_security_question?(resource, params)
|
12
|
-
self.resource = resource_class.send_confirmation_instructions(params[resource_name])
|
13
|
-
|
14
|
-
if successfully_sent?(resource)
|
15
|
-
respond_with({}, location: after_resending_confirmation_instructions_path_for(resource_name))
|
16
|
-
else
|
17
|
-
respond_with(resource)
|
18
|
-
end
|
19
|
-
else
|
20
|
-
flash[:alert] = t('devise.invalid_security_question') if is_navigational_format?
|
21
|
-
respond_with({}, location: new_confirmation_path(resource_name))
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DeviseSecurity::Patches
|
4
|
-
module PasswordsControllerCaptcha
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
define_method :create do
|
8
|
-
if valid_captcha_if_defined?(params[:captcha])
|
9
|
-
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
10
|
-
if successfully_sent?(resource)
|
11
|
-
respond_with({}, location: new_session_path(resource_name))
|
12
|
-
else
|
13
|
-
respond_with(resource)
|
14
|
-
end
|
15
|
-
else
|
16
|
-
flash[:alert] = t('devise.invalid_captcha') if is_navigational_format?
|
17
|
-
respond_with({}, location: new_password_path(resource_name))
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DeviseSecurity::Patches
|
4
|
-
module PasswordsControllerSecurityQuestion
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
define_method :create do
|
8
|
-
# only find via email, not login
|
9
|
-
resource = resource_class.find_or_initialize_with_error_by(:email, params[resource_name][:email], :not_found)
|
10
|
-
|
11
|
-
if valid_captcha_or_security_question?(resource, params)
|
12
|
-
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
|
13
|
-
if successfully_sent?(resource)
|
14
|
-
respond_with({}, location: new_session_path(resource_name))
|
15
|
-
else
|
16
|
-
respond_with(resource)
|
17
|
-
end
|
18
|
-
else
|
19
|
-
flash[:alert] = t('devise.invalid_security_question') if is_navigational_format?
|
20
|
-
respond_with({}, location: new_password_path(resource_name))
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DeviseSecurity::Patches
|
4
|
-
module RegistrationsControllerCaptcha
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
define_method :create do |&block|
|
8
|
-
build_resource(sign_up_params)
|
9
|
-
|
10
|
-
if valid_captcha_if_defined?(params[:captcha])
|
11
|
-
if resource.save
|
12
|
-
block.call(resource) if block
|
13
|
-
if resource.active_for_authentication?
|
14
|
-
set_flash_message :notice, :signed_up if is_flashing_format?
|
15
|
-
sign_up(resource_name, resource)
|
16
|
-
respond_with resource, location: after_sign_up_path_for(resource)
|
17
|
-
else
|
18
|
-
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
|
19
|
-
expire_data_after_sign_in!
|
20
|
-
respond_with resource, location: after_inactive_sign_up_path_for(resource)
|
21
|
-
end
|
22
|
-
else
|
23
|
-
clean_up_passwords resource
|
24
|
-
respond_with resource
|
25
|
-
end
|
26
|
-
|
27
|
-
else
|
28
|
-
resource.errors.add :base, t('devise.invalid_captcha')
|
29
|
-
clean_up_passwords resource
|
30
|
-
respond_with resource
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DeviseSecurity::Patches
|
4
|
-
module SessionsControllerCaptcha
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
define_method :create do |&block|
|
8
|
-
if valid_captcha_if_defined?(params[:captcha])
|
9
|
-
self.resource = warden.authenticate!(auth_options)
|
10
|
-
set_flash_message(:notice, :signed_in) if is_flashing_format?
|
11
|
-
sign_in(resource_name, resource)
|
12
|
-
block.call(resource) if block
|
13
|
-
respond_with resource, location: after_sign_in_path_for(resource)
|
14
|
-
else
|
15
|
-
flash[:alert] = t('devise.invalid_captcha') if is_flashing_format?
|
16
|
-
respond_with({}, location: new_session_path(resource_name))
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# for bad protected use in controller
|
21
|
-
define_method :auth_options do
|
22
|
-
{ scope: resource_name, recall: "#{controller_path}#new" }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DeviseSecurity::Patches
|
4
|
-
module UnlocksControllerCaptcha
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
define_method :create do
|
8
|
-
if valid_captcha_if_defined?(params[:captcha])
|
9
|
-
self.resource = resource_class.send_unlock_instructions(params[resource_name])
|
10
|
-
if successfully_sent?(resource)
|
11
|
-
respond_with({}, location: new_session_path(resource_name))
|
12
|
-
else
|
13
|
-
respond_with(resource)
|
14
|
-
end
|
15
|
-
else
|
16
|
-
flash[:alert] = t('devise.invalid_captcha') if is_navigational_format?
|
17
|
-
respond_with({}, location: new_unlock_path(resource_name))
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DeviseSecurity::Patches
|
4
|
-
module UnlocksControllerSecurityQuestion
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
included do
|
7
|
-
define_method :create do
|
8
|
-
# only find via email, not login
|
9
|
-
resource = resource_class.find_or_initialize_with_error_by(:email, params[resource_name][:email], :not_found)
|
10
|
-
|
11
|
-
if valid_captcha_or_security_question?(resource, params)
|
12
|
-
self.resource = resource_class.send_unlock_instructions(params[resource_name])
|
13
|
-
if successfully_sent?(resource)
|
14
|
-
respond_with({}, location: new_session_path(resource_name))
|
15
|
-
else
|
16
|
-
respond_with(resource)
|
17
|
-
end
|
18
|
-
else
|
19
|
-
flash[:alert] = t('devise.invalid_security_question') if is_navigational_format?
|
20
|
-
respond_with({}, location: new_unlock_path(resource_name))
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -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
|
File without changes
|
File without changes
|
@@ -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
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SharedUserWithoutEmail
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
# NOTE: This is missing :validatable and :confirmable, as they both require
|
8
|
-
# an email field at the moment. It is also missing :omniauthable because that
|
9
|
-
# adds unnecessary complexity to the setup
|
10
|
-
devise :database_authenticatable, :lockable, :recoverable,
|
11
|
-
:registerable, :rememberable, :timeoutable,
|
12
|
-
:trackable
|
13
|
-
end
|
14
|
-
|
15
|
-
# This test stub is a bit rubbish because it's tied very closely to the
|
16
|
-
# implementation where we care about this one case. However, completely
|
17
|
-
# removing the email field breaks "recoverable" tests completely, so we are
|
18
|
-
# just taking the approach here that "email" is something that is a not an
|
19
|
-
# ActiveRecord field.
|
20
|
-
def email_changed?
|
21
|
-
raise NoMethodError
|
22
|
-
end
|
23
|
-
|
24
|
-
def respond_to?(method_name, include_all=false)
|
25
|
-
return false if method_name.to_sym == :email_changed?
|
26
|
-
super(method_name, include_all)
|
27
|
-
end
|
28
|
-
end
|