rodauth 2.14.0 → 2.18.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.
@@ -96,6 +96,12 @@ module Rodauth
96
96
  :otp_tmp_key
97
97
  )
98
98
 
99
+ internal_request_method :otp_setup_params
100
+ internal_request_method :otp_setup
101
+ internal_request_method :otp_auth
102
+ internal_request_method :valid_otp_auth?
103
+ internal_request_method :otp_disable
104
+
99
105
  route(:otp_auth) do |r|
100
106
  require_login
101
107
  require_account_session
@@ -297,7 +303,7 @@ module Rodauth
297
303
  end
298
304
 
299
305
  def otp_qr_code
300
- RQRCode::QRCode.new(otp_provisioning_uri).as_svg(:module_size=>8)
306
+ RQRCode::QRCode.new(otp_provisioning_uri).as_svg(:module_size=>8, :viewbox=>true)
301
307
  end
302
308
 
303
309
  def otp_user_key
@@ -0,0 +1,22 @@
1
+ # frozen-string-literal: true
2
+
3
+ module Rodauth
4
+ Feature.define(:path_class_methods, :PathClassMethods) do
5
+ def post_configure
6
+ super
7
+
8
+ klass = self.class
9
+ klass.features.each do |feature_name|
10
+ feature = FEATURES[feature_name]
11
+ feature.routes.each do |handle_meth|
12
+ route = handle_meth.to_s.sub(/\Ahandle_/, '')
13
+ path_meth = :"#{route}_path"
14
+ url_meth = :"#{route}_url"
15
+ instance = klass.allocate.freeze
16
+ klass.define_singleton_method(path_meth){|opts={}| instance.send(path_meth, opts)}
17
+ klass.define_singleton_method(url_meth){|opts={}| instance.send(url_meth, opts)}
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -59,6 +59,10 @@ module Rodauth
59
59
  :recovery_code_match?,
60
60
  )
61
61
 
62
+ internal_request_method :recovery_codes
63
+ internal_request_method :recovery_auth
64
+ internal_request_method :valid_recovery_auth?
65
+
62
66
  route(:recovery_auth) do |r|
63
67
  require_login
64
68
  require_account_session
@@ -46,6 +46,10 @@ module Rodauth
46
46
  :remove_remember_key
47
47
  )
48
48
 
49
+ internal_request_method :remember_setup
50
+ internal_request_method :remember_disable
51
+ internal_request_method :account_id_for_remember_key
52
+
49
53
  route do |r|
50
54
  require_account
51
55
  before_remember_route
@@ -83,7 +87,7 @@ module Rodauth
83
87
  end
84
88
 
85
89
  def remembered_session_id
86
- return unless cookie = request.cookies[remember_cookie_key]
90
+ return unless cookie = _get_remember_cookie
87
91
  id, key = cookie.split('_', 2)
88
92
  return unless id && key
89
93
 
@@ -110,7 +114,7 @@ module Rodauth
110
114
 
111
115
  unless id = remembered_session_id
112
116
  # Only set expired cookie if there is already a cookie set.
113
- forget_login if request.cookies[remember_cookie_key]
117
+ forget_login if _get_remember_cookie
114
118
  return
115
119
  end
116
120
 
@@ -187,6 +191,10 @@ module Rodauth
187
191
 
188
192
  private
189
193
 
194
+ def _get_remember_cookie
195
+ request.cookies[remember_cookie_key]
196
+ end
197
+
190
198
  def after_logout
191
199
  forget_login
192
200
  super if defined?(super)
@@ -57,6 +57,9 @@ module Rodauth
57
57
  :account_from_reset_password_key
58
58
  )
59
59
 
60
+ internal_request_method(:reset_password_request)
61
+ internal_request_method
62
+
60
63
  route(:reset_password_request) do |r|
61
64
  check_already_logged_in
62
65
  before_reset_password_request_route
@@ -112,6 +112,13 @@ module Rodauth
112
112
  :sms_valid_phone?
113
113
  )
114
114
 
115
+ internal_request_method :sms_setup
116
+ internal_request_method :sms_confirm
117
+ internal_request_method :sms_request
118
+ internal_request_method :sms_auth
119
+ internal_request_method :valid_sms_auth?
120
+ internal_request_method :sms_disable
121
+
115
122
  route(:sms_request) do |r|
116
123
  require_login
117
124
  require_account_session
@@ -57,6 +57,8 @@ module Rodauth
57
57
  :two_factor_update_session
58
58
  )
59
59
 
60
+ internal_request_method :two_factor_disable
61
+
60
62
  route(:two_factor_manage, 'multifactor-manage') do |r|
61
63
  require_account
62
64
  before_two_factor_manage_route
@@ -60,6 +60,9 @@ module Rodauth
60
60
  :account_from_verify_account_key
61
61
  )
62
62
 
63
+ internal_request_method(:verify_account_resend)
64
+ internal_request_method
65
+
63
66
  route(:verify_account_resend) do |r|
64
67
  verify_account_check_already_logged_in
65
68
  before_verify_account_resend_route
@@ -193,8 +196,7 @@ module Rodauth
193
196
 
194
197
  def new_account(login)
195
198
  if account_from_login(login) && allow_resending_verify_account_email?
196
- set_redirect_error_status(unopen_account_error_status)
197
- set_error_reason :already_an_unverified_account_with_this_login
199
+ set_response_error_reason_status(:already_an_unverified_account_with_this_login, unopen_account_error_status)
198
200
  set_error_flash attempt_to_create_unverified_account_error_flash
199
201
  response.write resend_verify_account_view
200
202
  request.halt
@@ -271,8 +273,7 @@ module Rodauth
271
273
 
272
274
  def before_login_attempt
273
275
  unless open_account?
274
- set_redirect_error_status(unopen_account_error_status)
275
- set_error_reason :unverified_account
276
+ set_response_error_reason_status(:unverified_account, unopen_account_error_status)
276
277
  set_error_flash attempt_to_login_to_unverified_account_error_flash
277
278
  response.write resend_verify_account_view
278
279
  request.halt
@@ -50,6 +50,8 @@ module Rodauth
50
50
  :account_from_verify_login_change_key
51
51
  )
52
52
 
53
+ internal_request_method
54
+
53
55
  route do |r|
54
56
  before_verify_login_change_route
55
57
 
@@ -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 = 14
9
+ MINOR = 18
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
@@ -3,6 +3,17 @@
3
3
  require 'securerandom'
4
4
 
5
5
  module Rodauth
6
+ def self.lib(opts={}, &block)
7
+ require 'roda'
8
+ c = Class.new(Roda)
9
+ c.plugin(:rodauth, opts) do
10
+ enable :internal_request
11
+ instance_exec(&block)
12
+ end
13
+ c.freeze
14
+ c.rodauth
15
+ end
16
+
6
17
  def self.load_dependencies(app, opts={})
7
18
  json_opt = opts.fetch(:json, app.opts[:rodauth_json])
8
19
  if json_opt
@@ -46,6 +57,7 @@ module Rodauth
46
57
  auth_class = app.opts[:rodauths][opts[:name]] = Class.new(auth_class)
47
58
  auth_class.roda_class = app
48
59
  end
60
+ auth_class.class_eval{@configuration_name = opts[:name] unless defined?(@configuration_name)}
49
61
  auth_class.configure(&block) if block
50
62
  end
51
63
 
@@ -107,6 +119,7 @@ module Rodauth
107
119
  attr_accessor :dependencies
108
120
  attr_accessor :routes
109
121
  attr_accessor :configuration
122
+ attr_reader :internal_request_methods
110
123
 
111
124
  def route(name=feature_name, default=name.to_s.tr('_', '-'), &block)
112
125
  route_meth = :"#{name}_route"
@@ -152,6 +165,10 @@ module Rodauth
152
165
  FEATURES[name] = feature
153
166
  end
154
167
 
168
+ def internal_request_method(name=feature_name)
169
+ (@internal_request_methods ||= []) << name
170
+ end
171
+
155
172
  def configuration_module_eval(&block)
156
173
  configuration.module_eval(&block)
157
174
  end
@@ -260,6 +277,8 @@ module Rodauth
260
277
  attr_reader :features
261
278
  attr_reader :routes
262
279
  attr_accessor :route_hash
280
+ attr_reader :configuration_name
281
+ attr_reader :configuration
263
282
  end
264
283
 
265
284
  def self.inherited(subclass)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.14.0
4
+ version: 2.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-22 00:00:00.000000000 Z
11
+ date: 2021-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -268,6 +268,7 @@ extra_rdoc_files:
268
268
  - doc/email_base.rdoc
269
269
  - doc/error_reasons.rdoc
270
270
  - doc/http_basic_auth.rdoc
271
+ - doc/internal_request.rdoc
271
272
  - doc/json.rdoc
272
273
  - doc/jwt.rdoc
273
274
  - doc/jwt_cors.rdoc
@@ -281,6 +282,7 @@ extra_rdoc_files:
281
282
  - doc/password_expiration.rdoc
282
283
  - doc/password_grace_period.rdoc
283
284
  - doc/password_pepper.rdoc
285
+ - doc/path_class_methods.rdoc
284
286
  - doc/recovery_codes.rdoc
285
287
  - doc/remember.rdoc
286
288
  - doc/reset_password.rdoc
@@ -326,6 +328,10 @@ extra_rdoc_files:
326
328
  - doc/release_notes/2.12.0.txt
327
329
  - doc/release_notes/2.13.0.txt
328
330
  - doc/release_notes/2.14.0.txt
331
+ - doc/release_notes/2.15.0.txt
332
+ - doc/release_notes/2.16.0.txt
333
+ - doc/release_notes/2.17.0.txt
334
+ - doc/release_notes/2.18.0.txt
329
335
  - doc/release_notes/2.2.0.txt
330
336
  - doc/release_notes/2.3.0.txt
331
337
  - doc/release_notes/2.4.0.txt
@@ -378,6 +384,7 @@ files:
378
384
  - doc/guides/status_column.rdoc
379
385
  - doc/guides/totp_or_recovery.rdoc
380
386
  - doc/http_basic_auth.rdoc
387
+ - doc/internal_request.rdoc
381
388
  - doc/json.rdoc
382
389
  - doc/jwt.rdoc
383
390
  - doc/jwt_cors.rdoc
@@ -391,6 +398,7 @@ files:
391
398
  - doc/password_expiration.rdoc
392
399
  - doc/password_grace_period.rdoc
393
400
  - doc/password_pepper.rdoc
401
+ - doc/path_class_methods.rdoc
394
402
  - doc/recovery_codes.rdoc
395
403
  - doc/release_notes/1.0.0.txt
396
404
  - doc/release_notes/1.1.0.txt
@@ -423,6 +431,10 @@ files:
423
431
  - doc/release_notes/2.12.0.txt
424
432
  - doc/release_notes/2.13.0.txt
425
433
  - doc/release_notes/2.14.0.txt
434
+ - doc/release_notes/2.15.0.txt
435
+ - doc/release_notes/2.16.0.txt
436
+ - doc/release_notes/2.17.0.txt
437
+ - doc/release_notes/2.18.0.txt
426
438
  - doc/release_notes/2.2.0.txt
427
439
  - doc/release_notes/2.3.0.txt
428
440
  - doc/release_notes/2.4.0.txt
@@ -464,6 +476,7 @@ files:
464
476
  - lib/rodauth/features/email_auth.rb
465
477
  - lib/rodauth/features/email_base.rb
466
478
  - lib/rodauth/features/http_basic_auth.rb
479
+ - lib/rodauth/features/internal_request.rb
467
480
  - lib/rodauth/features/json.rb
468
481
  - lib/rodauth/features/jwt.rb
469
482
  - lib/rodauth/features/jwt_cors.rb
@@ -477,6 +490,7 @@ files:
477
490
  - lib/rodauth/features/password_expiration.rb
478
491
  - lib/rodauth/features/password_grace_period.rb
479
492
  - lib/rodauth/features/password_pepper.rb
493
+ - lib/rodauth/features/path_class_methods.rb
480
494
  - lib/rodauth/features/recovery_codes.rb
481
495
  - lib/rodauth/features/remember.rb
482
496
  - lib/rodauth/features/reset_password.rb
@@ -576,7 +590,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
576
590
  - !ruby/object:Gem::Version
577
591
  version: '0'
578
592
  requirements: []
579
- rubygems_version: 3.2.15
593
+ rubygems_version: 3.2.22
580
594
  signing_key:
581
595
  specification_version: 4
582
596
  summary: Authentication and Account Management Framework for Rack Applications