rodauth 2.45.0 → 2.47.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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rodauth/features/active_sessions.rb +2 -2
  3. data/lib/rodauth/features/audit_logging.rb +2 -1
  4. data/lib/rodauth/features/base.rb +65 -10
  5. data/lib/rodauth/features/change_password.rb +12 -2
  6. data/lib/rodauth/features/close_account_email.rb +17 -0
  7. data/lib/rodauth/features/confirm_password.rb +1 -1
  8. data/lib/rodauth/features/create_account.rb +2 -1
  9. data/lib/rodauth/features/email_auth.rb +13 -4
  10. data/lib/rodauth/features/email_base.rb +37 -3
  11. data/lib/rodauth/features/internal_request.rb +4 -0
  12. data/lib/rodauth/features/json.rb +5 -1
  13. data/lib/rodauth/features/jwt.rb +7 -1
  14. data/lib/rodauth/features/jwt_cors.rb +2 -0
  15. data/lib/rodauth/features/jwt_refresh.rb +35 -22
  16. data/lib/rodauth/features/lockout.rb +22 -19
  17. data/lib/rodauth/features/login.rb +12 -4
  18. data/lib/rodauth/features/login_password_requirements_base.rb +39 -9
  19. data/lib/rodauth/features/otp.rb +19 -10
  20. data/lib/rodauth/features/password_expiration.rb +0 -1
  21. data/lib/rodauth/features/password_grace_period.rb +7 -0
  22. data/lib/rodauth/features/password_pepper.rb +11 -1
  23. data/lib/rodauth/features/recovery_codes.rb +4 -1
  24. data/lib/rodauth/features/remember.rb +2 -0
  25. data/lib/rodauth/features/require_domain.rb +12 -0
  26. data/lib/rodauth/features/require_hmac_secret.rb +12 -0
  27. data/lib/rodauth/features/reset_password.rb +25 -20
  28. data/lib/rodauth/features/single_session.rb +6 -2
  29. data/lib/rodauth/features/sms_codes.rb +4 -1
  30. data/lib/rodauth/features/two_factor_base.rb +2 -1
  31. data/lib/rodauth/features/update_password_hash.rb +5 -1
  32. data/lib/rodauth/features/verify_account.rb +40 -22
  33. data/lib/rodauth/features/verify_login_change.rb +19 -11
  34. data/lib/rodauth/features/webauthn.rb +10 -5
  35. data/lib/rodauth/features/webauthn_login.rb +1 -5
  36. data/lib/rodauth/features/webauthn_verify_account.rb +0 -4
  37. data/lib/rodauth/version.rb +1 -1
  38. data/lib/rodauth.rb +2 -0
  39. data/templates/close-account-email.str +2 -0
  40. metadata +6 -2
@@ -74,15 +74,18 @@ module Rodauth
74
74
  end
75
75
 
76
76
  r.post do
77
- key = session[verify_login_change_session_key] || param(verify_login_change_key_param)
78
- unless account_from_verify_login_change_key(key)
79
- set_redirect_error_status(invalid_key_error_status)
80
- set_error_reason :invalid_verify_login_change_key
81
- set_redirect_error_flash verify_login_change_error_flash
82
- redirect verify_login_change_redirect
83
- end
77
+ key = session_param(verify_login_change_session_key, verify_login_change_key_param)
78
+ remove_session_value(verify_login_change_session_key)
79
+ select_key_for_update!
84
80
 
85
81
  transaction do
82
+ unless key && account_from_verify_login_change_key(key)
83
+ set_redirect_error_status(invalid_key_error_status)
84
+ set_error_reason :invalid_verify_login_change_key
85
+ set_redirect_error_flash verify_login_change_error_flash
86
+ redirect verify_login_change_redirect
87
+ end
88
+
86
89
  before_verify_login_change
87
90
  unless verify_login_change
88
91
  set_redirect_error_status(invalid_key_error_status)
@@ -98,7 +101,6 @@ module Rodauth
98
101
  autologin_session('verify_login_change')
99
102
  end
100
103
 
101
- remove_session_value(verify_login_change_session_key)
102
104
  verify_login_change_response
103
105
  end
104
106
  end
@@ -120,7 +122,7 @@ module Rodauth
120
122
  end
121
123
 
122
124
  def account_from_verify_login_change_key(key)
123
- @account = _account_from_verify_login_change_key(key)
125
+ set_account(_account_from_verify_login_change_key(key), :verify_login_change)
124
126
  end
125
127
 
126
128
  def send_verify_login_change_email(login)
@@ -132,7 +134,9 @@ module Rodauth
132
134
  end
133
135
 
134
136
  def get_verify_login_change_login_and_key(id)
135
- verify_login_change_ds(id).get([verify_login_change_login_column, verify_login_change_key_column])
137
+ ds = verify_login_change_ds(id)
138
+ ds.where(Sequel::CURRENT_TIMESTAMP > verify_login_change_deadline_column).delete
139
+ apply_key_for_update(ds).get([verify_login_change_login_column, verify_login_change_key_column])
136
140
  end
137
141
 
138
142
  def change_login_notice_flash
@@ -210,10 +214,14 @@ module Rodauth
210
214
  end
211
215
 
212
216
  def _account_from_verify_login_change_key(token)
213
- account_from_key(token) do |id|
217
+ account_from_key(token, verify_login_change_account_status_value) do |id|
214
218
  @verify_login_change_new_login, key = get_verify_login_change_login_and_key(id)
215
219
  key
216
220
  end
217
221
  end
222
+
223
+ def verify_login_change_account_status_value
224
+ account_open_status_value
225
+ end
218
226
  end
219
227
  end
@@ -4,7 +4,7 @@ require 'webauthn'
4
4
 
5
5
  module Rodauth
6
6
  Feature.define(:webauthn, :Webauthn) do
7
- depends :two_factor_base
7
+ depends :two_factor_base, :require_domain, :require_hmac_secret
8
8
 
9
9
  loaded_templates %w'webauthn-setup webauthn-auth webauthn-remove'
10
10
 
@@ -164,7 +164,7 @@ module Rodauth
164
164
  end
165
165
 
166
166
  route(:webauthn_setup) do |r|
167
- require_authentication unless two_factor_login_type_match?('webauthn')
167
+ require_authentication unless webauthn_modification_authenticated?
168
168
  require_account_session
169
169
  before_webauthn_setup_route
170
170
 
@@ -185,7 +185,7 @@ module Rodauth
185
185
  raise Sequel::Rollback
186
186
  end
187
187
 
188
- unless two_factor_authenticated?
188
+ if !two_factor_authenticated? && !authenticated_by.include?('webauthn')
189
189
  webauthn_update_session(webauthn_credential.id)
190
190
  two_factor_update_session('webauthn')
191
191
  end
@@ -205,7 +205,7 @@ module Rodauth
205
205
  end
206
206
 
207
207
  route(:webauthn_remove) do |r|
208
- require_authentication unless two_factor_login_type_match?('webauthn')
208
+ require_authentication unless webauthn_modification_authenticated?
209
209
  require_account_session
210
210
  require_webauthn_setup
211
211
  before_webauthn_remove_route
@@ -469,6 +469,11 @@ module Rodauth
469
469
  # :nocov:
470
470
  end
471
471
 
472
+ def webauthn_modification_authenticated?
473
+ two_factor_login_type_match?('webauthn') &&
474
+ (!uses_two_factor_authentication? || two_factor_modifications_require_password?)
475
+ end
476
+
472
477
  def _two_factor_auth_links
473
478
  links = super
474
479
  links << [10, webauthn_auth_path, webauthn_auth_link_text] if webauthn_setup? && !two_factor_login_type_match?('webauthn')
@@ -501,7 +506,7 @@ module Rodauth
501
506
  end
502
507
 
503
508
  def webauthn_account_id
504
- session_value
509
+ account_id_or_session_value
505
510
  end
506
511
 
507
512
  def webauthn_user_ids_ds
@@ -76,7 +76,7 @@ module Rodauth
76
76
  end
77
77
 
78
78
  def account_from_webauthn_login
79
- account_from_login(login_param_value)
79
+ @account_retrieval_type == :login ? @account : account_from_login(login_param_value)
80
80
  end
81
81
 
82
82
  def webauthn_login_options?
@@ -91,9 +91,5 @@ module Rodauth
91
91
  end
92
92
  forms
93
93
  end
94
-
95
- def webauthn_account_id
96
- super || account_id
97
- end
98
94
  end
99
95
  end
@@ -40,9 +40,5 @@ module Rodauth
40
40
  @webauthn_credential = webauthn_setup_credential_from_form_submission
41
41
  add_webauthn_credential(@webauthn_credential)
42
42
  end
43
-
44
- def webauthn_account_id
45
- super || account_id
46
- end
47
43
  end
48
44
  end
@@ -6,7 +6,7 @@ module Rodauth
6
6
  MAJOR = 2
7
7
 
8
8
  # The minor version of Rodauth, updated for new feature releases of Rodauth.
9
- MINOR = 45
9
+ MINOR = 47
10
10
 
11
11
  # The patch version of Rodauth, updated only for bug fixes from the last
12
12
  # feature release.
data/lib/rodauth.rb CHANGED
@@ -7,6 +7,8 @@ module Rodauth
7
7
  SCOPE_INSTANCE_VARIABLES = [:@_rodauths, :@_rodauth].freeze
8
8
 
9
9
  class ConfigurationError < StandardError; end
10
+ class Error < StandardError; end
11
+ class SetPasswordFailure < Error; end
10
12
 
11
13
  def self.lib(opts=OPTS, &block)
12
14
  require 'roda'
@@ -0,0 +1,2 @@
1
+ Someone (hopefully you) has closed the account associated to this
2
+ email address.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.45.0
4
+ version: 2.47.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
@@ -265,6 +265,7 @@ files:
265
265
  - lib/rodauth/features/change_password.rb
266
266
  - lib/rodauth/features/change_password_notify.rb
267
267
  - lib/rodauth/features/close_account.rb
268
+ - lib/rodauth/features/close_account_email.rb
268
269
  - lib/rodauth/features/confirm_password.rb
269
270
  - lib/rodauth/features/create_account.rb
270
271
  - lib/rodauth/features/disallow_common_passwords.rb
@@ -292,6 +293,8 @@ files:
292
293
  - lib/rodauth/features/path_class_methods.rb
293
294
  - lib/rodauth/features/recovery_codes.rb
294
295
  - lib/rodauth/features/remember.rb
296
+ - lib/rodauth/features/require_domain.rb
297
+ - lib/rodauth/features/require_hmac_secret.rb
295
298
  - lib/rodauth/features/reset_password.rb
296
299
  - lib/rodauth/features/reset_password_notify.rb
297
300
  - lib/rodauth/features/reset_password_verifies_account.rb
@@ -314,6 +317,7 @@ files:
314
317
  - templates/button.str
315
318
  - templates/change-login.str
316
319
  - templates/change-password.str
320
+ - templates/close-account-email.str
317
321
  - templates/close-account.str
318
322
  - templates/confirm-password.str
319
323
  - templates/create-account.str
@@ -403,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
403
407
  - !ruby/object:Gem::Version
404
408
  version: '0'
405
409
  requirements: []
406
- rubygems_version: 4.0.10
410
+ rubygems_version: 4.0.16
407
411
  specification_version: 4
408
412
  summary: Authentication and Account Management Framework for Rack Applications
409
413
  test_files: []