rodauth 2.44.0 → 2.45.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/base.rb +18 -8
- data/lib/rodauth/features/internal_request.rb +2 -2
- data/lib/rodauth/features/json.rb +2 -0
- data/lib/rodauth/features/jwt.rb +1 -1
- data/lib/rodauth/features/lockout.rb +8 -1
- data/lib/rodauth/features/path_class_methods.rb +2 -2
- data/lib/rodauth/features/remember.rb +1 -1
- data/lib/rodauth/features/reset_password.rb +5 -0
- data/lib/rodauth/features/sms_codes.rb +1 -1
- data/lib/rodauth/version.rb +1 -1
- data/lib/rodauth.rb +32 -11
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5dea248f50448b260c6d0007d8bc4054f17794270e857a6310b969ba58105fbf
|
|
4
|
+
data.tar.gz: 875dbda4ddd85b04041a8e854e0adb09b466269ecef74dd1a73f384519d54553
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dbf7c82f8b1c93496c59225891c1d747f317eaf46d8283f9c6f2d0562a48aaaec4d6491ed7567011356914fb4498e0f86576c230e183cf53c0ac7a7c5f27d99a
|
|
7
|
+
data.tar.gz: c8c2a228ce0395e4e14dbd1a69b01f7038b2ac94267b33bc5695d11b3eae6a278846be5100714dc18b0a65010db1693c0621f9ec1f2d0ba0793e92b61a698bf9
|
|
@@ -35,7 +35,7 @@ module Rodauth
|
|
|
35
35
|
auth_value_method :accounts_table, :accounts
|
|
36
36
|
auth_value_method :cache_templates, true
|
|
37
37
|
auth_value_method :check_csrf_block, nil
|
|
38
|
-
auth_value_method :check_csrf_opts,
|
|
38
|
+
auth_value_method :check_csrf_opts, OPTS
|
|
39
39
|
auth_value_method :default_redirect, '/'
|
|
40
40
|
auth_value_method :convert_token_id_to_integer?, nil
|
|
41
41
|
flash_key :flash_error_key, :error
|
|
@@ -73,9 +73,10 @@ module Rodauth
|
|
|
73
73
|
auth_value_method :mark_input_fields_with_inputmode?, true
|
|
74
74
|
auth_value_method :skip_status_checks?, true
|
|
75
75
|
translatable_method :strftime_format, '%F %T'
|
|
76
|
-
auth_value_method :template_opts,
|
|
76
|
+
auth_value_method :template_opts, OPTS
|
|
77
77
|
auth_value_method :title_instance_variable, nil
|
|
78
78
|
auth_value_method :token_separator, "_"
|
|
79
|
+
auth_value_method :transaction_opts, OPTS
|
|
79
80
|
auth_value_method :unmatched_field_error_status, 422
|
|
80
81
|
auth_value_method :unopen_account_error_status, 403
|
|
81
82
|
translatable_method :unverified_account_message, "unverified account, please verify account before logging in"
|
|
@@ -107,6 +108,7 @@ module Rodauth
|
|
|
107
108
|
:check_csrf,
|
|
108
109
|
:clear_session,
|
|
109
110
|
:clear_tokens,
|
|
111
|
+
:convert_token_id,
|
|
110
112
|
:csrf_tag,
|
|
111
113
|
:function_name,
|
|
112
114
|
:hook_action,
|
|
@@ -135,7 +137,6 @@ module Rodauth
|
|
|
135
137
|
:account_from_id,
|
|
136
138
|
:account_from_login,
|
|
137
139
|
:account_from_session,
|
|
138
|
-
:convert_token_id,
|
|
139
140
|
:field_attributes,
|
|
140
141
|
:field_error_attributes,
|
|
141
142
|
:formatted_field_error,
|
|
@@ -218,7 +219,7 @@ module Rodauth
|
|
|
218
219
|
end
|
|
219
220
|
end
|
|
220
221
|
|
|
221
|
-
def input_field_string(param, id, opts=
|
|
222
|
+
def input_field_string(param, id, opts=OPTS)
|
|
222
223
|
type = opts.fetch(:type, "text")
|
|
223
224
|
|
|
224
225
|
unless type == "password"
|
|
@@ -449,7 +450,7 @@ module Rodauth
|
|
|
449
450
|
_template_opts(opts, 'button')
|
|
450
451
|
end
|
|
451
452
|
|
|
452
|
-
def button(value, opts=
|
|
453
|
+
def button(value, opts=OPTS)
|
|
453
454
|
scope.render(button_opts(value, opts))
|
|
454
455
|
end
|
|
455
456
|
|
|
@@ -696,17 +697,18 @@ module Rodauth
|
|
|
696
697
|
request.halt
|
|
697
698
|
end
|
|
698
699
|
|
|
699
|
-
def route_path(route, opts=
|
|
700
|
+
def route_path(route, opts=OPTS)
|
|
700
701
|
path = "#{prefix}/#{route}"
|
|
701
702
|
path += "?#{Rack::Utils.build_nested_query(opts)}" unless opts.empty?
|
|
702
703
|
path
|
|
703
704
|
end
|
|
704
705
|
|
|
705
|
-
def route_url(route, opts=
|
|
706
|
+
def route_url(route, opts=OPTS)
|
|
706
707
|
"#{base_url}#{route_path(route, opts)}"
|
|
707
708
|
end
|
|
708
709
|
|
|
709
|
-
def transaction(opts=
|
|
710
|
+
def transaction(opts=OPTS, &block)
|
|
711
|
+
opts = opts.empty? ? transaction_opts : transaction_opts.merge(opts)
|
|
710
712
|
db.transaction(opts, &block)
|
|
711
713
|
end
|
|
712
714
|
|
|
@@ -966,6 +968,14 @@ module Rodauth
|
|
|
966
968
|
false
|
|
967
969
|
end
|
|
968
970
|
|
|
971
|
+
# :nocov:
|
|
972
|
+
if RUBY_VERSION >= '4.0'
|
|
973
|
+
# :nocov:
|
|
974
|
+
def instance_variables_to_inspect
|
|
975
|
+
instance_variables.reject{|v| instance_variable_get(v).nil?}
|
|
976
|
+
end
|
|
977
|
+
end
|
|
978
|
+
|
|
969
979
|
def use_scope_clear_session?
|
|
970
980
|
scope.respond_to?(:clear_session)
|
|
971
981
|
end
|
|
@@ -318,7 +318,7 @@ module Rodauth
|
|
|
318
318
|
]
|
|
319
319
|
end
|
|
320
320
|
|
|
321
|
-
def internal_request(route, opts=
|
|
321
|
+
def internal_request(route, opts=OPTS, &block)
|
|
322
322
|
opts = opts.dup
|
|
323
323
|
|
|
324
324
|
env = {
|
|
@@ -425,7 +425,7 @@ module Rodauth
|
|
|
425
425
|
feature = FEATURES[feature_name]
|
|
426
426
|
if meths = feature.internal_request_methods
|
|
427
427
|
meths.each do |name|
|
|
428
|
-
klass.define_singleton_method(name){|opts=
|
|
428
|
+
klass.define_singleton_method(name){|opts=OPTS, &block| internal_class.internal_request(name, opts, &block)}
|
|
429
429
|
end
|
|
430
430
|
end
|
|
431
431
|
end
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module Rodauth
|
|
4
4
|
Feature.define(:json, :Json) do
|
|
5
|
+
self.allowed_undefined_configuration_methods = [:only_json?].freeze
|
|
6
|
+
|
|
5
7
|
translatable_method :json_not_accepted_error_message, 'Unsupported Accept header. Must accept "application/json" or compatible content type'
|
|
6
8
|
translatable_method :json_non_post_error_message, 'non-POST method used in JSON API'
|
|
7
9
|
auth_value_method :json_accept_regexp, /(?:(?:\*|\bapplication)\/\*|\bapplication\/(?:vnd\.api\+)?json\b)/i
|
data/lib/rodauth/features/jwt.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Rodauth
|
|
|
11
11
|
auth_value_method :jwt_algorithm, "HS256"
|
|
12
12
|
auth_value_method :jwt_authorization_ignore, /\A(?:Basic|Digest) /
|
|
13
13
|
auth_value_method :jwt_authorization_remove, /\ABearer:?\s+/
|
|
14
|
-
auth_value_method :jwt_decode_opts,
|
|
14
|
+
auth_value_method :jwt_decode_opts, OPTS
|
|
15
15
|
auth_value_method :jwt_old_secret, nil
|
|
16
16
|
auth_value_method :jwt_session_key, nil
|
|
17
17
|
auth_value_method :jwt_symbolize_deeply?, false
|
|
@@ -251,7 +251,14 @@ module Rodauth
|
|
|
251
251
|
|
|
252
252
|
private
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
def unlock_account_key
|
|
255
|
+
@unlock_account_key_value
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def unlock_account_key_value
|
|
259
|
+
# RODAUTH3: call unlock_account_key directly
|
|
260
|
+
unlock_account_key
|
|
261
|
+
end
|
|
255
262
|
|
|
256
263
|
def before_login_attempt
|
|
257
264
|
if locked_out?
|
|
@@ -13,8 +13,8 @@ module Rodauth
|
|
|
13
13
|
path_meth = :"#{route}_path"
|
|
14
14
|
url_meth = :"#{route}_url"
|
|
15
15
|
instance = klass.allocate.freeze
|
|
16
|
-
klass.define_singleton_method(path_meth){|opts=
|
|
17
|
-
klass.define_singleton_method(url_meth){|opts=
|
|
16
|
+
klass.define_singleton_method(path_meth){|opts=OPTS| instance.send(path_meth, opts)}
|
|
17
|
+
klass.define_singleton_method(url_meth){|opts=OPTS| instance.send(url_meth, opts)}
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
end
|
|
@@ -16,7 +16,7 @@ module Rodauth
|
|
|
16
16
|
response
|
|
17
17
|
|
|
18
18
|
auth_value_method :raw_remember_token_deadline, nil
|
|
19
|
-
auth_value_method :remember_cookie_options,
|
|
19
|
+
auth_value_method :remember_cookie_options, OPTS
|
|
20
20
|
auth_value_method :extend_remember_deadline?, false
|
|
21
21
|
auth_value_method :extend_remember_deadline_period, 3600
|
|
22
22
|
auth_value_method :remember_period, {:days=>14}.freeze
|
|
@@ -192,6 +192,11 @@ module Rodauth
|
|
|
192
192
|
end
|
|
193
193
|
|
|
194
194
|
def get_password_reset_key(id)
|
|
195
|
+
# RODAUTH3: Remove method and call get_reset_password_key directly
|
|
196
|
+
get_reset_password_key(id)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def get_reset_password_key(id)
|
|
195
200
|
ds = password_reset_ds(id)
|
|
196
201
|
ds.where(Sequel::CURRENT_TIMESTAMP > reset_password_deadline_column).delete
|
|
197
202
|
ds.get(reset_password_key_column)
|
|
@@ -92,7 +92,6 @@ module Rodauth
|
|
|
92
92
|
auth_value_methods(
|
|
93
93
|
:sms_codes_primary?,
|
|
94
94
|
:sms_needs_confirmation_notice_flash,
|
|
95
|
-
:sms_request_response
|
|
96
95
|
)
|
|
97
96
|
|
|
98
97
|
auth_methods(
|
|
@@ -120,6 +119,7 @@ module Rodauth
|
|
|
120
119
|
:sms_setup?,
|
|
121
120
|
:sms_valid_phone?
|
|
122
121
|
)
|
|
122
|
+
auth_private_methods :sms_request_response
|
|
123
123
|
|
|
124
124
|
uses_instance_variables(:@sms)
|
|
125
125
|
|
data/lib/rodauth/version.rb
CHANGED
data/lib/rodauth.rb
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
require 'securerandom'
|
|
4
4
|
|
|
5
5
|
module Rodauth
|
|
6
|
+
OPTS = {}.freeze
|
|
7
|
+
SCOPE_INSTANCE_VARIABLES = [:@_rodauths, :@_rodauth].freeze
|
|
8
|
+
|
|
6
9
|
class ConfigurationError < StandardError; end
|
|
7
10
|
|
|
8
|
-
def self.lib(opts=
|
|
11
|
+
def self.lib(opts=OPTS, &block)
|
|
9
12
|
require 'roda'
|
|
10
13
|
c = Class.new(Roda)
|
|
11
14
|
c.plugin(:rodauth, opts) do
|
|
@@ -16,7 +19,7 @@ module Rodauth
|
|
|
16
19
|
c.rodauth
|
|
17
20
|
end
|
|
18
21
|
|
|
19
|
-
def self.load_dependencies(app, opts=
|
|
22
|
+
def self.load_dependencies(app, opts=OPTS, &_)
|
|
20
23
|
json_opt = opts.fetch(:json, app.opts[:rodauth_json])
|
|
21
24
|
if json_opt
|
|
22
25
|
app.plugin :json
|
|
@@ -45,7 +48,7 @@ module Rodauth
|
|
|
45
48
|
end
|
|
46
49
|
end
|
|
47
50
|
|
|
48
|
-
def self.configure(app, opts=
|
|
51
|
+
def self.configure(app, opts=OPTS, &block)
|
|
49
52
|
json_opt = app.opts[:rodauth_json] = opts.fetch(:json, app.opts[:rodauth_json])
|
|
50
53
|
csrf = app.opts[:rodauth_csrf] = opts.fetch(:csrf, app.opts[:rodauth_csrf])
|
|
51
54
|
app.opts[:rodauth_route_csrf] = case csrf
|
|
@@ -71,15 +74,32 @@ module Rodauth
|
|
|
71
74
|
|
|
72
75
|
class FeatureConfiguration < Module
|
|
73
76
|
def def_configuration_methods(feature)
|
|
74
|
-
private_methods = feature.private_instance_methods
|
|
77
|
+
private_methods = feature.private_instance_methods
|
|
75
78
|
priv = proc{|m| private_methods.include?(m)}
|
|
76
|
-
feature.auth_methods.each
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
feature.auth_methods.each do |m|
|
|
80
|
+
_check_method_defined(feature, m, priv[m])
|
|
81
|
+
def_auth_method(m, priv[m])
|
|
82
|
+
end
|
|
83
|
+
feature.auth_value_methods.each do |m|
|
|
84
|
+
_check_method_defined(feature, m, priv[m])
|
|
85
|
+
def_auth_value_method(m, priv[m])
|
|
86
|
+
end
|
|
87
|
+
feature.auth_private_methods.each do |m|
|
|
88
|
+
_check_method_defined(feature, :"_#{m}", true)
|
|
89
|
+
def_auth_private_method(m)
|
|
90
|
+
end
|
|
79
91
|
end
|
|
80
92
|
|
|
81
93
|
private
|
|
82
94
|
|
|
95
|
+
def _check_method_defined(feature, meth, priv)
|
|
96
|
+
if !feature.send(priv ? :private_method_defined? : :method_defined?, meth) &&
|
|
97
|
+
(!(allowed = feature.allowed_undefined_configuration_methods) || !allowed.include?(meth))
|
|
98
|
+
# RODAUTH3: raise instead of warn
|
|
99
|
+
warn "Bug in Rodauth #{feature.feature_name} feature definition, configuration method added for #{meth}, but the feature doesn't define the method"
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
83
103
|
def def_auth_method(meth, priv)
|
|
84
104
|
define_method(meth) do |&block|
|
|
85
105
|
@auth.send(:define_method, meth, &block)
|
|
@@ -125,6 +145,7 @@ module Rodauth
|
|
|
125
145
|
attr_accessor :dependencies
|
|
126
146
|
attr_accessor :routes
|
|
127
147
|
attr_accessor :configuration
|
|
148
|
+
attr_accessor :allowed_undefined_configuration_methods
|
|
128
149
|
attr_reader :internal_request_methods
|
|
129
150
|
attr_reader :instance_variables_used
|
|
130
151
|
|
|
@@ -132,8 +153,8 @@ module Rodauth
|
|
|
132
153
|
route_meth = :"#{name}_route"
|
|
133
154
|
auth_value_method route_meth, default
|
|
134
155
|
|
|
135
|
-
define_method(:"#{name}_path"){|opts=
|
|
136
|
-
define_method(:"#{name}_url"){|opts=
|
|
156
|
+
define_method(:"#{name}_path"){|opts=OPTS| route_path(send(route_meth), opts) if send(route_meth)}
|
|
157
|
+
define_method(:"#{name}_url"){|opts=OPTS| route_url(send(route_meth), opts) if send(route_meth)}
|
|
137
158
|
|
|
138
159
|
handle_meth = :"handle_#{name}"
|
|
139
160
|
internal_handle_meth = :"_#{handle_meth}"
|
|
@@ -260,7 +281,7 @@ module Rodauth
|
|
|
260
281
|
end
|
|
261
282
|
end
|
|
262
283
|
|
|
263
|
-
def email(type, subject, opts =
|
|
284
|
+
def email(type, subject, opts = OPTS)
|
|
264
285
|
subject_method = :"#{type}_email_subject"
|
|
265
286
|
body_method = :"#{type}_email_body"
|
|
266
287
|
create_method = :"create_#{type}_email"
|
|
@@ -507,7 +528,7 @@ module Rodauth
|
|
|
507
528
|
view_opts = rodauth.send(:loaded_templates).map do |page|
|
|
508
529
|
rodauth.send(:_view_opts, page)
|
|
509
530
|
end
|
|
510
|
-
view_opts << rodauth.send(:button_opts, '',
|
|
531
|
+
view_opts << rodauth.send(:button_opts, '', OPTS)
|
|
511
532
|
|
|
512
533
|
view_opts.each do |opts|
|
|
513
534
|
instance.send(:retrieve_template, opts).send(:compiled_method, opts[:locals].keys.sort_by(&:to_s))
|