rodauth 1.20.0 → 1.21.0

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: 7ecf305eda0aef347c6464decf7ef50e8e5fd4a69927bd690b68deae66de6b63
4
- data.tar.gz: 6f8e6ffcd70b5ff94b4f922c04661896055b401a85930e085e8aaa91d1e12dfe
3
+ metadata.gz: e2660e5b2f14afadab7d56a0a7329ff3f22cea0bb800fa952b3b40c3dcfbcb29
4
+ data.tar.gz: 34b96d4d8bc26d641288af6bced9a42b9a895790b019a03b00c3f0e55b67843b
5
5
  SHA512:
6
- metadata.gz: ebc055ab52ae0da05d5145b273cc63b53e93f29dae456ff86c321e4c5d5798b92d65b43f0d91272ccb2a44b7b77fc29765e45ffc511564c814771b87fc1b62bf
7
- data.tar.gz: fe083dd6517fd410eacfba69e061b3b7b82e6beae68e1413334db939c956ccb953e28d0a7a074731205e1d3ada60f12e96660b525bfc836a5a4fea45b33b881f
6
+ metadata.gz: c1f90ea3269e61b7de2e336bbe08ccde86b9d343d4b773971fcda7c4f3294804d9b251087978a57ae6eb0fea0a435fd16f0dd239ae524c465739fa6a129b3584
7
+ data.tar.gz: 6d8b86790ac1214bd48fffea3aaeffdce63351b8bf6fc40dce6ca96fa471f84a2d08be525d804f5138ba5664ac73bbc68bfda6f279ef17655fc4f24e64bd23d0
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ === 1.21.0 (2019-07-24)
2
+
3
+ * Support rotp 5.1 in the otp feature (jeremyevans)
4
+
5
+ * Log user out when locking out OTP account if no fallback options available (jeremyevans)
6
+
1
7
  === 1.20.0 (2019-06-07)
2
8
 
3
9
  * Support rotp 5 in the otp feature (jeremyevans)
@@ -183,7 +183,7 @@ Here's a heavily commented example showing what is going on inside a Rodauth fea
183
183
  foo_view
184
184
  end
185
185
 
186
- # Just like in Roda, r.post is called for GET requests
186
+ # Just like in Roda, r.post is called for POST requests
187
187
  r.post do
188
188
  # This is called before performing the foo action
189
189
  before_foo
@@ -0,0 +1,12 @@
1
+ = Improvements
2
+
3
+ * rotp 5.1 is now supported in the otp feature. Previous rotp
4
+ versions down to rotp 2.1.1 remain supported.
5
+
6
+ * When using the otp feature without the sms or recovery_codes
7
+ features, if an account gets locked out from OTP authentication due
8
+ to multiple invalid OTP authentication codes, automatically log
9
+ them out, and redirect them to the login page. Previously, the
10
+ default behavior in this case could be a redirect loop if OTP
11
+ authentication is required for the user on the default_redirect
12
+ page.
@@ -109,7 +109,12 @@ module Rodauth
109
109
  if otp_locked_out?
110
110
  set_response_error_status(lockout_error_status)
111
111
  set_redirect_error_flash otp_lockout_error_flash
112
- redirect otp_lockout_redirect
112
+ if redir = otp_lockout_redirect
113
+ redirect redir
114
+ else
115
+ clear_session
116
+ redirect require_login_redirect
117
+ end
113
118
  end
114
119
 
115
120
  before_otp_auth_route
@@ -241,7 +246,7 @@ module Rodauth
241
246
 
242
247
  def otp_lockout_redirect
243
248
  return super if defined?(super)
244
- default_redirect
249
+ nil
245
250
  end
246
251
 
247
252
  def otp_lockout_error_flash
@@ -359,7 +364,7 @@ module Rodauth
359
364
  if ROTP::Base32.respond_to?(:random_base32)
360
365
  # :nocov:
361
366
  def otp_new_secret
362
- ROTP::Base32.random_base32
367
+ ROTP::Base32.random_base32.downcase
363
368
  end
364
369
  # :nocov:
365
370
  else
@@ -6,7 +6,7 @@ module Rodauth
6
6
  MAJOR = 1
7
7
 
8
8
  # The minor version of Rodauth, updated for new feature releases of Rodauth.
9
- MINOR = 20
9
+ MINOR = 21
10
10
 
11
11
  # The patch version of Rodauth, updated only for bug fixes from the last
12
12
  # feature release.
@@ -560,10 +560,49 @@ describe 'Rodauth OTP feature' do
560
560
  DB[:account_recovery_codes].select_order_map(:code).must_equal ['a', 'b']
561
561
  end
562
562
 
563
+ it "should handle two factor lockout when using rodauth.require_two_factor_setup and rodauth.require_authentication" do
564
+ rodauth do
565
+ enable :login, :logout, :otp
566
+ otp_drift 10
567
+ end
568
+ roda do |r|
569
+ r.rodauth
570
+ rodauth.require_authentication
571
+ rodauth.require_two_factor_setup
572
+
573
+ view :content=>"Logged in"
574
+ end
575
+
576
+ login
577
+ page.title.must_equal 'Setup Two Factor Authentication'
578
+ secret = page.html.match(/Secret: ([a-z2-7]{#{secret_length}})/)[1]
579
+ totp = ROTP::TOTP.new(secret)
580
+ fill_in 'Password', :with=>'0123456789'
581
+ fill_in 'Authentication Code', :with=>totp.now
582
+ click_button 'Setup Two Factor Authentication'
583
+ page.find('#notice_flash').text.must_equal 'Two factor authentication is now setup'
584
+ page.current_path.must_equal '/'
585
+ page.html.must_include 'Logged in'
586
+ reset_otp_last_use
587
+
588
+ logout
589
+ login
590
+
591
+ 6.times do
592
+ page.title.must_equal 'Enter Authentication Code'
593
+ fill_in 'Authentication Code', :with=>'foo'
594
+ click_button 'Authenticate via 2nd Factor'
595
+ end
596
+ page.find('#error_flash').text.must_equal 'Authentication code use locked out due to numerous failures.'
597
+ page.title.must_include 'Login'
598
+ page.current_path.must_equal '/login'
599
+ end
600
+
563
601
  it "should allow two factor authentication setup, login, removal without recovery" do
564
602
  rodauth do
565
603
  enable :login, :logout, :otp
566
604
  otp_drift 10
605
+ otp_lockout_redirect '/'
567
606
  end
568
607
  roda do |r|
569
608
  r.rodauth
@@ -1149,7 +1188,7 @@ describe 'Rodauth OTP feature' do
1149
1188
  json_request(path).must_equal [403, {'error'=>'SMS authentication has not been setup yet.'}]
1150
1189
  end
1151
1190
 
1152
- secret = (ROTP::Base32.respond_to?(:random_base32) ? ROTP::Base32.random_base32 : ROTP::Base32.random.downcase)
1191
+ secret = (ROTP::Base32.respond_to?(:random_base32) ? ROTP::Base32.random_base32 : ROTP::Base32.random).downcase
1153
1192
  totp = ROTP::TOTP.new(secret)
1154
1193
 
1155
1194
  res = json_request('/otp-setup', :password=>'123456', :otp_secret=>secret)
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: 1.20.0
4
+ version: 1.21.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: 2019-06-07 00:00:00.000000000 Z
11
+ date: 2019-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -253,6 +253,7 @@ extra_rdoc_files:
253
253
  - doc/release_notes/1.18.0.txt
254
254
  - doc/release_notes/1.19.0.txt
255
255
  - doc/release_notes/1.20.0.txt
256
+ - doc/release_notes/1.21.0.txt
256
257
  files:
257
258
  - CHANGELOG
258
259
  - MIT-LICENSE
@@ -298,6 +299,7 @@ files:
298
299
  - doc/release_notes/1.19.0.txt
299
300
  - doc/release_notes/1.2.0.txt
300
301
  - doc/release_notes/1.20.0.txt
302
+ - doc/release_notes/1.21.0.txt
301
303
  - doc/release_notes/1.3.0.txt
302
304
  - doc/release_notes/1.4.0.txt
303
305
  - doc/release_notes/1.5.0.txt