quo_vadis 2.2.0 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e9808f4e29d96b1c9deac895bb45ebacbeb046928f22851fe618593abb49fa4
4
- data.tar.gz: 38980863633e441f4c5d28c2fe03e5d8e6357afc4f4ddd4546f4492205aee48c
3
+ metadata.gz: f5f77cea22311c350e1a0671c147db092e3e6c46164a468bff88904eb5fdb742
4
+ data.tar.gz: 03f0d04ea03e4e84b45d83fb494959a02f0483b5fd145ff550200fdbb6639ab6
5
5
  SHA512:
6
- metadata.gz: cb68d8909ca3343ed508dbe5c0510860a358cb39398d2bb5b91f999c6a74935e8bb09d41a27de5bcdc1a3061cb280865ce146fa168fa88690fc37f030cd83a78
7
- data.tar.gz: 6b5e022eab6f659dd4620117595c9ff9b9527f532d6963b732d149db4316f833626cca40f5e89cd7b8071ebea7e87ff64462c71c8104628b033447debec7a2a2
6
+ metadata.gz: b96e1e5398ded302e9efb69c6e268307606535fc63346acc4faf0443098eb500c97daa107be2ccced4151078c90aac9917a72e037023aeea7cf460a7c706dde8
7
+ data.tar.gz: 6de70ddbe36d8c5334d1a6ab95da333ab59d28a98a0c1a57ca1c47e1375a156df5c689fbc66f90e70ea44d3e46e2a9af3ad4b4b8a7d8e86fd6ed27e2055ab5e4
data/CHANGELOG.md CHANGED
@@ -4,13 +4,27 @@
4
4
  ## HEAD
5
5
 
6
6
 
7
+ ## 2.2.2 (30 April 2024)
8
+
9
+ * Do not update last activity time for ActiveStorage (#23).
10
+ * Fix login success-flash to not be reset (#37).
11
+ * Add issue numbers to changelog entries.
12
+
13
+
14
+ ## 2.2.1 (1 August 2023)
15
+
16
+ * Do not clear application session data on logout (#34).
17
+ * Use 'email' type for email input fields.
18
+ * Document how to log out.
19
+
20
+
7
21
  ## 2.2.0 (17 April 2023)
8
22
 
9
23
  * Improve the readme with internal links and more section headings.
10
- * Rename `password_reset_token_lifetime` to `password_reset_otp_lifetime`.
11
- * Use OTP instead of link for password reset.
12
- * Rename `account_confirmation_token_lifetime` to `account_confirmation_otp_lifetime`.
13
- * Use OTP instead of link for account confirmation.
24
+ * Rename `password_reset_token_lifetime` to `password_reset_otp_lifetime` (#28).
25
+ * Use OTP instead of link for password reset (#28).
26
+ * Rename `account_confirmation_token_lifetime` to `account_confirmation_otp_lifetime` (#28).
27
+ * Use OTP instead of link for account confirmation (#28).
14
28
 
15
29
 
16
30
  ## 2.1.11 (14 September 2022)
@@ -20,18 +34,18 @@
20
34
 
21
35
  ## 2.1.10 (14 September 2022)
22
36
 
23
- * Enable configuration of mailer superclass.
37
+ * Enable configuration of mailer superclass (#30).
24
38
 
25
39
 
26
40
  ## 2.1.9 (13 September 2022)
27
41
 
28
- * Enable code to be run after sign up.
42
+ * Enable code to be run after sign up (#29).
29
43
 
30
44
 
31
45
  ## 2.1.8 (18 June 2022)
32
46
 
33
- * Extract convenience method for has authentication account.
34
- * Only authenticating models react to email change.
47
+ * Extract convenience method for has authentication account (#26).
48
+ * Only authenticating models react to email change (#26).
35
49
 
36
50
 
37
51
  ## 2.1.7 (30 May 2022)
@@ -47,7 +61,7 @@
47
61
 
48
62
  ## 2.1.5 (27 May 2022)
49
63
 
50
- * Order sessions list and display more information.
64
+ * Order sessions list and display more information (#25).
51
65
  * Set status 303 See Other on destroy redirects.
52
66
  * Streamline bundler instructions.
53
67
 
@@ -59,7 +73,7 @@
59
73
 
60
74
  ## 2.1.3 (30 September 2021)
61
75
 
62
- * Pass IP and timestamp as parameters to mailer.
76
+ * Pass IP and timestamp as parameters to mailer (#24).
63
77
 
64
78
 
65
79
  ## 2.1.2 (30 September 2021)
@@ -71,8 +85,8 @@
71
85
 
72
86
  * Remove unnecessary route names.
73
87
  * Add user revocation.
74
- * Ensure password is only updated via #change or #reset.
75
- * Move views into gem's app/views/ directory.
88
+ * Ensure password is only updated via #change or #reset (#15).
89
+ * Move views into gem's app/views/ directory (#22).
76
90
 
77
91
 
78
92
  ## 2.1.0 (25 June 2021)
@@ -90,8 +104,8 @@
90
104
 
91
105
  ## 2.0.2 (24 May 2021)
92
106
 
93
- * Account confirmation: enable updating of email address.
94
- * Account confirmation: enable direct resending of email.
107
+ * Account confirmation: enable updating of email address (#21).
108
+ * Account confirmation: enable direct resending of email (#21).
95
109
  * Log unknown identifier in metadata.
96
110
 
97
111
 
data/README.md CHANGED
@@ -171,7 +171,7 @@ Your new user sign-up form ([example](https://github.com/airblade/quo_vadis/blob
171
171
  - a field for their identifier;
172
172
  - an `:email` field if the identifier is not their email.
173
173
 
174
- In your controller, use the [`#login`](#loginmodel-browser_session-%3D-true) method to log in your new user. The optional second argument specifies for how long the user should be logged in, and any metadata you supply is logged in the audit log.
174
+ In your controller, use the [`#login`](#loginmodel-browser_session--true-metadata-) method to log in your new user. The optional second argument specifies for how long the user should be logged in, and any metadata you supply is logged in the audit log.
175
175
 
176
176
  After logging in the user, redirect them wherever you like. You can use `qv.path_after_signup` which resolves to the first of these routes that exists: `:after_signup`, `:after_login`, the root route.
177
177
 
@@ -238,6 +238,40 @@ After authenticating the user will be redirected to the first of these that exis
238
238
  - your root route.
239
239
 
240
240
 
241
+ ### Logout
242
+
243
+ Send a DELETE request to `quo_vadis.logout_path`. For example:
244
+
245
+ ```ruby
246
+ button_to 'Log out', quo_vadis.logout_path, method: :delete
247
+ ```
248
+
249
+ Note you are responsible for removing any application session data you want removed. To do so, subclass `QuoVadis::SessionsController` and override the `destroy` method:
250
+
251
+ ```ruby
252
+ # app/controllers/custom_sessions_controller.rb
253
+ class CustomSessionsController < QuoVadis::SessionsController
254
+ def destroy
255
+ reset_session
256
+ super
257
+ end
258
+ end
259
+ ```
260
+
261
+ Add a route:
262
+
263
+ ```ruby
264
+ # config/routes.rb
265
+ delete 'logout', to: 'custom_sessions#destroy'
266
+ ```
267
+
268
+ And then point your log out button at your custom action:
269
+
270
+ ```ruby
271
+ button_to 'Log out', main_app.logout_path, method: :delete
272
+ ```
273
+
274
+
241
275
  ### Two-factor authentication (2FA) or Two-step verification (2SV)
242
276
 
243
277
  If you do not want 2FA at all, set `QuoVadis.two_factor_authentication_mandatory false` in your configuration and skip the rest of this section.
@@ -490,6 +524,6 @@ If you don't want a specific flash message at all, give the key an empty value i
490
524
 
491
525
  ## Intellectual Property
492
526
 
493
- Copyright 2011-2022 Andrew Stewart (boss@airbladesoftware.com).
527
+ Copyright Andrew Stewart (boss@airbladesoftware.com).
494
528
 
495
529
  Released under the MIT licence.
@@ -39,10 +39,10 @@ module QuoVadis
39
39
  # params[:remember] == 1 => use QuoVadis.session_lifetime
40
40
  browser_session = params[:remember] == '0'
41
41
 
42
- flash[:notice] = QuoVadis.translate 'flash.login.success'
43
-
44
42
  login account.model, browser_session
45
43
 
44
+ flash[:notice] = QuoVadis.translate 'flash.login.success'
45
+
46
46
  redirect_to qv.path_after_authentication
47
47
  end
48
48
 
@@ -3,7 +3,7 @@
3
3
  <%= form_with url: password_reset_path, method: :post do |f| %>
4
4
  <p>
5
5
  <%= f.label :email %>
6
- <%= f.text_field :email, inputmode: 'email', autocomplete: 'email' %>
6
+ <%= f.text_field :email, type: 'email', inputmode: 'email', autocomplete: 'email' %>
7
7
  </p>
8
8
 
9
9
  <p>
@@ -3,7 +3,7 @@
3
3
  <%= form_with url: login_path, method: :post do |f| %>
4
4
  <p>
5
5
  <%= f.label :email %>
6
- <%= f.text_field :email, inputmode: 'email', autocomplete: 'email' %>
6
+ <%= f.text_field :email, type: 'email', inputmode: 'email', autocomplete: 'email' %>
7
7
  </p>
8
8
 
9
9
  <p>
@@ -11,7 +11,13 @@ module QuoVadis
11
11
  # Remember the last activity time so we can timeout idle sessions.
12
12
  # This has to be done after that timestamp is checked (in `#authenticated_model`)
13
13
  # otherwise sessions could never look idle.
14
- base.after_action { |controller| controller.qv.touch_session_last_seen_at }
14
+ #
15
+ # Ignores ActiveStorage requests.
16
+ base.after_action { |controller|
17
+ if !defined?(::ActiveStorage) || !controller.class.module_parents.include?(::ActiveStorage)
18
+ controller.qv.touch_session_last_seen_at
19
+ end
20
+ }
15
21
  end
16
22
 
17
23
 
@@ -190,7 +196,7 @@ module QuoVadis
190
196
  def logout
191
197
  session&.destroy
192
198
  clear_session_id
193
- reset_session
199
+ prevent_rails_session_fixation
194
200
  controller.instance_variable_set :@authenticated_model, nil
195
201
  end
196
202
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QuoVadis
4
- VERSION = '2.2.0'
4
+ VERSION = '2.2.2'
5
5
  end
data/test/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # Testing
2
+
3
+ Run tests with:
4
+
5
+ bundle exec rails test
6
+
@@ -6,6 +6,7 @@ class ArticlesController < ApplicationController
6
6
  end
7
7
 
8
8
  def secret
9
+ session[:foo] = 'bar'
9
10
  end
10
11
 
11
12
  def also_secret
@@ -69,6 +69,22 @@ class SessionsTest < IntegrationTest
69
69
  end
70
70
 
71
71
 
72
+ test 'non-authentication session data is not removed on logout' do
73
+ desktop = login
74
+ session_id = desktop.session.id
75
+
76
+ desktop.get secret_articles_path
77
+ assert_equal 'bar', desktop.session[:foo]
78
+
79
+ desktop.delete quo_vadis.logout_path
80
+ refute desktop.controller.logged_in?
81
+
82
+ desktop.get articles_path
83
+ assert_equal 'bar', desktop.session[:foo]
84
+ refute_equal session_id, desktop.session.id
85
+ end
86
+
87
+
72
88
  private
73
89
 
74
90
  # starts a new rails session and logs in
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quo_vadis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-17 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -136,6 +136,7 @@ files:
136
136
  - lib/quo_vadis/model.rb
137
137
  - lib/quo_vadis/version.rb
138
138
  - quo_vadis.gemspec
139
+ - test/README.md
139
140
  - test/dummy/README.markdown
140
141
  - test/dummy/Rakefile
141
142
  - test/dummy/app/controllers/application_controller.rb
@@ -218,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
219
  - !ruby/object:Gem::Version
219
220
  version: '0'
220
221
  requirements: []
221
- rubygems_version: 3.2.33
222
+ rubygems_version: 3.5.3
222
223
  signing_key:
223
224
  specification_version: 4
224
225
  summary: Multifactor authentication for Rails 6 and 7.