quo_vadis 1.4.2 → 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 +5 -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 +15 -9
  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 +50 -23
  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 -98
  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 -25
  46. metadata +46 -246
  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 -77
  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 -118
  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 -86
  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.4.2'
4
+ VERSION = '2.0.0'
3
5
  end
data/quo_vadis.gemspec CHANGED
@@ -1,31 +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', '< 5'
23
- s.add_dependency 'bcrypt', '> 3.1.6'
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'
27
- s.add_development_dependency 'capybara', '~>1.1'
28
- s.add_development_dependency 'launchy'
29
- s.add_development_dependency 'rake'
30
- s.add_development_dependency 'test-unit', '~> 3.0'
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'
31
24
  end
metadata CHANGED
@@ -1,120 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quo_vadis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-19 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
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '5'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">"
28
- - !ruby/object:Gem::Version
29
- version: 3.0.4
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '5'
33
- - !ruby/object:Gem::Dependency
34
- name: bcrypt
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">"
38
- - !ruby/object:Gem::Version
39
- version: 3.1.6
40
- type: :runtime
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">"
45
- - !ruby/object:Gem::Version
46
- version: 3.1.6
47
- - !ruby/object:Gem::Dependency
48
- name: sqlite3
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- - !ruby/object:Gem::Dependency
62
- name: capybara
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '1.1'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '1.1'
75
- - !ruby/object:Gem::Dependency
76
- name: launchy
77
15
  requirement: !ruby/object:Gem::Requirement
78
16
  requirements:
79
17
  - - ">="
80
18
  - !ruby/object:Gem::Version
81
- version: '0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '0'
89
- - !ruby/object:Gem::Dependency
90
- name: rake
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :development
19
+ version: '6'
20
+ type: :runtime
97
21
  prerelease: false
98
22
  version_requirements: !ruby/object:Gem::Requirement
99
23
  requirements:
100
24
  - - ">="
101
25
  - !ruby/object:Gem::Version
102
- version: '0'
26
+ version: '6'
103
27
  - !ruby/object:Gem::Dependency
104
- name: test-unit
28
+ name: bcrypt
105
29
  requirement: !ruby/object:Gem::Requirement
106
30
  requirements:
107
31
  - - "~>"
108
32
  - !ruby/object:Gem::Version
109
- version: '3.0'
110
- type: :development
33
+ version: 3.1.7
34
+ type: :runtime
111
35
  prerelease: false
112
36
  version_requirements: !ruby/object:Gem::Requirement
113
37
  requirements:
114
38
  - - "~>"
115
39
  - !ruby/object:Gem::Version
116
- version: '3.0'
117
- description: Simple username/password authentication for Rails 3.
40
+ version: 3.1.7
41
+ description:
118
42
  email:
119
43
  - boss@airbladesoftware.com
120
44
  executables: []
@@ -124,98 +48,50 @@ files:
124
48
  - ".gitignore"
125
49
  - CHANGELOG.md
126
50
  - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE.txt
127
53
  - README.md
128
54
  - Rakefile
129
- - 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
130
60
  - app/controllers/quo_vadis/sessions_controller.rb
131
- - app/mailers/quo_vadis/notifier.rb
132
- - 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
133
76
  - config/locales/quo_vadis.en.yml
134
77
  - config/routes.rb
78
+ - db/migrate/202102150904_setup.rb
135
79
  - lib/generators/quo_vadis/install_generator.rb
136
- - lib/generators/quo_vadis/templates/migration.rb.erb
137
- - lib/generators/quo_vadis/templates/quo_vadis.rb.erb
138
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
139
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
140
90
  - lib/quo_vadis/version.rb
141
91
  - quo_vadis.gemspec
142
- - test/dummy/.gitignore
143
- - test/dummy/Rakefile
144
- - test/dummy/app/controllers/application_controller.rb
145
- - test/dummy/app/controllers/articles_controller.rb
146
- - test/dummy/app/controllers/users_controller.rb
147
- - test/dummy/app/helpers/application_helper.rb
148
- - test/dummy/app/helpers/articles_helper.rb
149
- - test/dummy/app/models/article.rb
150
- - test/dummy/app/models/person.rb
151
- - test/dummy/app/models/user.rb
152
- - test/dummy/app/views/articles/index.html.erb
153
- - test/dummy/app/views/articles/new.html.erb
154
- - test/dummy/app/views/layouts/application.html.erb
155
- - test/dummy/app/views/layouts/sessions.html.erb
156
- - test/dummy/app/views/quo_vadis/notifier/change_password.text.erb
157
- - test/dummy/app/views/quo_vadis/notifier/invite.text.erb
158
- - test/dummy/app/views/sessions/edit.html.erb
159
- - test/dummy/app/views/sessions/forgotten.html.erb
160
- - test/dummy/app/views/sessions/invite.html.erb
161
- - test/dummy/app/views/sessions/new.html.erb
162
- - test/dummy/app/views/users/new.html.erb
163
- - test/dummy/config.ru
164
- - test/dummy/config/application.rb
165
- - test/dummy/config/boot.rb
166
- - test/dummy/config/database.yml
167
- - test/dummy/config/environment.rb
168
- - test/dummy/config/environments/development.rb
169
- - test/dummy/config/environments/production.rb
170
- - test/dummy/config/environments/test.rb
171
- - test/dummy/config/initializers/backtrace_silencers.rb
172
- - test/dummy/config/initializers/inflections.rb
173
- - test/dummy/config/initializers/mime_types.rb
174
- - test/dummy/config/initializers/quo_vadis.rb
175
- - test/dummy/config/initializers/rack_patch.rb
176
- - test/dummy/config/initializers/secret_token.rb
177
- - test/dummy/config/initializers/session_store.rb
178
- - test/dummy/config/locales/en.yml
179
- - test/dummy/config/locales/quo_vadis.en.yml
180
- - test/dummy/config/routes.rb
181
- - test/dummy/db/migrate/20110124125037_create_users.rb
182
- - test/dummy/db/migrate/20110124131535_create_articles.rb
183
- - test/dummy/db/migrate/20110127094709_add_authentication_to_users.rb
184
- - test/dummy/db/migrate/20111004112209_create_people.rb
185
- - test/dummy/db/migrate/20111004132342_add_authentication_to_people.rb
186
- - test/dummy/db/schema.rb
187
- - test/dummy/public/404.html
188
- - test/dummy/public/422.html
189
- - test/dummy/public/500.html
190
- - test/dummy/public/favicon.ico
191
- - test/dummy/public/javascripts/application.js
192
- - test/dummy/public/javascripts/controls.js
193
- - test/dummy/public/javascripts/dragdrop.js
194
- - test/dummy/public/javascripts/effects.js
195
- - test/dummy/public/javascripts/prototype.js
196
- - test/dummy/public/javascripts/rails.js
197
- - test/dummy/public/stylesheets/.gitkeep
198
- - test/dummy/script/rails
199
- - test/integration/activation_test.rb
200
- - test/integration/authenticate_test.rb
201
- - test/integration/blocked_test.rb
202
- - test/integration/config_test.rb
203
- - test/integration/cookie_test.rb
204
- - test/integration/csrf_test.rb
205
- - test/integration/forgotten_test.rb
206
- - test/integration/helper_test.rb
207
- - test/integration/locale_test.rb
208
- - test/integration/navigation_test.rb
209
- - test/integration/sign_in_person_test.rb
210
- - test/integration/sign_in_test.rb
211
- - test/integration/sign_out_test.rb
212
- - test/integration/sign_up_test.rb
213
- - test/quo_vadis_test.rb
214
- - test/support/integration_case.rb
215
- - test/test_helper.rb
216
- - test/unit/user_test.rb
217
92
  homepage: https://github.com/airblade/quo_vadis
218
- licenses: []
93
+ licenses:
94
+ - MIT
219
95
  metadata: {}
220
96
  post_install_message:
221
97
  rdoc_options: []
@@ -232,84 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
108
  - !ruby/object:Gem::Version
233
109
  version: '0'
234
110
  requirements: []
235
- rubyforge_project: quo_vadis
236
- rubygems_version: 2.5.2.3
111
+ rubygems_version: 3.1.4
237
112
  signing_key:
238
113
  specification_version: 4
239
- summary: Simple username/password authentication for Rails 3.
240
- test_files:
241
- - test/dummy/.gitignore
242
- - test/dummy/Rakefile
243
- - test/dummy/app/controllers/application_controller.rb
244
- - test/dummy/app/controllers/articles_controller.rb
245
- - test/dummy/app/controllers/users_controller.rb
246
- - test/dummy/app/helpers/application_helper.rb
247
- - test/dummy/app/helpers/articles_helper.rb
248
- - test/dummy/app/models/article.rb
249
- - test/dummy/app/models/person.rb
250
- - test/dummy/app/models/user.rb
251
- - test/dummy/app/views/articles/index.html.erb
252
- - test/dummy/app/views/articles/new.html.erb
253
- - test/dummy/app/views/layouts/application.html.erb
254
- - test/dummy/app/views/layouts/sessions.html.erb
255
- - test/dummy/app/views/quo_vadis/notifier/change_password.text.erb
256
- - test/dummy/app/views/quo_vadis/notifier/invite.text.erb
257
- - test/dummy/app/views/sessions/edit.html.erb
258
- - test/dummy/app/views/sessions/forgotten.html.erb
259
- - test/dummy/app/views/sessions/invite.html.erb
260
- - test/dummy/app/views/sessions/new.html.erb
261
- - test/dummy/app/views/users/new.html.erb
262
- - test/dummy/config.ru
263
- - test/dummy/config/application.rb
264
- - test/dummy/config/boot.rb
265
- - test/dummy/config/database.yml
266
- - test/dummy/config/environment.rb
267
- - test/dummy/config/environments/development.rb
268
- - test/dummy/config/environments/production.rb
269
- - test/dummy/config/environments/test.rb
270
- - test/dummy/config/initializers/backtrace_silencers.rb
271
- - test/dummy/config/initializers/inflections.rb
272
- - test/dummy/config/initializers/mime_types.rb
273
- - test/dummy/config/initializers/quo_vadis.rb
274
- - test/dummy/config/initializers/rack_patch.rb
275
- - test/dummy/config/initializers/secret_token.rb
276
- - test/dummy/config/initializers/session_store.rb
277
- - test/dummy/config/locales/en.yml
278
- - test/dummy/config/locales/quo_vadis.en.yml
279
- - test/dummy/config/routes.rb
280
- - test/dummy/db/migrate/20110124125037_create_users.rb
281
- - test/dummy/db/migrate/20110124131535_create_articles.rb
282
- - test/dummy/db/migrate/20110127094709_add_authentication_to_users.rb
283
- - test/dummy/db/migrate/20111004112209_create_people.rb
284
- - test/dummy/db/migrate/20111004132342_add_authentication_to_people.rb
285
- - test/dummy/db/schema.rb
286
- - test/dummy/public/404.html
287
- - test/dummy/public/422.html
288
- - test/dummy/public/500.html
289
- - test/dummy/public/favicon.ico
290
- - test/dummy/public/javascripts/application.js
291
- - test/dummy/public/javascripts/controls.js
292
- - test/dummy/public/javascripts/dragdrop.js
293
- - test/dummy/public/javascripts/effects.js
294
- - test/dummy/public/javascripts/prototype.js
295
- - test/dummy/public/javascripts/rails.js
296
- - test/dummy/public/stylesheets/.gitkeep
297
- - test/dummy/script/rails
298
- - test/integration/activation_test.rb
299
- - test/integration/authenticate_test.rb
300
- - test/integration/blocked_test.rb
301
- - test/integration/config_test.rb
302
- - test/integration/cookie_test.rb
303
- - test/integration/csrf_test.rb
304
- - test/integration/forgotten_test.rb
305
- - test/integration/helper_test.rb
306
- - test/integration/locale_test.rb
307
- - test/integration/navigation_test.rb
308
- - test/integration/sign_in_person_test.rb
309
- - test/integration/sign_in_test.rb
310
- - test/integration/sign_out_test.rb
311
- - test/integration/sign_up_test.rb
312
- - test/quo_vadis_test.rb
313
- - test/support/integration_case.rb
314
- - test/test_helper.rb
315
- - 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