quo_vadis 1.3.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +11 -8
  3. data/CHANGELOG.md +26 -0
  4. data/Gemfile +14 -1
  5. data/Gemfile.lock +178 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +435 -127
  8. data/Rakefile +14 -16
  9. data/app/controllers/quo_vadis/confirmations_controller.rb +56 -0
  10. data/app/controllers/quo_vadis/logs_controller.rb +20 -0
  11. data/app/controllers/quo_vadis/password_resets_controller.rb +65 -0
  12. data/app/controllers/quo_vadis/passwords_controller.rb +26 -0
  13. data/app/controllers/quo_vadis/recovery_codes_controller.rb +54 -0
  14. data/app/controllers/quo_vadis/sessions_controller.rb +50 -132
  15. data/app/controllers/quo_vadis/totps_controller.rb +72 -0
  16. data/app/controllers/quo_vadis/twofas_controller.rb +26 -0
  17. data/app/mailers/quo_vadis/mailer.rb +73 -0
  18. data/app/models/quo_vadis/account.rb +59 -0
  19. data/app/models/quo_vadis/account_confirmation_token.rb +17 -0
  20. data/app/models/quo_vadis/log.rb +57 -0
  21. data/app/models/quo_vadis/password.rb +52 -0
  22. data/app/models/quo_vadis/password_reset_token.rb +17 -0
  23. data/app/models/quo_vadis/recovery_code.rb +26 -0
  24. data/app/models/quo_vadis/session.rb +55 -0
  25. data/app/models/quo_vadis/token.rb +42 -0
  26. data/app/models/quo_vadis/totp.rb +56 -0
  27. data/bin/console +15 -0
  28. data/bin/rails +21 -0
  29. data/bin/setup +8 -0
  30. data/config/locales/quo_vadis.en.yml +51 -18
  31. data/config/routes.rb +40 -12
  32. data/db/migrate/202102150904_setup.rb +48 -0
  33. data/lib/generators/quo_vadis/install_generator.rb +4 -23
  34. data/lib/quo_vadis.rb +100 -106
  35. data/lib/quo_vadis/controller.rb +227 -0
  36. data/lib/quo_vadis/crypt.rb +43 -0
  37. data/lib/quo_vadis/current_request_details.rb +11 -0
  38. data/lib/quo_vadis/defaults.rb +18 -0
  39. data/lib/quo_vadis/encrypted_type.rb +17 -0
  40. data/lib/quo_vadis/engine.rb +9 -11
  41. data/lib/quo_vadis/hmacable.rb +26 -0
  42. data/lib/quo_vadis/ip_masking.rb +31 -0
  43. data/lib/quo_vadis/model.rb +86 -0
  44. data/lib/quo_vadis/version.rb +3 -1
  45. data/quo_vadis.gemspec +18 -24
  46. metadata +49 -229
  47. data/app/controllers/controller_mixin.rb +0 -109
  48. data/app/mailers/quo_vadis/notifier.rb +0 -30
  49. data/app/models/model_mixin.rb +0 -128
  50. data/lib/generators/quo_vadis/templates/migration.rb.erb +0 -18
  51. data/lib/generators/quo_vadis/templates/quo_vadis.rb.erb +0 -96
  52. data/test/dummy/.gitignore +0 -2
  53. data/test/dummy/Rakefile +0 -7
  54. data/test/dummy/app/controllers/application_controller.rb +0 -3
  55. data/test/dummy/app/controllers/articles_controller.rb +0 -20
  56. data/test/dummy/app/controllers/users_controller.rb +0 -17
  57. data/test/dummy/app/helpers/application_helper.rb +0 -2
  58. data/test/dummy/app/helpers/articles_helper.rb +0 -2
  59. data/test/dummy/app/models/article.rb +0 -2
  60. data/test/dummy/app/models/person.rb +0 -3
  61. data/test/dummy/app/models/user.rb +0 -3
  62. data/test/dummy/app/views/articles/index.html.erb +0 -1
  63. data/test/dummy/app/views/articles/new.html.erb +0 -11
  64. data/test/dummy/app/views/layouts/application.html.erb +0 -30
  65. data/test/dummy/app/views/layouts/sessions.html.erb +0 -3
  66. data/test/dummy/app/views/quo_vadis/notifier/change_password.text.erb +0 -9
  67. data/test/dummy/app/views/quo_vadis/notifier/invite.text.erb +0 -8
  68. data/test/dummy/app/views/sessions/edit.html.erb +0 -11
  69. data/test/dummy/app/views/sessions/forgotten.html.erb +0 -13
  70. data/test/dummy/app/views/sessions/invite.html.erb +0 -31
  71. data/test/dummy/app/views/sessions/new.html.erb +0 -15
  72. data/test/dummy/app/views/users/new.html.erb +0 -14
  73. data/test/dummy/config.ru +0 -4
  74. data/test/dummy/config/application.rb +0 -21
  75. data/test/dummy/config/boot.rb +0 -10
  76. data/test/dummy/config/database.yml +0 -22
  77. data/test/dummy/config/environment.rb +0 -5
  78. data/test/dummy/config/environments/development.rb +0 -26
  79. data/test/dummy/config/environments/production.rb +0 -49
  80. data/test/dummy/config/environments/test.rb +0 -37
  81. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  82. data/test/dummy/config/initializers/inflections.rb +0 -10
  83. data/test/dummy/config/initializers/mime_types.rb +0 -5
  84. data/test/dummy/config/initializers/quo_vadis.rb +0 -84
  85. data/test/dummy/config/initializers/rack_patch.rb +0 -16
  86. data/test/dummy/config/initializers/secret_token.rb +0 -7
  87. data/test/dummy/config/initializers/session_store.rb +0 -8
  88. data/test/dummy/config/locales/en.yml +0 -5
  89. data/test/dummy/config/locales/quo_vadis.en.yml +0 -21
  90. data/test/dummy/config/routes.rb +0 -5
  91. data/test/dummy/db/migrate/20110124125037_create_users.rb +0 -13
  92. data/test/dummy/db/migrate/20110124131535_create_articles.rb +0 -14
  93. data/test/dummy/db/migrate/20110127094709_add_authentication_to_users.rb +0 -18
  94. data/test/dummy/db/migrate/20111004112209_create_people.rb +0 -13
  95. data/test/dummy/db/migrate/20111004132342_add_authentication_to_people.rb +0 -18
  96. data/test/dummy/db/schema.rb +0 -33
  97. data/test/dummy/public/404.html +0 -26
  98. data/test/dummy/public/422.html +0 -26
  99. data/test/dummy/public/500.html +0 -26
  100. data/test/dummy/public/favicon.ico +0 -0
  101. data/test/dummy/public/javascripts/application.js +0 -2
  102. data/test/dummy/public/javascripts/controls.js +0 -965
  103. data/test/dummy/public/javascripts/dragdrop.js +0 -974
  104. data/test/dummy/public/javascripts/effects.js +0 -1123
  105. data/test/dummy/public/javascripts/prototype.js +0 -6001
  106. data/test/dummy/public/javascripts/rails.js +0 -175
  107. data/test/dummy/public/stylesheets/.gitkeep +0 -0
  108. data/test/dummy/script/rails +0 -6
  109. data/test/integration/activation_test.rb +0 -108
  110. data/test/integration/authenticate_test.rb +0 -39
  111. data/test/integration/blocked_test.rb +0 -23
  112. data/test/integration/config_test.rb +0 -132
  113. data/test/integration/cookie_test.rb +0 -67
  114. data/test/integration/csrf_test.rb +0 -41
  115. data/test/integration/forgotten_test.rb +0 -93
  116. data/test/integration/helper_test.rb +0 -18
  117. data/test/integration/locale_test.rb +0 -197
  118. data/test/integration/navigation_test.rb +0 -7
  119. data/test/integration/sign_in_person_test.rb +0 -26
  120. data/test/integration/sign_in_test.rb +0 -24
  121. data/test/integration/sign_out_test.rb +0 -20
  122. data/test/integration/sign_up_test.rb +0 -21
  123. data/test/quo_vadis_test.rb +0 -7
  124. data/test/support/integration_case.rb +0 -11
  125. data/test/test_helper.rb +0 -88
  126. data/test/unit/user_test.rb +0 -75
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module QuoVadis
2
- VERSION = '1.3.1'
4
+ VERSION = '2.0.0'
3
5
  end
data/quo_vadis.gemspec CHANGED
@@ -1,30 +1,24 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
3
- require 'quo_vadis/version'
1
+ # frozen_string_literal: true
4
2
 
5
- Gem::Specification.new do |s|
6
- s.name = 'quo_vadis'
7
- s.version = QuoVadis::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ['Andy Stewart']
10
- s.email = ['boss@airbladesoftware.com']
11
- s.homepage = 'https://github.com/airblade/quo_vadis'
12
- s.summary = 'Simple username/password authentication for Rails 3.'
13
- s.description = s.summary
3
+ require_relative 'lib/quo_vadis/version'
14
4
 
15
- s.rubyforge_project = 'quo_vadis'
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'quo_vadis'
7
+ spec.version = QuoVadis::VERSION
8
+ spec.authors = ['Andy Stewart']
9
+ spec.email = ['boss@airbladesoftware.com']
16
10
 
17
- s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
- s.require_paths = ['lib']
11
+ spec.summary = 'Multifactor authentication for Rails 6.'
12
+ spec.homepage = 'https://github.com/airblade/quo_vadis'
13
+ spec.license = 'MIT'
21
14
 
22
- s.add_dependency 'rails', '~> 3.0.4'
23
- s.add_dependency 'bcrypt-ruby', '~> 3.0.0'
15
+ # spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
24
16
 
25
- # s.add_development_dependency 'rails', '~> 3.0.4' # so we can test CSRF protection
26
- s.add_development_dependency 'sqlite3-ruby'
27
- s.add_development_dependency 'capybara', '~>1.1'
28
- s.add_development_dependency 'launchy'
29
- s.add_development_dependency 'rake'
17
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
19
+ end
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'rails', '>= 6'
23
+ spec.add_dependency 'bcrypt', '~> 3.1.7'
30
24
  end
metadata CHANGED
@@ -1,100 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quo_vadis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-22 00:00:00.000000000 Z
11
+ date: 2021-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 3.0.4
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 3.0.4
27
- - !ruby/object:Gem::Dependency
28
- name: bcrypt-ruby
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 3.0.0
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 3.0.0
41
- - !ruby/object:Gem::Dependency
42
- name: sqlite3-ruby
43
15
  requirement: !ruby/object:Gem::Requirement
44
16
  requirements:
45
17
  - - ">="
46
18
  - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
19
+ version: '6'
20
+ type: :runtime
49
21
  prerelease: false
50
22
  version_requirements: !ruby/object:Gem::Requirement
51
23
  requirements:
52
24
  - - ">="
53
25
  - !ruby/object:Gem::Version
54
- version: '0'
26
+ version: '6'
55
27
  - !ruby/object:Gem::Dependency
56
- name: capybara
28
+ name: bcrypt
57
29
  requirement: !ruby/object:Gem::Requirement
58
30
  requirements:
59
31
  - - "~>"
60
32
  - !ruby/object:Gem::Version
61
- version: '1.1'
62
- type: :development
33
+ version: 3.1.7
34
+ type: :runtime
63
35
  prerelease: false
64
36
  version_requirements: !ruby/object:Gem::Requirement
65
37
  requirements:
66
38
  - - "~>"
67
39
  - !ruby/object:Gem::Version
68
- version: '1.1'
69
- - !ruby/object:Gem::Dependency
70
- name: launchy
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- description: Simple username/password authentication for Rails 3.
40
+ version: 3.1.7
41
+ description:
98
42
  email:
99
43
  - boss@airbladesoftware.com
100
44
  executables: []
@@ -104,100 +48,52 @@ files:
104
48
  - ".gitignore"
105
49
  - CHANGELOG.md
106
50
  - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE.txt
107
53
  - README.md
108
54
  - Rakefile
109
- - app/controllers/controller_mixin.rb
55
+ - app/controllers/quo_vadis/confirmations_controller.rb
56
+ - app/controllers/quo_vadis/logs_controller.rb
57
+ - app/controllers/quo_vadis/password_resets_controller.rb
58
+ - app/controllers/quo_vadis/passwords_controller.rb
59
+ - app/controllers/quo_vadis/recovery_codes_controller.rb
110
60
  - app/controllers/quo_vadis/sessions_controller.rb
111
- - app/mailers/quo_vadis/notifier.rb
112
- - app/models/model_mixin.rb
61
+ - app/controllers/quo_vadis/totps_controller.rb
62
+ - app/controllers/quo_vadis/twofas_controller.rb
63
+ - app/mailers/quo_vadis/mailer.rb
64
+ - app/models/quo_vadis/account.rb
65
+ - app/models/quo_vadis/account_confirmation_token.rb
66
+ - app/models/quo_vadis/log.rb
67
+ - app/models/quo_vadis/password.rb
68
+ - app/models/quo_vadis/password_reset_token.rb
69
+ - app/models/quo_vadis/recovery_code.rb
70
+ - app/models/quo_vadis/session.rb
71
+ - app/models/quo_vadis/token.rb
72
+ - app/models/quo_vadis/totp.rb
73
+ - bin/console
74
+ - bin/rails
75
+ - bin/setup
113
76
  - config/locales/quo_vadis.en.yml
114
77
  - config/routes.rb
78
+ - db/migrate/202102150904_setup.rb
115
79
  - lib/generators/quo_vadis/install_generator.rb
116
- - lib/generators/quo_vadis/templates/migration.rb.erb
117
- - lib/generators/quo_vadis/templates/quo_vadis.rb.erb
118
80
  - lib/quo_vadis.rb
81
+ - lib/quo_vadis/controller.rb
82
+ - lib/quo_vadis/crypt.rb
83
+ - lib/quo_vadis/current_request_details.rb
84
+ - lib/quo_vadis/defaults.rb
85
+ - lib/quo_vadis/encrypted_type.rb
119
86
  - lib/quo_vadis/engine.rb
87
+ - lib/quo_vadis/hmacable.rb
88
+ - lib/quo_vadis/ip_masking.rb
89
+ - lib/quo_vadis/model.rb
120
90
  - lib/quo_vadis/version.rb
121
91
  - quo_vadis.gemspec
122
- - test/dummy/.gitignore
123
- - test/dummy/Rakefile
124
- - test/dummy/app/controllers/application_controller.rb
125
- - test/dummy/app/controllers/articles_controller.rb
126
- - test/dummy/app/controllers/users_controller.rb
127
- - test/dummy/app/helpers/application_helper.rb
128
- - test/dummy/app/helpers/articles_helper.rb
129
- - test/dummy/app/models/article.rb
130
- - test/dummy/app/models/person.rb
131
- - test/dummy/app/models/user.rb
132
- - test/dummy/app/views/articles/index.html.erb
133
- - test/dummy/app/views/articles/new.html.erb
134
- - test/dummy/app/views/layouts/application.html.erb
135
- - test/dummy/app/views/layouts/sessions.html.erb
136
- - test/dummy/app/views/quo_vadis/notifier/change_password.text.erb
137
- - test/dummy/app/views/quo_vadis/notifier/invite.text.erb
138
- - test/dummy/app/views/sessions/edit.html.erb
139
- - test/dummy/app/views/sessions/forgotten.html.erb
140
- - test/dummy/app/views/sessions/invite.html.erb
141
- - test/dummy/app/views/sessions/new.html.erb
142
- - test/dummy/app/views/users/new.html.erb
143
- - test/dummy/config.ru
144
- - test/dummy/config/application.rb
145
- - test/dummy/config/boot.rb
146
- - test/dummy/config/database.yml
147
- - test/dummy/config/environment.rb
148
- - test/dummy/config/environments/development.rb
149
- - test/dummy/config/environments/production.rb
150
- - test/dummy/config/environments/test.rb
151
- - test/dummy/config/initializers/backtrace_silencers.rb
152
- - test/dummy/config/initializers/inflections.rb
153
- - test/dummy/config/initializers/mime_types.rb
154
- - test/dummy/config/initializers/quo_vadis.rb
155
- - test/dummy/config/initializers/rack_patch.rb
156
- - test/dummy/config/initializers/secret_token.rb
157
- - test/dummy/config/initializers/session_store.rb
158
- - test/dummy/config/locales/en.yml
159
- - test/dummy/config/locales/quo_vadis.en.yml
160
- - test/dummy/config/routes.rb
161
- - test/dummy/db/migrate/20110124125037_create_users.rb
162
- - test/dummy/db/migrate/20110124131535_create_articles.rb
163
- - test/dummy/db/migrate/20110127094709_add_authentication_to_users.rb
164
- - test/dummy/db/migrate/20111004112209_create_people.rb
165
- - test/dummy/db/migrate/20111004132342_add_authentication_to_people.rb
166
- - test/dummy/db/schema.rb
167
- - test/dummy/public/404.html
168
- - test/dummy/public/422.html
169
- - test/dummy/public/500.html
170
- - test/dummy/public/favicon.ico
171
- - test/dummy/public/javascripts/application.js
172
- - test/dummy/public/javascripts/controls.js
173
- - test/dummy/public/javascripts/dragdrop.js
174
- - test/dummy/public/javascripts/effects.js
175
- - test/dummy/public/javascripts/prototype.js
176
- - test/dummy/public/javascripts/rails.js
177
- - test/dummy/public/stylesheets/.gitkeep
178
- - test/dummy/script/rails
179
- - test/integration/activation_test.rb
180
- - test/integration/authenticate_test.rb
181
- - test/integration/blocked_test.rb
182
- - test/integration/config_test.rb
183
- - test/integration/cookie_test.rb
184
- - test/integration/csrf_test.rb
185
- - test/integration/forgotten_test.rb
186
- - test/integration/helper_test.rb
187
- - test/integration/locale_test.rb
188
- - test/integration/navigation_test.rb
189
- - test/integration/sign_in_person_test.rb
190
- - test/integration/sign_in_test.rb
191
- - test/integration/sign_out_test.rb
192
- - test/integration/sign_up_test.rb
193
- - test/quo_vadis_test.rb
194
- - test/support/integration_case.rb
195
- - test/test_helper.rb
196
- - test/unit/user_test.rb
197
92
  homepage: https://github.com/airblade/quo_vadis
198
- licenses: []
93
+ licenses:
94
+ - MIT
199
95
  metadata: {}
200
- post_install_message:
96
+ post_install_message:
201
97
  rdoc_options: []
202
98
  require_paths:
203
99
  - lib
@@ -212,84 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
108
  - !ruby/object:Gem::Version
213
109
  version: '0'
214
110
  requirements: []
215
- rubyforge_project: quo_vadis
216
- rubygems_version: 2.2.2
217
- signing_key:
111
+ rubygems_version: 3.1.4
112
+ signing_key:
218
113
  specification_version: 4
219
- summary: Simple username/password authentication for Rails 3.
220
- test_files:
221
- - test/dummy/.gitignore
222
- - test/dummy/Rakefile
223
- - test/dummy/app/controllers/application_controller.rb
224
- - test/dummy/app/controllers/articles_controller.rb
225
- - test/dummy/app/controllers/users_controller.rb
226
- - test/dummy/app/helpers/application_helper.rb
227
- - test/dummy/app/helpers/articles_helper.rb
228
- - test/dummy/app/models/article.rb
229
- - test/dummy/app/models/person.rb
230
- - test/dummy/app/models/user.rb
231
- - test/dummy/app/views/articles/index.html.erb
232
- - test/dummy/app/views/articles/new.html.erb
233
- - test/dummy/app/views/layouts/application.html.erb
234
- - test/dummy/app/views/layouts/sessions.html.erb
235
- - test/dummy/app/views/quo_vadis/notifier/change_password.text.erb
236
- - test/dummy/app/views/quo_vadis/notifier/invite.text.erb
237
- - test/dummy/app/views/sessions/edit.html.erb
238
- - test/dummy/app/views/sessions/forgotten.html.erb
239
- - test/dummy/app/views/sessions/invite.html.erb
240
- - test/dummy/app/views/sessions/new.html.erb
241
- - test/dummy/app/views/users/new.html.erb
242
- - test/dummy/config.ru
243
- - test/dummy/config/application.rb
244
- - test/dummy/config/boot.rb
245
- - test/dummy/config/database.yml
246
- - test/dummy/config/environment.rb
247
- - test/dummy/config/environments/development.rb
248
- - test/dummy/config/environments/production.rb
249
- - test/dummy/config/environments/test.rb
250
- - test/dummy/config/initializers/backtrace_silencers.rb
251
- - test/dummy/config/initializers/inflections.rb
252
- - test/dummy/config/initializers/mime_types.rb
253
- - test/dummy/config/initializers/quo_vadis.rb
254
- - test/dummy/config/initializers/rack_patch.rb
255
- - test/dummy/config/initializers/secret_token.rb
256
- - test/dummy/config/initializers/session_store.rb
257
- - test/dummy/config/locales/en.yml
258
- - test/dummy/config/locales/quo_vadis.en.yml
259
- - test/dummy/config/routes.rb
260
- - test/dummy/db/migrate/20110124125037_create_users.rb
261
- - test/dummy/db/migrate/20110124131535_create_articles.rb
262
- - test/dummy/db/migrate/20110127094709_add_authentication_to_users.rb
263
- - test/dummy/db/migrate/20111004112209_create_people.rb
264
- - test/dummy/db/migrate/20111004132342_add_authentication_to_people.rb
265
- - test/dummy/db/schema.rb
266
- - test/dummy/public/404.html
267
- - test/dummy/public/422.html
268
- - test/dummy/public/500.html
269
- - test/dummy/public/favicon.ico
270
- - test/dummy/public/javascripts/application.js
271
- - test/dummy/public/javascripts/controls.js
272
- - test/dummy/public/javascripts/dragdrop.js
273
- - test/dummy/public/javascripts/effects.js
274
- - test/dummy/public/javascripts/prototype.js
275
- - test/dummy/public/javascripts/rails.js
276
- - test/dummy/public/stylesheets/.gitkeep
277
- - test/dummy/script/rails
278
- - test/integration/activation_test.rb
279
- - test/integration/authenticate_test.rb
280
- - test/integration/blocked_test.rb
281
- - test/integration/config_test.rb
282
- - test/integration/cookie_test.rb
283
- - test/integration/csrf_test.rb
284
- - test/integration/forgotten_test.rb
285
- - test/integration/helper_test.rb
286
- - test/integration/locale_test.rb
287
- - test/integration/navigation_test.rb
288
- - test/integration/sign_in_person_test.rb
289
- - test/integration/sign_in_test.rb
290
- - test/integration/sign_out_test.rb
291
- - test/integration/sign_up_test.rb
292
- - test/quo_vadis_test.rb
293
- - test/support/integration_case.rb
294
- - test/test_helper.rb
295
- - test/unit/user_test.rb
114
+ summary: Multifactor authentication for Rails 6.
115
+ test_files: []
@@ -1,109 +0,0 @@
1
- module ControllerMixin
2
- def self.included(base)
3
- base.helper_method :"current_#{QuoVadis.model_instance_name}", :authenticated?
4
- end
5
-
6
- protected
7
-
8
- def handle_unverified_request
9
- super
10
- cookies.delete :remember_me, :domain => QuoVadis.cookie_domain
11
- end
12
-
13
- private
14
-
15
- class_eval <<-END, __FILE__, __LINE__ + 1
16
- # Returns `true` if we have an authenticated user, `false` otherwise.
17
- def authenticated?
18
- !!current_#{QuoVadis.model_instance_name}
19
- end
20
-
21
- # Remembers the authenticated <tt>user</tt> (in this session and future sessions).
22
- #
23
- # If you want to sign in a <tt>user</tt> you have just created, call <tt>sign_in</tt>
24
- # instead.
25
- def current_#{QuoVadis.model_instance_name}=(user)
26
- remember_user_in_session user
27
- remember_user_between_sessions user
28
- end
29
-
30
- # Returns the authenticated user.
31
- def current_#{QuoVadis.model_instance_name}
32
- @current_#{QuoVadis.model_instance_name} ||= find_authenticated_user
33
- end
34
-
35
- # Does nothing if we already have an authenticated user. If we don't have an
36
- # authenticated user, it stores the desired URL and redirects to the sign in URL.
37
- def authenticate
38
- unless authenticated?
39
- session[:quo_vadis_original_url] = request.fullpath
40
- flash[:notice] = t('quo_vadis.flash.sign_in.before') unless t('quo_vadis.flash.sign_in.before').blank?
41
- redirect_to sign_in_url
42
- end
43
- end
44
-
45
- # Signs in a user, i.e. remembers them in the session, runs the sign-in hook,
46
- # and redirects appropriately.
47
- #
48
- # This method should be called when you have just authenticated a <tt>user</tt>
49
- # and you need to sign them in. For example, if a new user has just signed up,
50
- # you should call this method to sign them in.
51
- def sign_in(user)
52
- prevent_session_fixation
53
- self.current_#{QuoVadis.model_instance_name} = user
54
- QuoVadis.signed_in_hook user, self
55
- redirect_to QuoVadis.signed_in_url(user, original_url, self)
56
- end
57
-
58
- def remember_user_in_session(user) # :nodoc:
59
- session[:current_#{QuoVadis.model_instance_name}_id] = user ? user.id : nil
60
- end
61
-
62
- def find_user_by_cookie # :nodoc:
63
- #{QuoVadis.model}.find_by_salt(*cookies.signed[:remember_me]) if cookies.signed[:remember_me]
64
- end
65
-
66
- def find_user_by_session # :nodoc:
67
- #{QuoVadis.model}.find(session[:current_#{QuoVadis.model_instance_name}_id]) if session[:current_#{QuoVadis.model_instance_name}_id]
68
- end
69
- END
70
-
71
- # Returns true if the sign-in process is blocked to the user, false otherwise.
72
- def blocked?
73
- QuoVadis.blocked?(self)
74
- end
75
-
76
- def remember_user_between_sessions(user) # :nodoc:
77
- if user && QuoVadis.remember_for
78
- cookies.signed[:remember_me] = {
79
- :value => [user.id, user.password_salt],
80
- :expires => QuoVadis.remember_for.from_now,
81
- :httponly => true,
82
- :domain => QuoVadis.cookie_domain
83
- }
84
- else
85
- cookies.delete :remember_me, :domain => QuoVadis.cookie_domain
86
- end
87
- end
88
-
89
- def find_authenticated_user # :nodoc:
90
- find_user_by_session || find_user_by_cookie
91
- end
92
-
93
- # Returns the URL if any which the user tried to visit before being forced to authenticate.
94
- def original_url
95
- url = session[:quo_vadis_original_url]
96
- session[:quo_vadis_original_url] = nil
97
- url
98
- end
99
-
100
- def prevent_session_fixation # :nodoc:
101
- original_flash = flash.inject({}) { |hsh, (k,v)| hsh[k] = v; hsh }
102
- original_url = session[:quo_vadis_original_url]
103
-
104
- reset_session
105
-
106
- original_flash.each { |k,v| flash[k] = v }
107
- session[:quo_vadis_original_url] = original_url
108
- end
109
- end