rodauth 2.47.0 → 2.49.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.
- checksums.yaml +4 -4
- data/lib/rodauth/features/argon2.rb +6 -6
- data/lib/rodauth/features/audit_logging.rb +2 -2
- data/lib/rodauth/features/base.rb +24 -25
- data/lib/rodauth/features/disallow_password_reuse.rb +2 -2
- data/lib/rodauth/features/http_basic_auth.rb +6 -1
- data/lib/rodauth/features/jwt.rb +2 -2
- data/lib/rodauth/features/lockout.rb +2 -2
- data/lib/rodauth/features/login_password_requirements_base.rb +6 -6
- data/lib/rodauth/features/otp.rb +6 -6
- data/lib/rodauth/features/otp_unlock.rb +2 -2
- data/lib/rodauth/features/password_complexity.rb +2 -2
- data/lib/rodauth/features/password_grace_period.rb +2 -1
- data/lib/rodauth/features/remember.rb +2 -2
- data/lib/rodauth/features/update_password_hash.rb +2 -0
- data/lib/rodauth/features/verify_account.rb +1 -1
- data/lib/rodauth/features/webauthn.rb +6 -6
- data/lib/rodauth/version.rb +1 -1
- data/lib/rodauth.rb +44 -22
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 24077da1fc384a74f6e692220eeac283243ce13c0d219befdbd43c4a3498ab63
|
|
4
|
+
data.tar.gz: b05d593e3e12ebcf503c8de530613dea813cfa90984c058d1910bab7cb010674
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e6d8819e37fd3d417641dc1745360c9ff52df0ee90399ad844ad7d3c23990d1c74f9db31d698e17861881e8776f5fb3fb4aae07ab4d9e2762e257ffd334d51f
|
|
7
|
+
data.tar.gz: 902ece75d3590486435729195e741834c4613d379f47ca29b93ba68281810273b36ae94374c9c9b317ca49464e60c1be15d344b88c94bada8fd1f8ea5668dde1
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
require 'argon2'
|
|
4
4
|
|
|
5
|
-
# :
|
|
5
|
+
# simplecov:disable
|
|
6
6
|
if !defined?(Argon2::VERSION) || Argon2::VERSION < '2'
|
|
7
7
|
raise LoadError, "argon2 version 1.x not supported as it does not support argon2id hashes"
|
|
8
8
|
end
|
|
9
|
-
# :
|
|
9
|
+
# simplecov:enable
|
|
10
10
|
|
|
11
11
|
module Rodauth
|
|
12
12
|
Feature.define(:argon2, :Argon2) do
|
|
@@ -36,12 +36,12 @@ module Rodauth
|
|
|
36
36
|
def argon2_salt_option
|
|
37
37
|
:salt_do_not_supply
|
|
38
38
|
end
|
|
39
|
-
# :
|
|
39
|
+
# simplecov:disable
|
|
40
40
|
else
|
|
41
41
|
def argon2_salt_option
|
|
42
42
|
:salt_for_testing_purposes_only
|
|
43
43
|
end
|
|
44
|
-
# :
|
|
44
|
+
# simplecov:enable
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def password_hash_cost
|
|
@@ -78,7 +78,7 @@ module Rodauth
|
|
|
78
78
|
def argon2_hash_cost
|
|
79
79
|
{ t_cost: 1, m_cost: 5, p_cost: 1 }
|
|
80
80
|
end
|
|
81
|
-
# :
|
|
81
|
+
# simplecov:disable
|
|
82
82
|
else
|
|
83
83
|
def argon2_hash_cost
|
|
84
84
|
{ t_cost: 2, m_cost: 16, p_cost: 1 }
|
|
@@ -102,7 +102,7 @@ module Rodauth
|
|
|
102
102
|
end
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
|
-
# :
|
|
105
|
+
# simplecov:enable
|
|
106
106
|
|
|
107
107
|
def argon2_hash_algorithm?(hash)
|
|
108
108
|
hash.start_with?('$argon2id$')
|
|
@@ -83,9 +83,9 @@ module Rodauth
|
|
|
83
83
|
|
|
84
84
|
def audit_log_ds
|
|
85
85
|
ds = db[audit_logging_table]
|
|
86
|
-
# :
|
|
86
|
+
# simplecov:disable
|
|
87
87
|
if db.database_type == :postgres
|
|
88
|
-
# :
|
|
88
|
+
# simplecov:enable
|
|
89
89
|
# For PostgreSQL, use RETURNING NULL. This allows the feature
|
|
90
90
|
# to be used with INSERT but not SELECT permissions on the
|
|
91
91
|
# table, useful for audit logging where the database user
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
begin
|
|
4
4
|
require "rack/version"
|
|
5
|
-
# :
|
|
5
|
+
# simplecov:disable
|
|
6
6
|
rescue LoadError
|
|
7
7
|
require "rack"
|
|
8
8
|
else
|
|
@@ -13,7 +13,7 @@ else
|
|
|
13
13
|
require "rack"
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
|
-
# :
|
|
16
|
+
# simplecov:enable
|
|
17
17
|
|
|
18
18
|
module Rodauth
|
|
19
19
|
Feature.define(:base, :Base) do
|
|
@@ -443,9 +443,9 @@ module Rodauth
|
|
|
443
443
|
if use_request_specific_csrf_tokens?
|
|
444
444
|
scope.csrf_tag(path)
|
|
445
445
|
else
|
|
446
|
-
# :
|
|
446
|
+
# simplecov:disable
|
|
447
447
|
scope.csrf_tag
|
|
448
|
-
# :
|
|
448
|
+
# simplecov:enable
|
|
449
449
|
end
|
|
450
450
|
end
|
|
451
451
|
|
|
@@ -472,7 +472,7 @@ module Rodauth
|
|
|
472
472
|
end
|
|
473
473
|
|
|
474
474
|
def only_json?
|
|
475
|
-
scope.class.
|
|
475
|
+
scope.class.rodauth_json == :only
|
|
476
476
|
end
|
|
477
477
|
|
|
478
478
|
def post_configure
|
|
@@ -623,7 +623,7 @@ module Rodauth
|
|
|
623
623
|
def convert_response_header_key(key)
|
|
624
624
|
key
|
|
625
625
|
end
|
|
626
|
-
# :
|
|
626
|
+
# simplecov:disable
|
|
627
627
|
else
|
|
628
628
|
def set_response_header(key, value)
|
|
629
629
|
response.headers[convert_response_header_key(key)] = value
|
|
@@ -650,13 +650,13 @@ module Rodauth
|
|
|
650
650
|
mixed_case_headers.fetch(key, key)
|
|
651
651
|
end
|
|
652
652
|
end
|
|
653
|
-
# :
|
|
653
|
+
# simplecov:enable
|
|
654
654
|
|
|
655
655
|
if RUBY_VERSION >= '2.1'
|
|
656
656
|
def button_fixed_locals
|
|
657
657
|
'(value:, opts:)'
|
|
658
658
|
end
|
|
659
|
-
# :
|
|
659
|
+
# simplecov:disable
|
|
660
660
|
else
|
|
661
661
|
# Work on Ruby 2.0 when using Tilt 2.6+, as Ruby 2.0 does
|
|
662
662
|
# not support required keyword arguments.
|
|
@@ -664,7 +664,7 @@ module Rodauth
|
|
|
664
664
|
'(value: nil, opts: nil)'
|
|
665
665
|
end
|
|
666
666
|
end
|
|
667
|
-
# :
|
|
667
|
+
# simplecov:enable
|
|
668
668
|
|
|
669
669
|
def missing_recommended_configuration(msg)
|
|
670
670
|
# RODAUTH3: switch to raise ConfigurationError
|
|
@@ -674,7 +674,6 @@ module Rodauth
|
|
|
674
674
|
def account_reload(current_retrieval_type, new_retrieval_type)
|
|
675
675
|
return unless @current_route
|
|
676
676
|
|
|
677
|
-
|
|
678
677
|
if current_retrieval_type == new_retrieval_type
|
|
679
678
|
warn "account retrieved multiple times during rodauth route with retrieval type #{current_retrieval_type}"
|
|
680
679
|
else
|
|
@@ -770,7 +769,7 @@ module Rodauth
|
|
|
770
769
|
end
|
|
771
770
|
|
|
772
771
|
def require_account_session
|
|
773
|
-
unless account_from_session
|
|
772
|
+
unless (@account_retrieval_type == :session ? account : account_from_session)
|
|
774
773
|
clear_session
|
|
775
774
|
login_required
|
|
776
775
|
end
|
|
@@ -828,25 +827,25 @@ module Rodauth
|
|
|
828
827
|
when :postgres, :mysql, :mssql
|
|
829
828
|
true
|
|
830
829
|
else
|
|
831
|
-
# :
|
|
830
|
+
# simplecov:disable
|
|
832
831
|
false
|
|
833
|
-
# :
|
|
832
|
+
# simplecov:enable
|
|
834
833
|
end
|
|
835
834
|
end
|
|
836
835
|
|
|
837
836
|
def use_request_specific_csrf_tokens?
|
|
838
|
-
scope.
|
|
837
|
+
scope.class.rodauth_route_csrf? && scope.use_request_specific_csrf_tokens?
|
|
839
838
|
end
|
|
840
839
|
|
|
841
840
|
def check_csrf?
|
|
842
|
-
scope.
|
|
841
|
+
scope.class.rodauth_route_csrf?
|
|
843
842
|
end
|
|
844
843
|
|
|
845
844
|
def function_name(name)
|
|
846
845
|
if db.database_type == :mssql
|
|
847
|
-
# :
|
|
846
|
+
# simplecov:disable
|
|
848
847
|
"dbo.#{name}"
|
|
849
|
-
# :
|
|
848
|
+
# simplecov:enable
|
|
850
849
|
else
|
|
851
850
|
name
|
|
852
851
|
end
|
|
@@ -864,9 +863,9 @@ module Rodauth
|
|
|
864
863
|
elsif use_database_authentication_functions?
|
|
865
864
|
db.get(Sequel.function(function_name(:rodauth_get_salt), account_id_or_session_value))
|
|
866
865
|
else
|
|
867
|
-
# :
|
|
866
|
+
# simplecov:disable
|
|
868
867
|
password_hash_ds.get(password_hash_column)
|
|
869
|
-
# :
|
|
868
|
+
# simplecov:enable
|
|
870
869
|
end
|
|
871
870
|
end
|
|
872
871
|
|
|
@@ -977,9 +976,9 @@ module Rodauth
|
|
|
977
976
|
# UniqueConstraintViolation.
|
|
978
977
|
def unique_constraint_violation_class
|
|
979
978
|
if db.adapter_scheme == :jdbc && db.database_type == :sqlite
|
|
980
|
-
# :
|
|
979
|
+
# simplecov:disable
|
|
981
980
|
Sequel::ConstraintViolation
|
|
982
|
-
# :
|
|
981
|
+
# simplecov:enable
|
|
983
982
|
else
|
|
984
983
|
Sequel::UniqueConstraintViolation
|
|
985
984
|
end
|
|
@@ -995,9 +994,9 @@ module Rodauth
|
|
|
995
994
|
# CURRENT_TIMESTAMP.
|
|
996
995
|
def set_deadline_value(hash, column, interval)
|
|
997
996
|
if set_deadline_values?
|
|
998
|
-
# :
|
|
997
|
+
# simplecov:disable
|
|
999
998
|
hash[column] = Sequel.date_add(Sequel::CURRENT_TIMESTAMP, interval)
|
|
1000
|
-
# :
|
|
999
|
+
# simplecov:enable
|
|
1001
1000
|
end
|
|
1002
1001
|
end
|
|
1003
1002
|
|
|
@@ -1023,9 +1022,9 @@ module Rodauth
|
|
|
1023
1022
|
end
|
|
1024
1023
|
end
|
|
1025
1024
|
|
|
1026
|
-
# :
|
|
1025
|
+
# simplecov:disable
|
|
1027
1026
|
if RUBY_VERSION >= '4.0'
|
|
1028
|
-
# :
|
|
1027
|
+
# simplecov:enable
|
|
1029
1028
|
def instance_variables_to_inspect
|
|
1030
1029
|
instance_variables.reject{|v| instance_variable_get(v).nil?}
|
|
1031
1030
|
end
|
|
@@ -59,11 +59,11 @@ module Rodauth
|
|
|
59
59
|
database_function_password_match?(:rodauth_previous_password_hash_match, hash_id, password, salt)
|
|
60
60
|
end
|
|
61
61
|
else
|
|
62
|
-
# :
|
|
62
|
+
# simplecov:disable
|
|
63
63
|
previous_password_ds.select_map(previous_password_hash_column).any? do |hash|
|
|
64
64
|
password_hash_match?(hash, password)
|
|
65
65
|
end
|
|
66
|
-
# :
|
|
66
|
+
# simplecov:enable
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
return true unless match
|
|
@@ -4,13 +4,14 @@ module Rodauth
|
|
|
4
4
|
Feature.define(:http_basic_auth, :HttpBasicAuth) do
|
|
5
5
|
auth_value_method :http_basic_auth_realm, "protected"
|
|
6
6
|
auth_value_method :require_http_basic_auth?, false
|
|
7
|
+
auth_value_method :logged_in_fallback_to_http_basic_auth?, true # RODAUTH3: false
|
|
7
8
|
|
|
8
9
|
uses_instance_variables(:@checked_http_basic_auth)
|
|
9
10
|
|
|
10
11
|
def logged_in?
|
|
11
12
|
ret = super
|
|
12
13
|
|
|
13
|
-
if !ret && @checked_http_basic_auth.nil?
|
|
14
|
+
if !ret && logged_in_fallback_to_http_basic_auth? && @checked_http_basic_auth.nil?
|
|
14
15
|
http_basic_auth
|
|
15
16
|
ret = super
|
|
16
17
|
end
|
|
@@ -33,6 +34,10 @@ module Rodauth
|
|
|
33
34
|
end
|
|
34
35
|
end
|
|
35
36
|
|
|
37
|
+
def account_from_session
|
|
38
|
+
@checked_http_basic_auth ? @account : super
|
|
39
|
+
end
|
|
40
|
+
|
|
36
41
|
def http_basic_auth
|
|
37
42
|
unless @checked_http_basic_auth.nil?
|
|
38
43
|
return (@checked_http_basic_auth ? true : nil)
|
data/lib/rodauth/features/jwt.rb
CHANGED
|
@@ -187,11 +187,11 @@ module Rodauth
|
|
|
187
187
|
with_sql(:update_sql, account_login_failures_number_column=>Sequel.expr(account_login_failures_number_column)+1).
|
|
188
188
|
single_value
|
|
189
189
|
else
|
|
190
|
-
# :
|
|
190
|
+
# simplecov:disable
|
|
191
191
|
if ds.update(account_login_failures_number_column=>Sequel.expr(account_login_failures_number_column)+1) > 0
|
|
192
192
|
ds.get(account_login_failures_number_column)
|
|
193
193
|
end
|
|
194
|
-
# :
|
|
194
|
+
# simplecov:enable
|
|
195
195
|
end
|
|
196
196
|
|
|
197
197
|
unless number
|
|
@@ -81,10 +81,10 @@ module Rodauth
|
|
|
81
81
|
if @existing_password_hash_or_salt
|
|
82
82
|
existing_expression = if use_database_authentication_functions?
|
|
83
83
|
Sequel.function(function_name(:rodauth_get_salt), :id)
|
|
84
|
-
# :
|
|
84
|
+
# simplecov:disable
|
|
85
85
|
else
|
|
86
86
|
password_hash_column
|
|
87
|
-
# :
|
|
87
|
+
# simplecov:enable
|
|
88
88
|
end
|
|
89
89
|
ds = ds.where(existing_expression => @existing_password_hash_or_salt)
|
|
90
90
|
end
|
|
@@ -159,12 +159,12 @@ module Rodauth
|
|
|
159
159
|
def login_confirmation_matches?(login, login_confirmation)
|
|
160
160
|
login.casecmp?(login_confirmation)
|
|
161
161
|
end
|
|
162
|
-
# :
|
|
162
|
+
# simplecov:disable
|
|
163
163
|
else
|
|
164
164
|
def login_confirmation_matches?(login, login_confirmation)
|
|
165
165
|
login.casecmp(login_confirmation) == 0
|
|
166
166
|
end
|
|
167
|
-
# :
|
|
167
|
+
# simplecov:enable
|
|
168
168
|
end
|
|
169
169
|
|
|
170
170
|
def login_meets_length_requirements?(login)
|
|
@@ -223,11 +223,11 @@ module Rodauth
|
|
|
223
223
|
BCrypt::Engine::MIN_COST
|
|
224
224
|
end
|
|
225
225
|
else
|
|
226
|
-
# :
|
|
226
|
+
# simplecov:disable
|
|
227
227
|
def password_hash_cost
|
|
228
228
|
BCrypt::Engine::DEFAULT_COST
|
|
229
229
|
end
|
|
230
|
-
# :
|
|
230
|
+
# simplecov:enable
|
|
231
231
|
end
|
|
232
232
|
|
|
233
233
|
def extract_password_hash_cost(hash)
|
data/lib/rodauth/features/otp.rb
CHANGED
|
@@ -270,17 +270,17 @@ module Rodauth
|
|
|
270
270
|
return false unless otp_exists?
|
|
271
271
|
ot_pass = ot_pass.gsub(/\s+/, '')
|
|
272
272
|
if drift = otp_drift
|
|
273
|
-
# :
|
|
273
|
+
# simplecov:disable
|
|
274
274
|
if otp.respond_to?(:verify_with_drift)
|
|
275
275
|
otp.verify_with_drift(ot_pass, drift)
|
|
276
|
-
# :
|
|
276
|
+
# simplecov:enable
|
|
277
277
|
else
|
|
278
278
|
otp.verify(ot_pass, :drift_behind=>drift, :drift_ahead=>drift, :after=>otp_last_use)
|
|
279
279
|
end
|
|
280
|
-
# :
|
|
280
|
+
# simplecov:disable
|
|
281
281
|
elsif otp.respond_to?(:verify_with_drift)
|
|
282
282
|
otp.verify(ot_pass)
|
|
283
|
-
# :
|
|
283
|
+
# simplecov:enable
|
|
284
284
|
else
|
|
285
285
|
otp.verify(ot_pass, :after=>otp_last_use)
|
|
286
286
|
end
|
|
@@ -413,11 +413,11 @@ module Rodauth
|
|
|
413
413
|
ROTP::Base32.random_base32.downcase
|
|
414
414
|
end
|
|
415
415
|
else
|
|
416
|
-
# :
|
|
416
|
+
# simplecov:disable
|
|
417
417
|
def otp_new_secret
|
|
418
418
|
ROTP::Base32.random.downcase
|
|
419
419
|
end
|
|
420
|
-
# :
|
|
420
|
+
# simplecov:enable
|
|
421
421
|
end
|
|
422
422
|
|
|
423
423
|
def base32_encode(data, length)
|
|
@@ -181,9 +181,9 @@ module Rodauth
|
|
|
181
181
|
end
|
|
182
182
|
|
|
183
183
|
@otp_unlock_data = nil
|
|
184
|
-
# :
|
|
184
|
+
# simplecov:disable
|
|
185
185
|
if otp_unlock_data
|
|
186
|
-
# :
|
|
186
|
+
# simplecov:enable
|
|
187
187
|
if otp_unlock_num_successes >= otp_unlock_auths_required
|
|
188
188
|
# At least the requisite number of consecutive successful unlock
|
|
189
189
|
# authentications. Unlock OTP authentication.
|
|
@@ -33,9 +33,9 @@ module Rodauth
|
|
|
33
33
|
# nothing
|
|
34
34
|
when nil
|
|
35
35
|
default_dictionary_file = '/usr/share/dict/words'
|
|
36
|
-
# :
|
|
36
|
+
# simplecov:disable
|
|
37
37
|
if File.file?(default_dictionary_file)
|
|
38
|
-
# :
|
|
38
|
+
# simplecov:enable
|
|
39
39
|
words = File.read(default_dictionary_file)
|
|
40
40
|
end
|
|
41
41
|
else
|
|
@@ -34,8 +34,9 @@ module Rodauth
|
|
|
34
34
|
private
|
|
35
35
|
|
|
36
36
|
def new_password_matches_current_password?(_)
|
|
37
|
+
last_password_entry = session[last_password_entry_session_key]
|
|
37
38
|
if v = super
|
|
38
|
-
|
|
39
|
+
set_session_value(last_password_entry_session_key, last_password_entry)
|
|
39
40
|
end
|
|
40
41
|
v
|
|
41
42
|
end
|
|
@@ -70,9 +70,9 @@ module Rodauth
|
|
|
70
70
|
if [remember_remember_param_value, remember_forget_param_value, remember_disable_param_value].include?(remember)
|
|
71
71
|
transaction do
|
|
72
72
|
before_remember
|
|
73
|
-
# :
|
|
73
|
+
# simplecov:disable
|
|
74
74
|
case remember
|
|
75
|
-
# :
|
|
75
|
+
# simplecov:enable
|
|
76
76
|
when remember_remember_param_value
|
|
77
77
|
remember_login
|
|
78
78
|
when remember_forget_param_value
|
|
@@ -265,7 +265,7 @@ module Rodauth
|
|
|
265
265
|
|
|
266
266
|
def _login_form_footer_links
|
|
267
267
|
links = super
|
|
268
|
-
if !param_or_nil(login_param) || ((account || account_from_login(login_param_value)) && allow_resending_verify_account_email?)
|
|
268
|
+
if !param_or_nil(login_param) || ((account || (@account_retrieval_type != :login && account_from_login(login_param_value))) && allow_resending_verify_account_email?)
|
|
269
269
|
links << [30, verify_account_resend_path, verify_account_resend_link_text]
|
|
270
270
|
end
|
|
271
271
|
links
|
|
@@ -290,9 +290,9 @@ module Rodauth
|
|
|
290
290
|
# it is safe for the second one to use the webauthn user id inserted by the other request.
|
|
291
291
|
# If there is still no webauthn user id at this point, then we'll just reraise the
|
|
292
292
|
# exception.
|
|
293
|
-
# :
|
|
293
|
+
# simplecov:disable
|
|
294
294
|
raise e unless webauthn_id = webauthn_user_ids_ds.get(webauthn_user_ids_webauthn_id_column)
|
|
295
|
-
# :
|
|
295
|
+
# simplecov:enable
|
|
296
296
|
end
|
|
297
297
|
end
|
|
298
298
|
|
|
@@ -419,7 +419,7 @@ module Rodauth
|
|
|
419
419
|
name: webauthn_rp_name,
|
|
420
420
|
)
|
|
421
421
|
end
|
|
422
|
-
# :
|
|
422
|
+
# simplecov:disable
|
|
423
423
|
else
|
|
424
424
|
def webauthn_relying_party
|
|
425
425
|
WebAuthn::RelyingParty.new(
|
|
@@ -428,7 +428,7 @@ module Rodauth
|
|
|
428
428
|
name: webauthn_rp_name,
|
|
429
429
|
)
|
|
430
430
|
end
|
|
431
|
-
# :
|
|
431
|
+
# simplecov:enable
|
|
432
432
|
end
|
|
433
433
|
|
|
434
434
|
def webauthn_create_relying_party_opts
|
|
@@ -443,7 +443,7 @@ module Rodauth
|
|
|
443
443
|
def _override_webauthn_credential_response_verify(webauthn_credential)
|
|
444
444
|
# no need to override
|
|
445
445
|
end
|
|
446
|
-
# :
|
|
446
|
+
# simplecov:disable
|
|
447
447
|
else
|
|
448
448
|
def webauthn_create_relying_party_opts
|
|
449
449
|
{:rp => {:name=>webauthn_rp_name, :id=>webauthn_rp_id}}
|
|
@@ -466,7 +466,7 @@ module Rodauth
|
|
|
466
466
|
super(expected_challenge, expected_origin || origin, **kw)
|
|
467
467
|
end
|
|
468
468
|
end
|
|
469
|
-
# :
|
|
469
|
+
# simplecov:enable
|
|
470
470
|
end
|
|
471
471
|
|
|
472
472
|
def webauthn_modification_authenticated?
|
data/lib/rodauth/version.rb
CHANGED
data/lib/rodauth.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen-string-literal: true
|
|
2
2
|
|
|
3
3
|
require 'securerandom'
|
|
4
|
+
require 'roda'
|
|
4
5
|
|
|
5
6
|
module Rodauth
|
|
6
7
|
OPTS = {}.freeze
|
|
@@ -22,7 +23,7 @@ module Rodauth
|
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
def self.load_dependencies(app, opts=OPTS, &_)
|
|
25
|
-
json_opt = opts.fetch(:json
|
|
26
|
+
json_opt = opts.fetch(:json){app.opts[:rodauth_json]}
|
|
26
27
|
if json_opt
|
|
27
28
|
app.plugin :json
|
|
28
29
|
app.plugin :json_parser
|
|
@@ -34,13 +35,13 @@ module Rodauth
|
|
|
34
35
|
app.plugin :render
|
|
35
36
|
end
|
|
36
37
|
|
|
37
|
-
case opts.fetch(:csrf
|
|
38
|
+
case opts.fetch(:csrf){app.opts[:rodauth_csrf]}
|
|
38
39
|
when false
|
|
39
40
|
# nothing
|
|
40
41
|
when :rack_csrf
|
|
41
|
-
# :
|
|
42
|
+
# simplecov:disable
|
|
42
43
|
app.plugin :csrf
|
|
43
|
-
# :
|
|
44
|
+
# simplecov:enable
|
|
44
45
|
else
|
|
45
46
|
app.plugin :route_csrf
|
|
46
47
|
end
|
|
@@ -51,22 +52,23 @@ module Rodauth
|
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
def self.configure(app, opts=OPTS, &block)
|
|
54
|
-
json_opt = app.opts[:rodauth_json] = opts.fetch(:json
|
|
55
|
-
csrf = app.opts[:rodauth_csrf] = opts.fetch(:csrf
|
|
55
|
+
json_opt = app.opts[:rodauth_json] = opts.fetch(:json){app.rodauth_json}
|
|
56
|
+
csrf = app.opts[:rodauth_csrf] = opts.fetch(:csrf){app.opts[:rodauth_csrf]}
|
|
56
57
|
app.opts[:rodauth_route_csrf] = case csrf
|
|
57
58
|
when false, :rack_csrf
|
|
58
59
|
false
|
|
59
60
|
else
|
|
60
61
|
json_opt != :only
|
|
61
62
|
end
|
|
62
|
-
|
|
63
|
+
name = opts[:name]
|
|
64
|
+
auth_class = (app.opts[:rodauths] ||= {})[name] ||= opts[:auth_class] || Class.new(Auth)
|
|
63
65
|
if !auth_class.roda_class
|
|
64
66
|
auth_class.roda_class = app
|
|
65
67
|
elsif auth_class.roda_class != app
|
|
66
|
-
auth_class = app.
|
|
68
|
+
auth_class = app.rodauths[name] = Class.new(auth_class)
|
|
67
69
|
auth_class.roda_class = app
|
|
68
70
|
end
|
|
69
|
-
auth_class.class_eval{@configuration_name =
|
|
71
|
+
auth_class.class_eval{@configuration_name = name unless defined?(@configuration_name)}
|
|
70
72
|
auth_class.configure(&block) if block
|
|
71
73
|
auth_class.send(:make_shape_friendly)
|
|
72
74
|
auth_class.allocate.post_configure if auth_class.method_defined?(:post_configure)
|
|
@@ -186,9 +188,9 @@ module Rodauth
|
|
|
186
188
|
feature.module_eval(&block)
|
|
187
189
|
configuration.def_configuration_methods(feature)
|
|
188
190
|
|
|
189
|
-
# :
|
|
191
|
+
# simplecov:disable
|
|
190
192
|
if constant
|
|
191
|
-
# :
|
|
193
|
+
# simplecov:enable
|
|
192
194
|
Rodauth.const_set(constant, feature)
|
|
193
195
|
Rodauth::FeatureConfiguration.const_set(constant, configuration)
|
|
194
196
|
end
|
|
@@ -211,9 +213,9 @@ module Rodauth
|
|
|
211
213
|
if RUBY_VERSION >= '2.5'
|
|
212
214
|
DEPRECATED_ARGS = [{:uplevel=>1}]
|
|
213
215
|
else
|
|
214
|
-
# :
|
|
216
|
+
# simplecov:disable
|
|
215
217
|
DEPRECATED_ARGS = []
|
|
216
|
-
# :
|
|
218
|
+
# simplecov:enable
|
|
217
219
|
end
|
|
218
220
|
def def_deprecated_alias(new, old)
|
|
219
221
|
configuration_module_eval do
|
|
@@ -348,7 +350,7 @@ module Rodauth
|
|
|
348
350
|
auth_private_methods(meth)
|
|
349
351
|
end
|
|
350
352
|
|
|
351
|
-
# :
|
|
353
|
+
# simplecov:disable
|
|
352
354
|
def auth_cached_method(meth, iv=:"@#{meth}") # :nodoc:
|
|
353
355
|
# Non-shape friendly historical method.
|
|
354
356
|
# RODAUTH3: Remove
|
|
@@ -363,7 +365,7 @@ module Rodauth
|
|
|
363
365
|
alias_method(meth, meth)
|
|
364
366
|
auth_private_methods(meth)
|
|
365
367
|
end
|
|
366
|
-
# :
|
|
368
|
+
# simplecov:enable
|
|
367
369
|
|
|
368
370
|
[:notice_flash, :error_flash, :button].each do |meth|
|
|
369
371
|
define_method(meth) do |v, name=feature_name|
|
|
@@ -377,11 +379,11 @@ module Rodauth
|
|
|
377
379
|
|
|
378
380
|
def initialize(auth, &block)
|
|
379
381
|
@auth = auth
|
|
380
|
-
# :
|
|
382
|
+
# simplecov:disable
|
|
381
383
|
# Only for backwards compatibility
|
|
382
384
|
# RODAUTH3: Remove
|
|
383
385
|
apply(&block) if block
|
|
384
|
-
# :
|
|
386
|
+
# simplecov:enable
|
|
385
387
|
end
|
|
386
388
|
|
|
387
389
|
def apply(&block)
|
|
@@ -471,12 +473,12 @@ module Rodauth
|
|
|
471
473
|
|
|
472
474
|
ivs
|
|
473
475
|
end
|
|
474
|
-
# :
|
|
476
|
+
# simplecov:disable
|
|
475
477
|
else
|
|
476
478
|
def make_shape_friendly # :nodoc:
|
|
477
479
|
end
|
|
478
480
|
end
|
|
479
|
-
# :
|
|
481
|
+
# simplecov:enable
|
|
480
482
|
end
|
|
481
483
|
|
|
482
484
|
def self.inherited(subclass)
|
|
@@ -519,8 +521,28 @@ module Rodauth
|
|
|
519
521
|
end
|
|
520
522
|
|
|
521
523
|
module ClassMethods
|
|
524
|
+
if Roda::RodaPlugins.respond_to?(:opt_attr_reader)
|
|
525
|
+
Roda::RodaPlugins.opt_attr_reader(self, :rodauths)
|
|
526
|
+
Roda::RodaPlugins.opt_attr_reader(self, :rodauth_json)
|
|
527
|
+
Roda::RodaPlugins.opt_attr_reader(self, :rodauth_route_csrf, name: :rodauth_route_csrf?)
|
|
528
|
+
# simplecov:disable
|
|
529
|
+
else
|
|
530
|
+
def rodauths
|
|
531
|
+
opts[:rodauths]
|
|
532
|
+
end
|
|
533
|
+
|
|
534
|
+
def rodauth_json
|
|
535
|
+
opts[:rodauth_json]
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
def rodauth_route_csrf?
|
|
539
|
+
opts[:rodauth_route_csrf]
|
|
540
|
+
end
|
|
541
|
+
# simplecov:enable
|
|
542
|
+
end
|
|
543
|
+
|
|
522
544
|
def rodauth(name=nil)
|
|
523
|
-
|
|
545
|
+
rodauths[name]
|
|
524
546
|
end
|
|
525
547
|
|
|
526
548
|
def precompile_rodauth_templates
|
|
@@ -540,8 +562,8 @@ module Rodauth
|
|
|
540
562
|
end
|
|
541
563
|
|
|
542
564
|
def freeze
|
|
543
|
-
|
|
544
|
-
|
|
565
|
+
rodauths.each_value(&:freeze)
|
|
566
|
+
rodauths.freeze
|
|
545
567
|
super
|
|
546
568
|
end
|
|
547
569
|
end
|
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.
|
|
4
|
+
version: 2.49.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeremy Evans
|
|
@@ -407,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
407
407
|
- !ruby/object:Gem::Version
|
|
408
408
|
version: '0'
|
|
409
409
|
requirements: []
|
|
410
|
-
rubygems_version: 4.0.
|
|
410
|
+
rubygems_version: 4.0.20
|
|
411
411
|
specification_version: 4
|
|
412
412
|
summary: Authentication and Account Management Framework for Rack Applications
|
|
413
413
|
test_files: []
|