devise_security_extension 0.7.2 → 0.10.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 (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +39 -0
  3. data/.rubocop.yml +38 -0
  4. data/Gemfile +2 -15
  5. data/Gemfile.lock +157 -112
  6. data/README.md +264 -0
  7. data/Rakefile +13 -29
  8. data/app/controllers/devise/paranoid_verification_code_controller.rb +42 -0
  9. data/app/controllers/devise/password_expired_controller.rb +20 -7
  10. data/app/views/devise/paranoid_verification_code/show.html.erb +10 -0
  11. data/config/locales/de.yml +3 -0
  12. data/config/locales/en.yml +7 -4
  13. data/config/locales/it.yml +10 -0
  14. data/devise_security_extension.gemspec +24 -88
  15. data/lib/devise_security_extension/controllers/helpers.rb +40 -7
  16. data/lib/devise_security_extension/hooks/paranoid_verification.rb +5 -0
  17. data/lib/devise_security_extension/hooks/password_expirable.rb +1 -1
  18. data/lib/devise_security_extension/hooks/session_limitable.rb +3 -2
  19. data/lib/devise_security_extension/models/database_authenticatable_patch.rb +26 -0
  20. data/lib/devise_security_extension/models/expirable.rb +1 -2
  21. data/lib/devise_security_extension/models/old_password.rb +1 -2
  22. data/lib/devise_security_extension/models/paranoid_verification.rb +35 -0
  23. data/lib/devise_security_extension/models/password_archivable.rb +11 -11
  24. data/lib/devise_security_extension/models/password_expirable.rb +9 -5
  25. data/lib/devise_security_extension/models/secure_validatable.rb +35 -9
  26. data/lib/devise_security_extension/models/security_questionable.rb +4 -1
  27. data/lib/devise_security_extension/patches/confirmations_controller_captcha.rb +3 -1
  28. data/lib/devise_security_extension/patches/confirmations_controller_security_question.rb +3 -1
  29. data/lib/devise_security_extension/patches/passwords_controller_captcha.rb +3 -1
  30. data/lib/devise_security_extension/patches/passwords_controller_security_question.rb +3 -1
  31. data/lib/devise_security_extension/patches/registrations_controller_captcha.rb +11 -8
  32. data/lib/devise_security_extension/patches/sessions_controller_captcha.rb +8 -5
  33. data/lib/devise_security_extension/patches/unlocks_controller_captcha.rb +3 -1
  34. data/lib/devise_security_extension/patches/unlocks_controller_security_question.rb +3 -1
  35. data/lib/devise_security_extension/routes.rb +4 -0
  36. data/lib/devise_security_extension/version.rb +3 -0
  37. data/lib/devise_security_extension.rb +20 -10
  38. data/lib/generators/devise_security_extension/install_generator.rb +16 -33
  39. data/lib/generators/templates/devise_security_extension.rb +38 -0
  40. data/test/dummy/Rakefile +6 -0
  41. data/test/dummy/app/controllers/application_controller.rb +2 -0
  42. data/test/dummy/app/controllers/foos_controller.rb +0 -0
  43. data/test/dummy/app/models/.gitkeep +0 -0
  44. data/test/dummy/app/models/user.rb +4 -0
  45. data/test/dummy/app/views/foos/index.html.erb +0 -0
  46. data/test/dummy/config/application.rb +24 -0
  47. data/test/dummy/config/boot.rb +6 -0
  48. data/test/dummy/config/database.yml +7 -0
  49. data/test/dummy/config/environment.rb +5 -0
  50. data/test/dummy/config/environments/test.rb +21 -0
  51. data/test/dummy/config/initializers/devise.rb +9 -0
  52. data/test/dummy/config/routes.rb +6 -0
  53. data/test/dummy/config/secrets.yml +3 -0
  54. data/test/dummy/config.ru +4 -0
  55. data/test/dummy/db/migrate/20120508165529_create_tables.rb +26 -0
  56. data/test/dummy/db/migrate/20150402165590_add_verification_columns.rb +11 -0
  57. data/test/dummy/db/migrate/20150407162345_add_verification_attempt_column.rb +9 -0
  58. data/test/test_helper.rb +10 -0
  59. data/test/test_install_generator.rb +16 -0
  60. data/test/test_paranoid_verification.rb +124 -0
  61. data/test/test_password_archivable.rb +61 -0
  62. data/test/test_password_expired_controller.rb +24 -0
  63. metadata +142 -62
  64. data/README.rdoc +0 -193
  65. data/VERSION +0 -1
  66. data/lib/devise_security_extension/models/security_question.rb +0 -3
  67. data/test/helper.rb +0 -17
  68. data/test/test_devise_security_extension.rb +0 -7
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 861a1fcbcd16044ea27b948eafcf016c545d1260
4
+ data.tar.gz: b0282b6fc0a9f73a511acb11c7f37bd2892f0f84
5
+ SHA512:
6
+ metadata.gz: c2b2c5cd49063826a3ea60490bb25d07632cb7c8adde652ec8a60f109e60a94ef9ac20e6a859fcc5567b087c6507f249e37bb739db7949cad85a9adb9be60048
7
+ data.tar.gz: f3ca889418be85fff8cd897de27de8f9555e2c21ca4527fe38cc62874a633ccff9110066e81edc0c3b6c6040b83792f6cb786f73a7020dfb939fe80ad847c4f6
data/.gitignore ADDED
@@ -0,0 +1,39 @@
1
+ test/rails_app/log/*
2
+ test/rails_app/tmp/*
3
+ *~
4
+ coverage/*
5
+ *.sqlite3
6
+ .bundle
7
+ rdoc/*
8
+ pkg
9
+
10
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
11
+ #
12
+ # * Create a file at ~/.gitignore
13
+ # * Include files you want ignored
14
+ # * Run: git config --global core.excludesfile ~/.gitignore
15
+ #
16
+ # After doing this, these files will be ignored in all your git projects,
17
+ # saving you from having to 'pollute' every project you touch with them
18
+ #
19
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
20
+ #
21
+ # For MacOS:
22
+ #
23
+ #.DS_Store
24
+ #
25
+ # For TextMate
26
+ #*.tmproj
27
+ #tmtags
28
+ #
29
+ # For emacs:
30
+ #*~
31
+ #\#*
32
+ #.\#*
33
+ #
34
+ # For vim:
35
+ #*.swp
36
+
37
+ log
38
+ test/tmp/*
39
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,38 @@
1
+ AllCops:
2
+ Include:
3
+ - '**/Rakefile'
4
+ - '**/config.ru'
5
+ - 'lib/tasks/**/*'
6
+ Exclude:
7
+ - Gemfile*
8
+ - 'db/**/*'
9
+ - 'config/**/*'
10
+ - 'bin/**/*'
11
+ - 'vendor/bundle/**/*'
12
+ - 'spec/support/**/*' # rspec support helpers have a strange api
13
+ RunRailsCops: true
14
+
15
+ # We don't care about method length, since we check method cyclomatic
16
+ # complexity.
17
+ Metrics/MethodLength:
18
+ Enabled: false
19
+
20
+ # Trailing commas make for clearer diffs because the last line won't appear
21
+ # to have been changed, as it would if it lacked a comma and had one added.
22
+ Style/TrailingComma:
23
+ EnforcedStyleForMultiline: comma
24
+
25
+ # Cop supports --auto-correct.
26
+ # Configuration parameters: PreferredDelimiters.
27
+ Style/PercentLiteralDelimiters:
28
+ PreferredDelimiters:
29
+ # Using `[]` for string arrays instead of `()`, since normal arrays are
30
+ # indicated with `[]` not `()`.
31
+ '%w': '[]'
32
+ '%W': '[]'
33
+
34
+ Style/AndOr:
35
+ # Whether `and` and `or` are banned only in conditionals (conditionals)
36
+ # or completely (always).
37
+ # They read better, more like normal English.
38
+ Enabled: false
data/Gemfile CHANGED
@@ -1,15 +1,2 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- gem "rails", ">= 3.1.1"
5
- gem "devise", ">= 2.0.0"
6
-
7
- # Add dependencies to develop your gem here.
8
- # Include everything needed to run rake, tests, features, etc.
9
- group :development do
10
- gem "rails_email_validator"
11
- gem "easy_captcha"
12
- gem "bundler", ">= 1.0.0"
13
- gem "jeweler", "~> 1.8.4"
14
- # gem "rcov", ">= 0"
15
- end
1
+ source "https://rubygems.org"
2
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,43 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ devise_security_extension (0.10.0)
5
+ devise (>= 3.0.0, < 4.0)
6
+ railties (>= 3.2.6, < 5.0)
7
+
1
8
  GEM
2
- remote: http://rubygems.org/
9
+ remote: https://rubygems.org/
3
10
  specs:
4
- actionmailer (3.2.9)
5
- actionpack (= 3.2.9)
6
- mail (~> 2.4.4)
7
- actionpack (3.2.9)
8
- activemodel (= 3.2.9)
9
- activesupport (= 3.2.9)
10
- builder (~> 3.0.0)
11
+ actionmailer (4.2.5.1)
12
+ actionpack (= 4.2.5.1)
13
+ actionview (= 4.2.5.1)
14
+ activejob (= 4.2.5.1)
15
+ mail (~> 2.5, >= 2.5.4)
16
+ rails-dom-testing (~> 1.0, >= 1.0.5)
17
+ actionpack (4.2.5.1)
18
+ actionview (= 4.2.5.1)
19
+ activesupport (= 4.2.5.1)
20
+ rack (~> 1.6)
21
+ rack-test (~> 0.6.2)
22
+ rails-dom-testing (~> 1.0, >= 1.0.5)
23
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
24
+ actionview (4.2.5.1)
25
+ activesupport (= 4.2.5.1)
26
+ builder (~> 3.1)
11
27
  erubis (~> 2.7.0)
12
- journey (~> 1.0.4)
13
- rack (~> 1.4.0)
14
- rack-cache (~> 1.2)
15
- rack-test (~> 0.6.1)
16
- sprockets (~> 2.2.1)
17
- activemodel (3.2.9)
18
- activesupport (= 3.2.9)
19
- builder (~> 3.0.0)
20
- activerecord (3.2.9)
21
- activemodel (= 3.2.9)
22
- activesupport (= 3.2.9)
23
- arel (~> 3.0.2)
24
- tzinfo (~> 0.3.29)
25
- activeresource (3.2.9)
26
- activemodel (= 3.2.9)
27
- activesupport (= 3.2.9)
28
- activesupport (3.2.9)
29
- i18n (~> 0.6)
30
- multi_json (~> 1.0)
31
- arel (3.0.2)
32
- bcrypt-ruby (3.0.1)
33
- builder (3.0.4)
34
- devise (2.1.2)
35
- bcrypt-ruby (~> 3.0)
28
+ rails-dom-testing (~> 1.0, >= 1.0.5)
29
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
30
+ activejob (4.2.5.1)
31
+ activesupport (= 4.2.5.1)
32
+ globalid (>= 0.3.0)
33
+ activemodel (4.2.5.1)
34
+ activesupport (= 4.2.5.1)
35
+ builder (~> 3.1)
36
+ activerecord (4.2.5.1)
37
+ activemodel (= 4.2.5.1)
38
+ activesupport (= 4.2.5.1)
39
+ arel (~> 6.0)
40
+ activesupport (4.2.5.1)
41
+ i18n (~> 0.7)
42
+ json (~> 1.7, >= 1.7.7)
43
+ minitest (~> 5.1)
44
+ thread_safe (~> 0.3, >= 0.3.4)
45
+ tzinfo (~> 1.1)
46
+ arel (6.0.3)
47
+ ast (2.2.0)
48
+ bcrypt (3.1.10)
49
+ builder (3.2.2)
50
+ concurrent-ruby (1.0.0)
51
+ devise (3.5.6)
52
+ bcrypt (~> 3.0)
36
53
  orm_adapter (~> 0.1)
37
- railties (~> 3.1)
38
- warden (~> 1.2.1)
39
- diff-lcs (1.1.3)
40
- easy_captcha (0.5.1)
54
+ railties (>= 3.2.6, < 5)
55
+ responders
56
+ thread_safe (~> 0.1)
57
+ warden (~> 1.2.3)
58
+ diff-lcs (1.2.5)
59
+ docile (1.1.5)
60
+ easy_captcha (0.6.5)
41
61
  bundler (>= 1.1.0)
42
62
  rails (>= 3.0.0)
43
63
  rmagick (>= 2.13.1)
@@ -45,89 +65,114 @@ GEM
45
65
  simplecov (>= 0.3.8)
46
66
  yard (>= 0.7.0)
47
67
  erubis (2.7.0)
48
- git (1.2.5)
49
- hike (1.2.1)
50
- i18n (0.6.1)
51
- jeweler (1.8.4)
52
- bundler (~> 1.0)
53
- git (>= 1.2.5)
54
- rake
55
- rdoc
56
- journey (1.0.4)
57
- json (1.7.5)
58
- mail (2.4.4)
59
- i18n (>= 0.4.0)
60
- mime-types (~> 1.16)
61
- treetop (~> 1.4.8)
62
- mime-types (1.19)
63
- multi_json (1.3.7)
64
- orm_adapter (0.4.0)
65
- polyglot (0.3.3)
66
- rack (1.4.1)
67
- rack-cache (1.2)
68
- rack (>= 0.4)
69
- rack-ssl (1.3.2)
70
- rack
71
- rack-test (0.6.2)
68
+ globalid (0.3.6)
69
+ activesupport (>= 4.1.0)
70
+ i18n (0.7.0)
71
+ json (1.8.3)
72
+ loofah (2.0.3)
73
+ nokogiri (>= 1.5.9)
74
+ mail (2.6.3)
75
+ mime-types (>= 1.16, < 3)
76
+ mime-types (2.99.1)
77
+ mini_portile2 (2.0.0)
78
+ minitest (5.8.4)
79
+ nokogiri (1.6.7.2)
80
+ mini_portile2 (~> 2.0.0.rc2)
81
+ orm_adapter (0.5.0)
82
+ parser (2.3.0.6)
83
+ ast (~> 2.2)
84
+ powerpack (0.1.1)
85
+ rack (1.6.4)
86
+ rack-test (0.6.3)
72
87
  rack (>= 1.0)
73
- rails (3.2.9)
74
- actionmailer (= 3.2.9)
75
- actionpack (= 3.2.9)
76
- activerecord (= 3.2.9)
77
- activeresource (= 3.2.9)
78
- activesupport (= 3.2.9)
79
- bundler (~> 1.0)
80
- railties (= 3.2.9)
88
+ rails (4.2.5.1)
89
+ actionmailer (= 4.2.5.1)
90
+ actionpack (= 4.2.5.1)
91
+ actionview (= 4.2.5.1)
92
+ activejob (= 4.2.5.1)
93
+ activemodel (= 4.2.5.1)
94
+ activerecord (= 4.2.5.1)
95
+ activesupport (= 4.2.5.1)
96
+ bundler (>= 1.3.0, < 2.0)
97
+ railties (= 4.2.5.1)
98
+ sprockets-rails
99
+ rails-deprecated_sanitizer (1.0.3)
100
+ activesupport (>= 4.2.0.alpha)
101
+ rails-dom-testing (1.0.7)
102
+ activesupport (>= 4.2.0.beta, < 5.0)
103
+ nokogiri (~> 1.6.0)
104
+ rails-deprecated_sanitizer (>= 1.0.1)
105
+ rails-html-sanitizer (1.0.3)
106
+ loofah (~> 2.0)
81
107
  rails_email_validator (0.1.4)
82
108
  activemodel (>= 3.0.0)
83
- railties (3.2.9)
84
- actionpack (= 3.2.9)
85
- activesupport (= 3.2.9)
86
- rack-ssl (~> 1.3.2)
109
+ railties (4.2.5.1)
110
+ actionpack (= 4.2.5.1)
111
+ activesupport (= 4.2.5.1)
87
112
  rake (>= 0.8.7)
88
- rdoc (~> 3.4)
89
- thor (>= 0.14.6, < 2.0)
90
- rake (10.0.2)
91
- rdoc (3.12)
92
- json (~> 1.4)
93
- rmagick (2.13.1)
94
- rspec-core (2.12.0)
95
- rspec-expectations (2.12.0)
96
- diff-lcs (~> 1.1.3)
97
- rspec-mocks (2.12.0)
98
- rspec-rails (2.12.0)
99
- actionpack (>= 3.0)
100
- activesupport (>= 3.0)
101
- railties (>= 3.0)
102
- rspec-core (~> 2.12.0)
103
- rspec-expectations (~> 2.12.0)
104
- rspec-mocks (~> 2.12.0)
105
- simplecov (0.7.1)
106
- multi_json (~> 1.0)
107
- simplecov-html (~> 0.7.1)
108
- simplecov-html (0.7.1)
109
- sprockets (2.2.1)
110
- hike (~> 1.2)
111
- multi_json (~> 1.0)
112
- rack (~> 1.0)
113
- tilt (~> 1.1, != 1.3.0)
114
- thor (0.16.0)
115
- tilt (1.3.3)
116
- treetop (1.4.12)
117
- polyglot
118
- polyglot (>= 0.3.1)
119
- tzinfo (0.3.35)
120
- warden (1.2.1)
113
+ thor (>= 0.18.1, < 2.0)
114
+ rainbow (2.1.0)
115
+ rake (10.5.0)
116
+ responders (2.1.1)
117
+ railties (>= 4.2.0, < 5.1)
118
+ rmagick (2.15.4)
119
+ rspec-core (3.4.3)
120
+ rspec-support (~> 3.4.0)
121
+ rspec-expectations (3.4.0)
122
+ diff-lcs (>= 1.2.0, < 2.0)
123
+ rspec-support (~> 3.4.0)
124
+ rspec-mocks (3.4.1)
125
+ diff-lcs (>= 1.2.0, < 2.0)
126
+ rspec-support (~> 3.4.0)
127
+ rspec-rails (3.4.2)
128
+ actionpack (>= 3.0, < 4.3)
129
+ activesupport (>= 3.0, < 4.3)
130
+ railties (>= 3.0, < 4.3)
131
+ rspec-core (~> 3.4.0)
132
+ rspec-expectations (~> 3.4.0)
133
+ rspec-mocks (~> 3.4.0)
134
+ rspec-support (~> 3.4.0)
135
+ rspec-support (3.4.1)
136
+ rubocop (0.37.2)
137
+ parser (>= 2.3.0.4, < 3.0)
138
+ powerpack (~> 0.1)
139
+ rainbow (>= 1.99.1, < 3.0)
140
+ ruby-progressbar (~> 1.7)
141
+ unicode-display_width (~> 0.3)
142
+ ruby-progressbar (1.7.5)
143
+ simplecov (0.11.2)
144
+ docile (~> 1.1.0)
145
+ json (~> 1.8)
146
+ simplecov-html (~> 0.10.0)
147
+ simplecov-html (0.10.0)
148
+ sprockets (3.5.2)
149
+ concurrent-ruby (~> 1.0)
150
+ rack (> 1, < 3)
151
+ sprockets-rails (3.0.3)
152
+ actionpack (>= 4.0)
153
+ activesupport (>= 4.0)
154
+ sprockets (>= 3.0.0)
155
+ sqlite3 (1.3.11)
156
+ thor (0.19.1)
157
+ thread_safe (0.3.5)
158
+ tzinfo (1.2.2)
159
+ thread_safe (~> 0.1)
160
+ unicode-display_width (0.3.1)
161
+ warden (1.2.6)
121
162
  rack (>= 1.0)
122
- yard (0.8.3)
163
+ yard (0.8.7.6)
123
164
 
124
165
  PLATFORMS
125
166
  ruby
126
167
 
127
168
  DEPENDENCIES
128
- bundler (>= 1.0.0)
129
- devise (>= 2.0.0)
130
- easy_captcha
131
- jeweler (~> 1.8.4)
132
- rails (>= 3.1.1)
133
- rails_email_validator
169
+ bundler (>= 1.3.0, < 2.0)
170
+ devise_security_extension!
171
+ easy_captcha (~> 0)
172
+ minitest
173
+ rails_email_validator (~> 0)
174
+ rubocop (~> 0)
175
+ sqlite3 (~> 1.3.10)
176
+
177
+ BUNDLED WITH
178
+ 1.11.2
data/README.md ADDED
@@ -0,0 +1,264 @@
1
+ # Devise Security Extension
2
+
3
+ An enterprise security extension for [Devise](https://github.com/plataformatec/devise), trying to meet industrial standard security demands for web applications.
4
+
5
+ It is composed of 7 additional Devise modules:
6
+
7
+ * `:password_expirable` - passwords will expire after a configured time (and will need an update)
8
+ * `:secure_validatable` - better way to validate a model (email, stronger password validation). Don't use with Devise `:validatable` module!
9
+ * `:password_archivable` - save used passwords in an `old_passwords` table for history checks (don't be able to use a formerly used password)
10
+ * `:session_limitable` - ensures, that there is only one session usable per account at once
11
+ * `:expirable` - expires a user account after x days of inactivity (default 90 days)
12
+ * `:security_questionable` - as accessible substitution for captchas (security question with captcha fallback)
13
+ * `:paranoid_verification` - admin can generate verification code that user needs to fill in otherwise he wont be able to use the application.
14
+
15
+ Configuration and database schema for each module below.
16
+
17
+ ## Additional features
18
+
19
+ * **captcha support** for `sign_up`, `sign_in`, `recover` and `unlock` (to make automated mass creation and brute forcing of accounts harder)
20
+
21
+ ## Getting started
22
+
23
+ Devise Security Extension works with Devise on Rails 3.2 onwards. You can add it to your Gemfile after you successfully set up Devise (see [Devise documentation](https://github.com/plataformatec/devise)) with:
24
+
25
+ ```ruby
26
+ gem 'devise_security_extension'
27
+ ```
28
+
29
+ Run the bundle command to install it.
30
+
31
+ After you installed Devise Security Extension you need to run the generator:
32
+
33
+ ```console
34
+ rails generate devise_security_extension:install
35
+ ```
36
+
37
+ The generator adds optional configurations to `config/initializers/devise.rb`. Enable
38
+ the modules you wish to use in the initializer you are ready to add Devise Security Extension modules on top of Devise modules to any of your Devise models:
39
+
40
+ ```ruby
41
+ devise :password_expirable, :secure_validatable, :password_archivable, :session_limitable, :expirable
42
+ ```
43
+
44
+ for `:secure_validatable` you need to add
45
+
46
+ ```ruby
47
+ gem 'rails_email_validator'
48
+ ```
49
+
50
+ ## Configuration
51
+
52
+ ```ruby
53
+ Devise.setup do |config|
54
+ # ==> Security Extension
55
+ # Configure security extension for devise
56
+
57
+ # Should the password expire (e.g 3.months)
58
+ # config.expire_password_after = 3.months
59
+
60
+ # Need 1 char of A-Z, a-z and 0-9
61
+ # config.password_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])/
62
+
63
+ # Number of old passwords in archive
64
+ # config.password_archiving_count = 5
65
+
66
+ # Deny old password (true, false, count)
67
+ # config.deny_old_passwords = true
68
+
69
+ # captcha integration for recover form
70
+ # config.captcha_for_recover = true
71
+
72
+ # captcha integration for sign up form
73
+ # config.captcha_for_sign_up = true
74
+
75
+ # captcha integration for sign in form
76
+ # config.captcha_for_sign_in = true
77
+
78
+ # captcha integration for unlock form
79
+ # config.captcha_for_unlock = true
80
+
81
+ # security_question integration for recover form
82
+ # this automatically enables captchas (captcha_for_recover, as fallback)
83
+ # config.security_question_for_recover = false
84
+
85
+ # security_question integration for unlock form
86
+ # this automatically enables captchas (captcha_for_unlock, as fallback)
87
+ # config.security_question_for_unlock = false
88
+
89
+ # security_question integration for confirmation form
90
+ # this automatically enables captchas (captcha_for_confirmation, as fallback)
91
+ # config.security_question_for_confirmation = false
92
+
93
+ # ==> Configuration for :expirable
94
+ # Time period for account expiry from last_activity_at
95
+ # config.expire_after = 90.days
96
+ end
97
+ ```
98
+
99
+ ## Captcha-Support
100
+ The captcha support depends on [EasyCaptcha](https://github.com/phatworx/easy_captcha). See further documention there.
101
+
102
+ ### Installation
103
+
104
+ 1. Add EasyCaptcha to your `Gemfile` with
105
+ ```ruby
106
+ gem 'easy_captcha'
107
+ ```
108
+ 2. Run the initializer
109
+ ```ruby
110
+ rails generate easy_captcha:install
111
+ ```
112
+ 3. Enable captcha - see "Configuration" of Devise Security Extension above.
113
+ 4. Add the captcha in the generated devise views for each controller you have activated
114
+ ```erb
115
+ <p><%= captcha_tag %></p>
116
+ <p><%= text_field_tag :captcha %></p>
117
+ ```
118
+
119
+ ## Schema
120
+
121
+ ### Password expirable
122
+ ```ruby
123
+ create_table :the_resources do |t|
124
+ # other devise fields
125
+
126
+ t.datetime :password_changed_at
127
+ end
128
+ add_index :the_resources, :password_changed_at
129
+ ```
130
+
131
+ ### Password archivable
132
+ ```ruby
133
+ create_table :old_passwords do |t|
134
+ t.string :encrypted_password, :null => false
135
+ t.string :password_archivable_type, :null => false
136
+ t.integer :password_archivable_id, :null => false
137
+ t.datetime :created_at
138
+ end
139
+ add_index :old_passwords, [:password_archivable_type, :password_archivable_id], :name => :index_password_archivable
140
+ ```
141
+
142
+ ### Session limitable
143
+ ```ruby
144
+ create_table :the_resources do |t|
145
+ # other devise fields
146
+
147
+ t.string :unique_session_id, :limit => 20
148
+ end
149
+ ```
150
+
151
+ ### Expirable
152
+ ```ruby
153
+ create_table :the_resources do |t|
154
+ # other devise fields
155
+
156
+ t.datetime :last_activity_at
157
+ t.datetime :expired_at
158
+ end
159
+ add_index :the_resources, :last_activity_at
160
+ add_index :the_resources, :expired_at
161
+ ```
162
+
163
+ ### Paranoid verifiable
164
+ ```ruby
165
+ create_table :the_resources do |t|
166
+ # other devise fields
167
+
168
+ t.string :paranoid_verification_code
169
+ t.integer :paranoid_verification_attempt, default: 0
170
+ t.datetime :paranoid_verified_at
171
+ end
172
+ add_index :the_resources, :paranoid_verification_code
173
+ add_index :the_resources, :paranoid_verified_at
174
+ ```
175
+
176
+ [Documentation for Paranoid Verifiable module]( https://github.com/phatworx/devise_security_extension/wiki/Paranoid-Verification)
177
+
178
+ ### Security questionable
179
+
180
+ ```ruby
181
+ # app/models/security_question.rb
182
+ class SecurityQuestion < ActiveRecord::Base
183
+ validates :locale, presence: true
184
+ validates :name, presence: true, uniqueness: true
185
+ end
186
+ ```
187
+
188
+ ```ruby
189
+ create_table :security_questions do |t|
190
+ t.string :locale, :null => false
191
+ t.string :name, :null => false
192
+ end
193
+
194
+ SecurityQuestion.create! locale: :de, name: 'Wie lautet der Geburstname Ihrer Mutter?'
195
+ SecurityQuestion.create! locale: :de, name: 'Wo sind sie geboren?'
196
+ SecurityQuestion.create! locale: :de, name: 'Wie lautet der Name Ihres ersten Haustieres?'
197
+ SecurityQuestion.create! locale: :de, name: 'Was ist Ihr Lieblingsfilm?'
198
+ SecurityQuestion.create! locale: :de, name: 'Was ist Ihr Lieblingsbuch?'
199
+ SecurityQuestion.create! locale: :de, name: 'Was ist Ihr Lieblingstier?'
200
+ SecurityQuestion.create! locale: :de, name: 'Was ist Ihr Lieblings-Reiseland?'
201
+ ```
202
+
203
+
204
+ ```ruby
205
+ add_column :the_resources, :security_question_id, :integer
206
+ add_column :the_resources, :security_question_answer, :string
207
+ ```
208
+
209
+ or
210
+
211
+ ```ruby
212
+ create_table :the_resources do |t|
213
+ # other devise fields
214
+
215
+ t.integer :security_question_id
216
+ t.string :security_question_answer
217
+ end
218
+ ```
219
+
220
+ ## Requirements
221
+
222
+ * Devise (https://github.com/plataformatec/devise)
223
+ * Rails 3.2 onwards (http://github.com/rails/rails)
224
+ * recommendations:
225
+ * `autocomplete-off` (http://github.com/phatworx/autocomplete-off)
226
+ * `easy_captcha` (http://github.com/phatworx/easy_captcha)
227
+ * `rails_email_validator` (http://github.com/phatworx/rails_email_validator)
228
+
229
+
230
+ ## Todo
231
+
232
+ * see the github issues (feature requests)
233
+
234
+ ## History
235
+ * 0.1 expire passwords
236
+ * 0.2 strong password validation
237
+ * 0.3 password archivable with validation
238
+ * 0.4 captcha support for sign_up, sign_in, recover and unlock
239
+ * 0.5 session_limitable module
240
+ * 0.6 expirable module
241
+ * 0.7 security questionable module for recover and unlock
242
+ * 0.8 Support for Rails 4 (+ variety of patches)
243
+
244
+ ## Maintainers
245
+
246
+ * Team Phatworx (https://github.com/phatworx)
247
+ * Alexander Dreher (https://github.com/alexdreher)
248
+ * Christoph Chilian (https://github.com/cc-web)
249
+ * Marco Scholl (https://github.com/traxanos)
250
+ * Thomas Powell (https://github.com/stringsn88keys)
251
+
252
+ ## Contributing to devise_security_extension
253
+
254
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
255
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
256
+ * Fork the project
257
+ * Start a feature/bugfix branch
258
+ * Commit and push until you are happy with your contribution
259
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
260
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
261
+
262
+ ## Copyright
263
+
264
+ Copyright (c) 2011-2015 Marco Scholl. See LICENSE.txt for further details.