rodauth 1.23.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +132 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +207 -79
  5. data/doc/account_expiration.rdoc +12 -26
  6. data/doc/active_sessions.rdoc +49 -0
  7. data/doc/audit_logging.rdoc +44 -0
  8. data/doc/base.rdoc +74 -128
  9. data/doc/change_login.rdoc +7 -14
  10. data/doc/change_password.rdoc +9 -13
  11. data/doc/change_password_notify.rdoc +2 -2
  12. data/doc/close_account.rdoc +9 -16
  13. data/doc/confirm_password.rdoc +12 -5
  14. data/doc/create_account.rdoc +11 -22
  15. data/doc/disallow_password_reuse.rdoc +6 -13
  16. data/doc/email_auth.rdoc +15 -14
  17. data/doc/email_base.rdoc +5 -15
  18. data/doc/http_basic_auth.rdoc +10 -1
  19. data/doc/jwt.rdoc +22 -22
  20. data/doc/jwt_cors.rdoc +2 -3
  21. data/doc/jwt_refresh.rdoc +12 -8
  22. data/doc/lockout.rdoc +17 -15
  23. data/doc/login.rdoc +10 -2
  24. data/doc/login_password_requirements_base.rdoc +15 -37
  25. data/doc/logout.rdoc +2 -2
  26. data/doc/otp.rdoc +24 -19
  27. data/doc/password_complexity.rdoc +10 -26
  28. data/doc/password_expiration.rdoc +11 -25
  29. data/doc/password_grace_period.rdoc +16 -2
  30. data/doc/recovery_codes.rdoc +18 -12
  31. data/doc/release_notes/2.0.0.txt +361 -0
  32. data/doc/remember.rdoc +40 -64
  33. data/doc/reset_password.rdoc +12 -9
  34. data/doc/session_expiration.rdoc +1 -0
  35. data/doc/single_session.rdoc +16 -25
  36. data/doc/sms_codes.rdoc +24 -14
  37. data/doc/two_factor_base.rdoc +60 -22
  38. data/doc/verify_account.rdoc +14 -12
  39. data/doc/verify_account_grace_period.rdoc +6 -2
  40. data/doc/verify_login_change.rdoc +9 -8
  41. data/doc/webauthn.rdoc +115 -0
  42. data/doc/webauthn_login.rdoc +15 -0
  43. data/doc/webauthn_verify_account.rdoc +9 -0
  44. data/javascript/webauthn_auth.js +45 -0
  45. data/javascript/webauthn_setup.js +35 -0
  46. data/lib/roda/plugins/rodauth.rb +1 -1
  47. data/lib/rodauth.rb +29 -24
  48. data/lib/rodauth/features/account_expiration.rb +5 -5
  49. data/lib/rodauth/features/active_sessions.rb +160 -0
  50. data/lib/rodauth/features/audit_logging.rb +96 -0
  51. data/lib/rodauth/features/base.rb +131 -47
  52. data/lib/rodauth/features/change_password_notify.rb +1 -1
  53. data/lib/rodauth/features/confirm_password.rb +40 -2
  54. data/lib/rodauth/features/create_account.rb +7 -13
  55. data/lib/rodauth/features/disallow_common_passwords.rb +1 -1
  56. data/lib/rodauth/features/disallow_password_reuse.rb +1 -1
  57. data/lib/rodauth/features/email_auth.rb +29 -27
  58. data/lib/rodauth/features/email_base.rb +3 -3
  59. data/lib/rodauth/features/http_basic_auth.rb +44 -37
  60. data/lib/rodauth/features/jwt.rb +51 -8
  61. data/lib/rodauth/features/jwt_refresh.rb +3 -3
  62. data/lib/rodauth/features/lockout.rb +11 -13
  63. data/lib/rodauth/features/login.rb +48 -8
  64. data/lib/rodauth/features/login_password_requirements_base.rb +4 -4
  65. data/lib/rodauth/features/otp.rb +71 -81
  66. data/lib/rodauth/features/password_complexity.rb +4 -11
  67. data/lib/rodauth/features/password_expiration.rb +1 -1
  68. data/lib/rodauth/features/password_grace_period.rb +17 -10
  69. data/lib/rodauth/features/recovery_codes.rb +47 -51
  70. data/lib/rodauth/features/remember.rb +11 -27
  71. data/lib/rodauth/features/reset_password.rb +25 -25
  72. data/lib/rodauth/features/session_expiration.rb +6 -4
  73. data/lib/rodauth/features/single_session.rb +7 -5
  74. data/lib/rodauth/features/sms_codes.rb +58 -67
  75. data/lib/rodauth/features/two_factor_base.rb +132 -28
  76. data/lib/rodauth/features/verify_account.rb +23 -20
  77. data/lib/rodauth/features/verify_account_grace_period.rb +19 -8
  78. data/lib/rodauth/features/verify_login_change.rb +11 -10
  79. data/lib/rodauth/features/webauthn.rb +507 -0
  80. data/lib/rodauth/features/webauthn_login.rb +70 -0
  81. data/lib/rodauth/features/webauthn_verify_account.rb +46 -0
  82. data/lib/rodauth/version.rb +2 -2
  83. data/templates/button.str +1 -3
  84. data/templates/change-login.str +1 -2
  85. data/templates/change-password.str +3 -5
  86. data/templates/close-account.str +2 -2
  87. data/templates/confirm-password.str +1 -1
  88. data/templates/create-account.str +1 -1
  89. data/templates/email-auth-request-form.str +1 -2
  90. data/templates/email-auth.str +1 -1
  91. data/templates/global-logout-field.str +6 -0
  92. data/templates/login-confirm-field.str +2 -4
  93. data/templates/login-display.str +3 -2
  94. data/templates/login-field.str +2 -4
  95. data/templates/login-form-footer.str +6 -0
  96. data/templates/login-form.str +7 -0
  97. data/templates/login.str +1 -9
  98. data/templates/logout.str +1 -1
  99. data/templates/multi-phase-login.str +3 -0
  100. data/templates/otp-auth-code-field.str +5 -3
  101. data/templates/otp-auth.str +1 -1
  102. data/templates/otp-disable.str +1 -1
  103. data/templates/otp-setup.str +3 -3
  104. data/templates/password-confirm-field.str +2 -4
  105. data/templates/password-field.str +2 -4
  106. data/templates/recovery-auth.str +3 -6
  107. data/templates/recovery-codes.str +1 -1
  108. data/templates/remember.str +15 -20
  109. data/templates/reset-password-request.str +2 -2
  110. data/templates/reset-password.str +1 -2
  111. data/templates/sms-auth.str +1 -1
  112. data/templates/sms-code-field.str +5 -3
  113. data/templates/sms-confirm.str +1 -2
  114. data/templates/sms-disable.str +1 -2
  115. data/templates/sms-request.str +1 -1
  116. data/templates/sms-setup.str +6 -4
  117. data/templates/two-factor-auth.str +5 -0
  118. data/templates/two-factor-disable.str +6 -0
  119. data/templates/two-factor-manage.str +16 -0
  120. data/templates/unlock-account-request.str +2 -2
  121. data/templates/unlock-account.str +1 -1
  122. data/templates/verify-account-resend.str +1 -1
  123. data/templates/verify-account.str +1 -2
  124. data/templates/verify-login-change.str +1 -1
  125. data/templates/webauthn-auth.str +11 -0
  126. data/templates/webauthn-remove.str +14 -0
  127. data/templates/webauthn-setup.str +12 -0
  128. metadata +64 -11
  129. data/doc/verify_change_login.rdoc +0 -11
  130. data/lib/rodauth/features/verify_change_login.rb +0 -20
@@ -10,13 +10,21 @@ login_button :: The text to use for the login button.
10
10
  login_error_flash :: The flash error to show for an unsuccesful login.
11
11
  login_error_status :: The response status to use when using an invalid login or password to login, 401 by default.
12
12
  login_form_footer :: A message to display after the login form.
13
- login_need_password_notice_flash :: The flash notice to show during multi phase login after the login has been entered, when requesting the password.
13
+ login_form_footer_links :: An array of entries for links to show on the login page. Each entry is an array of three elements, sort order (integer), link href, and link text.
14
+ login_form_footer_links_heading :: A heading to show before the login form footer links.
14
15
  login_notice_flash :: The flash notice to show after successful login.
16
+ login_page_title :: The page title to use on the login form.
15
17
  login_redirect :: Where to redirect after a sucessful login.
18
+ login_redirect_session_key :: The key in the session hash storing the location to redirect to after successful login.
19
+ login_return_to_requested_location? :: Whether to redirect to the originally requested location after successful login when +require_login+ was used, false by default.
16
20
  login_route :: The route to the login action. Defaults to +login+.
17
- use_multi_phase_login? :: Whether to ask for login first, and only ask for password after asking for the login, false by default.
21
+ multi_phase_login_forms :: An array of entries for authentication methods that can be used to login when using multi phase login. Each entry is an array of three elements, sort order (integer), HTML, and method to call if this entry is the only authentication method available (or nil to not call a method).
22
+ multi_phase_login_page_title :: The page title to use on the login form after login has been entered when using multi phase login.
23
+ need_password_notice_flash :: The flash notice to show during multi phase login after the login has been entered, when requesting the password.
24
+ use_multi_phase_login? :: Whether to ask for login first, and only ask for password after asking for the login, false by default unless an alternative login feature such as email_auth or webauthn_login is used.
18
25
 
19
26
  == Auth Methods
20
27
 
21
28
  before_login_route :: Run arbitrary code before handling a login route.
22
29
  login_view :: The HTML to use for the login form.
30
+ multi_phase_login_view :: The HTML to use for the login form after login has been entered when using multi phase login.
@@ -5,52 +5,30 @@ use a Rodauth feature that requires setting logins or passwords.
5
5
 
6
6
  == Auth Value Methods
7
7
 
8
- already_an_account_with_this_login_message :: The error message to display when
9
- there already exists an account
10
- with the same login
8
+ already_an_account_with_this_login_message :: The error message to display when there already exists an account with the same login.
11
9
  login_confirm_label :: The label to use for login confirmations.
12
10
  login_confirm_param :: The parameter name to use for login confirmations.
13
- login_does_not_meet_requirements_message :: The error message to display when
14
- the login does not meet the
15
- requirements you have set.
11
+ login_does_not_meet_requirements_message :: The error message to display when the login does not meet the requirements you have set.
16
12
  login_maximum_length :: The maximum length for logins, 255 by default.
17
13
  login_minimum_length :: The minimum length for logins, 3 by default.
18
- login_too_long_message :: The error message fragment to show if the login is
19
- too long.
20
- login_too_short_message :: The error message fragment to show if the login is
21
- too short.
22
- logins_do_not_match_message :: The error message to display when login and
23
- login confirmation do not match.
14
+ login_too_long_message :: The error message fragment to show if the login is too long.
15
+ login_too_short_message :: The error message fragment to show if the login is too short.
16
+ logins_do_not_match_message :: The error message to display when login and login confirmation do not match.
24
17
  password_confirm_label :: The label to use for password confirmations.
25
18
  password_confirm_param :: The parameter name to use for password confirmations.
26
- password_does_not_meet_requirements_message :: The error message to display when
27
- the password does not meet the
28
- requirements you have set.
19
+ password_does_not_meet_requirements_message :: The error message to display when the password does not meet the requirements you have set.
29
20
  password_hash_cost :: The bcrypt cost to use for the password hash.
30
21
  password_minimum_length :: The minimum length for passwords, 6 by default.
31
- password_too_short_message :: The error message fragment to show if the password
32
- is too short.
33
- passwords_do_not_match_message :: The error message to display when password
34
- and password confirmation do not match.
35
- require_email_address_logins? :: Whether logins need to be valid email addresses,
36
- true by default.
37
- require_login_confirmation? :: Whether login confirmations are required when
38
- changing logins or creating accounts.
39
- require_password_confirmation? :: Whether password confirmations are required
40
- when changing/resetting passwords and creating
41
- accounts.
42
- same_as_existing_password_message :: The error message to display when a new
43
- password is the same as the existing password.
22
+ password_too_short_message :: The error message fragment to show if the password is too short.
23
+ passwords_do_not_match_message :: The error message to display when password and password confirmation do not match.
24
+ require_email_address_logins? :: Whether logins need to be valid email addresses, true by default.
25
+ require_login_confirmation? :: Whether login confirmations are required when changing logins or creating accounts. True by default if not verifying the account.
26
+ require_password_confirmation? :: Whether password confirmations are required when changing/resetting passwords and creating accounts.
27
+ same_as_existing_password_message :: The error message to display when a new password is the same as the existing password.
44
28
 
45
29
  == Auth Methods
46
30
 
47
- login_meets_requirements?(login) :: Whether the given login meets the requirements.
48
- By default, just checks that the login is a
49
- valid email address.
50
- password_meets_requirements?(password) :: Whether the given password meets the
51
- requirements. Can be used to implement
52
- complexity requirements for passwords.
31
+ login_meets_requirements?(login) :: Whether the given login meets the requirements. By default, just checks that the login is a valid email address.
53
32
  password_hash(password) :: A hash of the given password.
54
- set_password(password) :: Set the password for the current account to the given
55
- password.
56
-
33
+ password_meets_requirements?(password) :: Whether the given password meets the requirements. Can be used to implement complexity requirements for passwords.
34
+ set_password(password) :: Set the password for the current account to the given password.
@@ -5,10 +5,10 @@ It is the simplest feature.
5
5
 
6
6
  == Auth Value Methods
7
7
 
8
- logout_additional_form_tags :: HTML fragment containing additional form
9
- tags to use on the logout form.
8
+ logout_additional_form_tags :: HTML fragment containing additional form tags to use on the logout form.
10
9
  logout_button :: The text to use for the logout button.
11
10
  logout_notice_flash :: The flash notice to show after logout.
11
+ logout_page_title :: The page title to use on the logout form.
12
12
  logout_redirect :: Where to redirect after a logout.
13
13
  logout_route :: The route to the logout action. Defaults to +logout+.
14
14
 
@@ -1,8 +1,8 @@
1
1
  = Documentation for OTP Feature
2
2
 
3
- The otp feature implements a 2 factor authentication via time-based one-time
4
- passwords (TOTP). It supports signing up for 2 factor authentication, logging
5
- in with authentication codes, and disabling two factor authentication.
3
+ The otp feature implements multifactor authentication via time-based one-time
4
+ passwords (TOTP). It supports setting up TOTP authentication, logging
5
+ in with TOTP authentication codes, and disabling TOTP authentication.
6
6
 
7
7
  The otp feature requires the rotp and rqrcode gems.
8
8
 
@@ -16,36 +16,41 @@ otp_auth_error_flash :: The flash error to show if unable to authenticate via OT
16
16
  otp_auth_failures_limit :: The number of allowed OTP authentication failures before locking out.
17
17
  otp_auth_form_footer :: A footer to display at the bottom of the OTP authentication form.
18
18
  otp_auth_label :: The label for the OTP authentication code.
19
+ otp_auth_link_text :: The text to use for the link from the multifactor auth page.
20
+ otp_auth_page_title :: The page title to use on the OTP authentication form.
19
21
  otp_auth_param :: The parameter name for the OTP authentication code.
20
22
  otp_auth_route :: The route to the OTP authentication action. Defaults to +otp-auth+.
21
23
  otp_class :: The class to use for OTP authentication (default: ROTP::TOTP)
22
24
  otp_digits :: The number of digits to use in OTP authentication codes (rotp's default is 6).
23
- otp_disable_additional_form_tags :: HTML fragment containing additional form tags to use on the from to disable OTP authentication.
24
- otp_disable_button :: The text to use for button on form to disable OTP authentication.
25
+ otp_disable_additional_form_tags :: HTML fragment containing additional form tags to use on the form to disable OTP authentication.
26
+ otp_disable_button :: The text to use for button on the form to disable OTP authentication.
25
27
  otp_disable_error_flash :: The flash error to show if unable to disable OTP authentication.
28
+ otp_disable_link_text :: The text to use for the disable link from the multifactor manage page.
26
29
  otp_disable_notice_flash :: The flash notice to show after disabling OTP authentication.
30
+ otp_disable_page_title :: The page title to use on the OTP disable form.
27
31
  otp_disable_redirect :: Where to redirect after disabling OTP authentication.
28
32
  otp_disable_route :: The route to the OTP disable action. Defaults to +otp-disable+.
29
- otp_drift :: The number of seconds the client and server are allowed to drift apart. The default is nil, to not allow drift.
33
+ otp_drift :: The number of seconds the client and server are allowed to drift apart. The default is 30. Can be set to nil to not allow drift.
34
+ otp_interval :: The number of seconds in which to rotate TOTP auth codes (rotp's default is 30).
30
35
  otp_invalid_auth_code_message :: The error message to show when an invalid OTP authentication code is used.
31
36
  otp_invalid_secret_message :: The error message to show when an invalid OTP secret is submitted during OTP setup.
32
- otp_interval :: The number of seconds in which to rotate TOTP auth codes (rotp's default is 300).
33
- otp_issuer :: The issuer to use in the OTP provisioning URL. Defaults to the host name of the request.
34
- otp_keys_id_column :: The column in the otp_keys_table containing the account id.
35
- otp_keys_column :: The column in the otp_keys_table containing the OTP secret.
36
- otp_keys_failures_column :: The column in the otp_keys_table containing the number of OTP authentication failures.
37
- otp_keys_last_use_column :: The column in otp_keys_table containing the last authentication timestamp.
37
+ otp_issuer :: The issuer to use in the OTP provisioning URL. Defaults to +domain+.
38
+ otp_keys_column :: The column in the +otp_keys_table+ containing the OTP secret.
39
+ otp_keys_failures_column :: The column in the +otp_keys_table+ containing the number of OTP authentication failures.
40
+ otp_keys_id_column :: The column in the +otp_keys_table+ containing the account id.
41
+ otp_keys_last_use_column :: The column in +otp_keys_table+ containing the last authentication timestamp.
38
42
  otp_keys_table :: The table name containing the OTP secrets.
39
43
  otp_keys_use_hmac? :: Whether to use HMACs for OTP keys. Defaults to whether +hmac_secret+ has been set. Should be set to false if adding +hmac_secret+ to Rodauth where the otp feature is already in use, as otherwise it will render existing OTP keys invalid.
40
- otp_lockout_redirect :: Where to redirect if going to OTP authentication page and OTP authentication has been locked out.
41
44
  otp_lockout_error_flash :: The flash error show show when OTP authentication has been locked out due to numerous authentication failures.
45
+ otp_lockout_redirect :: Where to redirect if going to OTP authentication page and OTP authentication has been locked out.
42
46
  otp_provisioning_uri_label :: The label used when displaying the OTP provisioning URI during OTP setup.
43
47
  otp_secret_label :: The label used when displaying the OTP secret during OTP setup.
44
- otp_session_key :: The session key used to store whether the user has authenticated via OTP.
45
48
  otp_setup_additional_form_tags :: HTML fragment containing additional form tags when setting up OTP authentication.
46
49
  otp_setup_button :: Text for the button when setting up OTP authentication.
47
50
  otp_setup_error_flash :: The flash error to show if OTP authentication setup was not successful.
51
+ otp_setup_link_text :: The text to use for the setup link from the multifactor manage page.
48
52
  otp_setup_notice_flash :: The flash notice to show if OTP authentication setup was successful.
53
+ otp_setup_page_title :: The page title to use on the form to setup OTP authentication.
49
54
  otp_setup_param :: The parameter name used for the OTP secret when setting up OTP authentication.
50
55
  otp_setup_raw_param :: The parameter name used for the raw OTP secret when setting up OTP authentication, when +otp_keys_use_hmac?+ is true.
51
56
  otp_setup_redirect :: Where to redirect after sucessful OTP authentication setup.
@@ -56,12 +61,12 @@ otp_setup_route :: The route to the OTP setup action. Defaults to +otp-setup+.
56
61
  after_otp_authentication_failure :: Run arbitrary code after OTP authentication failure.
57
62
  after_otp_disable :: Run arbitrary code after OTP authentication has been disabled.
58
63
  after_otp_setup :: Run arbitrary code after OTP authentication has been setup.
59
- before_otp_authentication :: Run arbitrary code before OTP authentication.
60
64
  before_otp_auth_route :: Run arbitrary code before handling an OTP authentication route.
61
- before_otp_setup :: Run arbitrary code before OTP authentication setup.
62
- before_otp_setup_route :: Run arbitrary code before handling an OTP authentication setup route.
65
+ before_otp_authentication :: Run arbitrary code before OTP authentication.
63
66
  before_otp_disable :: Run arbitrary code before OTP authentication disabling.
64
67
  before_otp_disable_route :: Run arbitrary code before handling an OTP authentication disable route.
68
+ before_otp_setup :: Run arbitrary code before OTP authentication setup.
69
+ before_otp_setup_route :: Run arbitrary code before handling an OTP authentication setup route.
65
70
  otp :: The object used for verifying OTP authentication attempts.
66
71
  otp_add_key(secret) :: Add an OTP key for the current account with the given secret.
67
72
  otp_auth_view :: The HTML to use for the OTP authentication form.
@@ -75,9 +80,9 @@ otp_provisioning_uri :: The provisioning URI displayed during OTP setup.
75
80
  otp_qr_code :: The QR code containing the otp_provisioning_uri, by default an SVG image.
76
81
  otp_record_authentication_failure :: Record an OTP authentication failure.
77
82
  otp_remove :: Removes all stored OTP data for the current account.
78
- otp_remove_auth_failures :: Removes OTP authentication failures for the current account, used after successful OTP authentication.
83
+ otp_remove_auth_failures :: Removes OTP authentication failures for the current account, used after successful multifactor authentication.
79
84
  otp_setup_view :: The HTML to use for the form to setup OTP authentication.
80
- otp_tmp_key(secret) :: Set the secret to use for the OTP key.
85
+ otp_tmp_key(secret) :: Set the secret to use for the temporary OTP key, during OTP setup.
81
86
  otp_update_last_use :: Update the last time OTP authentication was successful for the account. Return true if the authentication should be allowed, or false if it should not be allowed because the last authentication was too recent and indicates the possible reuse of a TOTP authentication code.
82
87
  otp_valid_code?(auth_code) :: Whether the given code is the currently valid OTP auth code for the account.
83
88
  otp_valid_key?(secret) :: Whether the given secret is a valid OTP secret.
@@ -21,30 +21,14 @@ Checks:
21
21
 
22
22
  == Auth Value Methods
23
23
 
24
- password_character_groups :: An array of regular expressions representing
25
- different character groups.
26
- password_dictionary :: A Array/Hash/Set containing dictionary words, which cannot
27
- match the password.
28
- password_dictionary_file :: A file containing dictionary words, which will not be allowed.
29
- By default, <tt>/usr/share/dict/words</tt> if present. Set to
30
- false to not use a password dictionary. Note that this is only
31
- used during initialization, and cannot refer to request-specific
32
- state, unlike most other settings.
33
- password_in_dictionary_message :: The error message fragment to show if the password
34
- is derived from a word in a dictionary.
35
- password_invalid_pattern :: A regexp where any match is considered an invalid password.
36
- For multiple sequences, use +Regexp.union+.
37
- password_invalid_pattern_message :: The error message fragment to show if the password
38
- matches the invalid pattern.
39
- password_max_length_for_groups_check :: The number of characters above which
40
- to skip the checks for character groups.
24
+ password_character_groups :: An array of regular expressions representing different character groups.
25
+ password_dictionary :: A Array/Hash/Set containing dictionary words, which cannot match the password.
26
+ password_dictionary_file :: A file containing dictionary words, which will not be allowed. By default, <tt>/usr/share/dict/words</tt> if present. Set to false to not use a password dictionary. Note that this is only used during initialization, and cannot refer to request-specific state, unlike most other settings.
27
+ password_in_dictionary_message :: The error message fragment to show if the password is derived from a word in a dictionary.
28
+ password_invalid_pattern :: A regexp where any match is considered an invalid password. For multiple sequences, use +Regexp.union+.
29
+ password_invalid_pattern_message :: The error message fragment to show if the password matches the invalid pattern.
30
+ password_max_length_for_groups_check :: The number of characters above which to skip the checks for character groups.
41
31
  password_max_repeating_characters :: The maximum number of repeating characters allowed.
42
- password_min_groups :: The minimum number of character groups the password
43
- has to contain if it is less than
44
- +password_max_length_for_groups_check+ characters.
45
- password_not_enough_character_groups_message :: The error message fragment to show if the
46
- password does not contain characters from
47
- enough character groups.
48
- password_too_many_repeating_characters_message :: The error message fragment to show if the
49
- password contains too many repeating
50
- characters.
32
+ password_min_groups :: The minimum number of character groups the password has to contain if it is less than +password_max_length_for_groups_check+ characters.
33
+ password_not_enough_character_groups_message :: The error message fragment to show if the password does not contain characters from enough character groups.
34
+ password_too_many_repeating_characters_message :: The error message fragment to show if the password contains too many repeating characters.
@@ -20,33 +20,19 @@ expiration is in general a net loss from a security perspective.
20
20
 
21
21
  == Auth Value Methods
22
22
 
23
- allow_password_change_after :: How long in seconds after the last password change
24
- until another password change is allowed (always allowed by default).
25
- password_expiration_error_flash :: The flash error to display when the account's
26
- password has expired and needs to be changed.
27
- password_not_changeable_yet_error_flash :: The flash error to display when not
28
- enough time has elapsed since the last
29
- password change and an attempt is made
30
- to change the password.
31
- password_not_changeable_yet_redirect :: Where to redirect if the password cannot
32
- be changed yet.
33
- password_change_needed_redirect :: Where to redirect if a password needs to be
34
- changes.
35
- password_changed_at_session_key :: The key in the session storing the timestamp the password
36
- was changed at.
37
- password_expiration_default :: If the last password change time for an account cannot
38
- be determined, whether to consider the account expired,
39
- false by default.
23
+ allow_password_change_after :: How long in seconds after the last password change until another password change is allowed (always allowed by default).
24
+ password_change_needed_redirect :: Where to redirect if a password needs to be changed.
25
+ password_changed_at_session_key :: The key in the session storing the timestamp the password was changed at.
26
+ password_expiration_changed_at_column :: The column in the +password_expiration_table+ containing the timestamp
27
+ password_expiration_default :: If the last password change time for an account cannot be determined, whether to consider the account expired, false by default.
28
+ password_expiration_error_flash :: The flash error to display when the account's password has expired and needs to be changed.
29
+ password_expiration_id_column :: The column in the +password_expiration_table+ containing the account's id.
40
30
  password_expiration_table :: The table holding the password last changed timestamps.
41
- password_expiration_id_column :: The column in the +password_expiration_table+ containing
42
- the account's id.
43
- password_expiration_changed_at_column :: The column in the +password_expiration_table+
44
- containing the timestamp
45
- require_password_change_after :: How long in seconds until a password change is
46
- required (90 days by default).
31
+ password_not_changeable_yet_error_flash :: The flash error to display when not enough time has elapsed since the last password change and an attempt is made to change the password.
32
+ password_not_changeable_yet_redirect :: Where to redirect if the password cannot be changed yet.
33
+ require_password_change_after :: How long in seconds until a password change is required (90 days by default).
47
34
 
48
35
  == Auth Methods
49
36
 
50
37
  password_expired? :: Whether the password has expired for the related account.
51
- update_password_changed_at :: Update the password last changed timestamp for the
52
- current account.
38
+ update_password_changed_at :: Update the password last changed timestamp for the current account.
@@ -1,10 +1,24 @@
1
1
  = Documentation for Password Grace Period Feature
2
2
 
3
3
  The password grace period feature keeps track of the last time the
4
- user entered their password, and doesn't require they reenter their
4
+ user entered their password in the session, and doesn't require they reenter their
5
5
  password for account modifications if they recently entered it correctly.
6
6
 
7
+ If you would like to provide extra security before certain routes, you can use
8
+ the confirm password feature to require users to reenter their password if they
9
+ haven't entered it recently:
10
+
11
+ rodauth.require_password_authentication
12
+
13
+ By default, this does not redirect if the session has been authenticated via
14
+ password, but with the password_grace_period feature, it also redirects if the
15
+ password has not been entered recently.
16
+
7
17
  == Auth Value Methods
8
18
 
9
- password_grace_period :: The number of seconds after a password entry until password reentry is required, 300 by default (5 minutes).
10
19
  last_password_entry_session_key :: The session key in which to store the last password entry time.
20
+ password_grace_period :: The number of seconds after a password entry until password reentry is required, 300 by default (5 minutes).
21
+
22
+ == Auth Methods
23
+
24
+ password_recently_entered? :: Whether the password has last been entered within the grace period.
@@ -1,8 +1,8 @@
1
1
  = Documentation for Recovery Codes Feature
2
2
 
3
- The recovery codes feature allows 2nd factor authentication via single use recovery
4
- codes. It is usually used as a backup if OTP authentication is not available or
5
- has been locked out, but can be used by itself or as a backup to SMS codes. It allows
3
+ The recovery codes feature allows multifactor authentication via single use recovery
4
+ codes. It is usually used as a backup if other multifactor authentication methods are
5
+ not available or have been locked out, but can be used by itself. It allows
6
6
  users to view authentication recovery codes as well as regenerate recovery codes.
7
7
 
8
8
  Access to recovery codes is limited to authenticated sessions only, so users should
@@ -11,25 +11,31 @@ of them being required due to a missing / lost device.
11
11
 
12
12
  == Auth Value Methods
13
13
 
14
- add_recovery_codes_button :: Text to use for button on form to add recovery codes.
14
+ add_recovery_codes_redirect :: Where to redirect to add recovery codes if recovery codes are the primary multifactor authentication and have not been setup yet.
15
+ add_recovery_codes_button :: Text to use for button on the form to add recovery codes.
15
16
  add_recovery_codes_error_flash :: The flash error to show when adding recovery codes.
16
- add_recovery_codes_heading :: Text to use for heading above form to add recovery codes.
17
+ add_recovery_codes_heading :: Text to use for heading above the form to add recovery codes.
18
+ add_recovery_codes_page_title :: The page title to use on the add recovery codes form.
17
19
  add_recovery_codes_param :: The parameter name to use for adding recovery codes.
18
- add_recovery_auth_redirect :: Where to redirect to add recovery codes if recovery codes are the primary 2nd factor and have not been setup yet.
20
+ auto_add_recovery_codes? :: Whether to automatically add recovery codes (or any missing recovery codes) when another multifactor authentication type is enabled (false by default).
19
21
  invalid_recovery_code_error_flash :: The flash error to show when an invalid recovery code is used.
20
22
  invalid_recovery_code_message :: The error message to show when an invalid recovery code is used.
21
23
  recovery_auth_additional_form_tags :: HTML fragment containing additional form tags when authenticating via a recovery code.
22
24
  recovery_auth_button :: The text to use for the button when authenticating via a recovery code.
25
+ recovery_auth_link_text :: The text to use for the link from the multifactor auth page.
26
+ recovery_auth_page_title :: The page title to use on the form to authenticate via a recovery code.
23
27
  recovery_auth_redirect :: Where to redirect after authenticating via an recovery code.
24
28
  recovery_auth_route :: The route to the recovery code authentication action. Defaults to +recovery-auth+.
25
29
  recovery_codes_added_notice_flash :: The flash notice to show when recovery codes were added.
26
30
  recovery_codes_additional_form_tags :: HTML fragment containing additional form tags when adding recovery codes.
27
- recovery_codes_column :: The column in the recovery_codes_table containing the recovery code.
28
- recovery_codes_id_column :: The column in the recovery_codes_table containing the account id.
31
+ recovery_codes_column :: The column in the +recovery_codes_table+ containing the recovery code.
32
+ recovery_codes_id_column :: The column in the +recovery_codes_table+ containing the account id.
29
33
  recovery_codes_label :: The label for recovery codes.
30
- recovery_codes_limit :: The number of recovery codes to allow.
34
+ recovery_codes_limit :: The number of recovery codes to setup.
35
+ recovery_codes_link_text :: The text to use for the setup link from the multifactor manage page.
36
+ recovery_codes_page_title :: The page title to use on the form to view recovery codes.
31
37
  recovery_codes_param :: The parameter name for the recovery code.
32
- recovery_codes_primary? :: Whether recovery codes are the primary second factor, true by default if neither the otp or sms_codes features are enabled.
38
+ recovery_codes_primary? :: Whether recovery codes are a primary multifactor authentication type. If not, they cannot be setup unless multifactor authentication is already setup.
33
39
  recovery_codes_route :: The route to the view recovery codes action. Defaults to +recovery-codes+.
34
40
  recovery_codes_table :: The table storing the recovery codes.
35
41
  view_recovery_codes_button :: Text for the button to view recovery codes.
@@ -41,8 +47,8 @@ add_recovery_code :: Add a recovery code for the given account.
41
47
  add_recovery_codes_view :: The HTML to use for the add recovery codes form.
42
48
  after_add_recovery_codes :: Run arbitrary code after adding recovery codes.
43
49
  before_add_recovery_codes :: Run arbitrary code before adding recovery codes.
44
- before_recovery_auth :: Run arbitrary code before recovery authentication.
45
- before_recovery_auth_route :: Run arbitrary code before handling recovery authentication route.
50
+ before_recovery_auth :: Run arbitrary code before recovery code authentication.
51
+ before_recovery_auth_route :: Run arbitrary code before handling recovery code authentication route.
46
52
  before_recovery_codes_route :: Run arbitrary code before handling view/add recovery codes route.
47
53
  before_view_recovery_codes :: Run arbitrary code before viewing recovery codes.
48
54
  can_add_recovery_codes? :: Whether the current account can add more recovery codes.
@@ -0,0 +1,361 @@
1
+ = New Features
2
+
3
+ * A webauthn feature has been added, allowing multifactor
4
+ authentication using WebAuthn. It allows for registering multiple
5
+ WebAuthn authenticators per account, authenticating using
6
+ WebAuthn, and removing WebAuthn authenticators. This feature
7
+ depends on the webauthn gem.
8
+
9
+ WebAuthn in browsers requires javascript to work, but Rodauth's
10
+ approach has the javascript set hidden form inputs and then use a
11
+ standard form submission, making it easy to test applications
12
+ using WebAuthn without a full browser, as long as a software
13
+ WebAuthn authenticator can be used (the webauthn gem provides
14
+ such an authenticator).
15
+
16
+ * A webauthn_login feature has been added, allowing passwordless
17
+ logins using WebAuthn.
18
+
19
+ * A webauthn_verify_account feature has been added, which requires
20
+ setting up a WebAuthn authenticator during account verification.
21
+ This allows for setups where WebAuthn is the sole method of
22
+ authentication.
23
+
24
+ * An active_sessions feature has been added, which disallows
25
+ session reuse after logout, and allows for a global logout of all
26
+ sessions for the account. It also supports inactivity and
27
+ lifetime deadlines for sessions. This also integrates with the
28
+ jwt_refresh feature to disable JWT access token usage after
29
+ logout.
30
+
31
+ * An audit_logging feature has been added, which logs Rodauth
32
+ actions to a database table. This hooks into all of Rodauth's
33
+ after_* hooks, and will implement audit logging for all
34
+ features that use such hooks.
35
+
36
+ * The confirm_password feature can now operate as multifactor
37
+ authentication if the user has a password but was originally
38
+ authenticated using the webauthn_login feature.
39
+
40
+ * The multifactor authentication support now better handles
41
+ multiple multifactor authentication methods. When setting up
42
+ multifactor authentication, a page is provided linking to all
43
+ enabled multifactor authentication options. When authenticating
44
+ via an additional factor, a page is provided linking to all
45
+ multifactor authentication options that have been setup and are
46
+ available for use. There is also a page to disable all multifactor
47
+ authentication methods that have been setup, and revert to single
48
+ factor authentication.
49
+
50
+ To provide a better user experience, if there would only be a
51
+ single link on the pages to setup multifactor authentication
52
+ or authenticate with an additional factor, the user is redirected
53
+ directly to the appropriate page.
54
+
55
+ * A translate configuration method has been added. This is called
56
+ with a translation key and default value for the translation, and
57
+ allows for internationalizing Rodauth. All translatable strings
58
+ are passed through this method, including flash messages, page
59
+ titles, button text, field error messages, and link texts.
60
+
61
+ * login_return_to_requested_location? and
62
+ two_factor_auth_return_to_requested_location? configuration methods
63
+ have been added. With these methods set to true, if
64
+ rodauth.require_login needs to redirect, it will store the current
65
+ page, and after logging in, the user will be redirected back to the
66
+ page. Likewise, if rodauth.require_two_factor_authenticated needs
67
+ to redirect, it will store the current page, and after multifactor
68
+ authentication, the user will be redirected back to the page.
69
+
70
+ * domain and base_url configuration methods have been added and it is
71
+ recommended that applications use them if they can be reached with
72
+ arbitrary Host headers. If not set, Rodauth will use information
73
+ from the request, which can be provided by an attacker.
74
+
75
+ * The *_url and *_path methods now accept an optional hash of query
76
+ parameters to use.
77
+
78
+ * Many Rodauth forms will now use appropriate autocomplete and
79
+ inputmode attributes on form inputs. You can modify the behavior
80
+ using the following configuration methods:
81
+
82
+ * autocomplete_for_field?
83
+ * inputmode_for_field?
84
+ * mark_input_fields_with_autocomplete?
85
+ * mark_input_fields_with_inputmode?
86
+
87
+ * An sms_phone_input_type configuration method has been added and
88
+ now defaults to tel. Previous, the SMS phone input used a text
89
+ type.
90
+
91
+ * rodauth.require_password_authentication has been added to the
92
+ confirm_password_feature, which will redirect to the login page
93
+ if not logged in, and will redirect to the confirm password page
94
+ if the user was logged in without typing in a password. If the
95
+ password_grace_period feature is used, this also redirects if
96
+ the password has not been entered recently.
97
+
98
+ * rodauth.authenticated_by has been added, which is an array of
99
+ strings for all methods by which the current session has been
100
+ authenticated, or nil if the session has not been authenticated.
101
+
102
+ * rodauth.possible_authentication_methods has been added, which is
103
+ an array of strings for all methods by which the current session
104
+ could be authenticated.
105
+
106
+ * rodauth.autologin_type now returns the type of autologin used if
107
+ authenticated using autologin.
108
+
109
+ * All *_view configuration methods now have *_page_title
110
+ configuration methods for setting custom page titles.
111
+
112
+ = Other Improvements
113
+
114
+ * The templates Rodauth uses by default are now compatible with
115
+ Bootstrap 4, and compatibility with Bootstrap 3 (which Rodauth
116
+ previously targeted) has been improved.
117
+
118
+ * When requesting a password reset, if the user provides an invalid
119
+ login, an input for the login is now displayed so the problem
120
+ can be corrected.
121
+
122
+ * When setting up an additional multifactor authentication method,
123
+ Rodauth no longer overrides which multifactor authentication method
124
+ was used to authenticate the current session.
125
+
126
+ * When disabling a multifactor authentication method that was not
127
+ used to authenticate the current session, the session remains
128
+ multifactor authenticated.
129
+
130
+ * When multiple multifactor authentication methods are setup for
131
+ an account, disabling a multifactor authentication method will not
132
+ mark the session as not having multifactor authentication enabled.
133
+
134
+ * When disabling OTP authentication, future calls to
135
+ rodauth.otp_exists? will return false instead of true.
136
+
137
+ * Recovery codes are no longer generated automatically when OTP or
138
+ SMS authentication is setup. There is no point generating codes
139
+ that the user has not yet viewed, and generating them automatically
140
+ will disable automatic redirections in the cases where only one
141
+ multifactor authentication method is setup. This can be turned
142
+ back on using the auto_add_recovery_codes? configuration method.
143
+
144
+ * The OTP setup page now displays better on phones and other devices
145
+ with small viewports.
146
+
147
+ * Links and alternative login forms shown on the login page are
148
+ now in a specific order and not based on the order in which
149
+ features were enabled.
150
+
151
+ * The link to resend the verify account email is not shown on the
152
+ multi-phase login page after the login has been entered if the
153
+ account has already been verified.
154
+
155
+ * The modifications_require_password? configuration method now
156
+ defaults to false for accounts that do not have a password.
157
+
158
+ * Multifactor authentication is no longer allowed using the same
159
+ factor type as used for initial authentication. Previously,
160
+ no multifactor authentication type could be used for initial
161
+ authentication, so this wasn't an issue.
162
+
163
+ * The verify login change page no longer calls already_logged_in
164
+ if the session is already logged in. This method is documented
165
+ to only be called on pages that expect not to be already logged
166
+ in, and it's common to access the verify login change page
167
+ while being logged in, since you need to be logged in to go to
168
+ the change login page. The default behavior of already_logged_in
169
+ is to do nothing, so this only affects you if you have used the
170
+ already_logged_in configuration method.
171
+
172
+ * If using the email_auth and verify_account_grace_period features
173
+ together, do not show email authentication as an option for
174
+ unverified accounts during the grace period.
175
+
176
+ * In the lockout feature, generate the unlock account key before
177
+ calling send_unlock_account_email, similar to how key generation
178
+ happens in other features that send email. This makes it easier
179
+ to override the method.
180
+
181
+ * Various method visibility issues have been fixed, so that
182
+ enabling any feature that ships with Rodauth will not affect
183
+ visibility of methods for features already enabled.
184
+
185
+ * All Rodauth configuration methods (over 1000) are now documented.
186
+
187
+ = Backwards Compatibility
188
+
189
+ * The verify_change_login feature has been removed. Users should
190
+ switch to the verify_login_change feature, which verifies the
191
+ new login works correctly before switching the login.
192
+
193
+ * For CSRF protection, Roda's route_csrf plugin is now used by
194
+ default instead of rack_csrf. This supports request specific
195
+ CSRF tokens by default. The :csrf=>:rack_csrf plugin option
196
+ can be used to continue using rack_csrf.
197
+
198
+ Roda's route_csrf allows for per-route checking of the CSRF token,
199
+ and support for that is enabled for all Rodauth routes. However,
200
+ if you were using Rodauth without explicitly loading rack_csrf,
201
+ these changes could remove CSRF support from your application.
202
+ You should probably load Roda's route_csrf plugin explicitly and
203
+ use it in your Roda routing tree if you want CSRF protection for
204
+ non-Rodauth routes. You can use the new check_csrf_opts and
205
+ check_csrf_block to customize options to pass to check_csrf!, or
206
+ set check_csrf? false to disable calling check_csrf!.
207
+
208
+ * Email rate limiting is now enabled by default in the lockout,
209
+ reset_password, and verify_account features. This requires
210
+ adding a column to store the last email sent time to the
211
+ related tables, if the tables were created without one:
212
+
213
+ DB.add_column :account_password_reset_keys, :email_last_sent,
214
+ DateTime, :null=>false, :default=>Sequel::CURRENT_TIMESTAMP
215
+ DB.add_column :account_verification_keys, :email_last_sent,
216
+ DateTime, :null=>false, :default=>Sequel::CURRENT_TIMESTAMP
217
+ DB.add_column :account_lockouts, :email_last_sent, DateTime
218
+
219
+ Alternatively, you can set the appropriate configuration method
220
+ (e.g. verify_account_email_last_sent_column) to nil to disable
221
+ rate limiting.
222
+
223
+ * The http_basic_auth feature has been changed significantly.
224
+ You should now call rodauth.http_basic_auth in the routing tree
225
+ to load authentication information from the Authorization
226
+ request header, similar to how rodauth.load_memory works in the
227
+ remember feature.
228
+
229
+ The require_http_basic_auth configuration method has been renamed
230
+ to require_http_basic_auth?. rodauth.require_http_basic_auth?
231
+ should now be used to check whether HTTP basic auth is required.
232
+ rodauth.require_http_basic_auth now requires that HTTP basic
233
+ auth is provided in the request.
234
+
235
+ To be more backwards compatible, if not already logged in,
236
+ rodauth.require_login will load HTTP basic auth information if
237
+ available, and will require HTTP basic auth if
238
+ require_http_basic_auth? is configured.
239
+
240
+ * If using the Bootstrap 3/4 compatibility, the forms used are
241
+ now standard (vertical) Bootstrap forms. Previously, they were
242
+ horizontal forms.
243
+
244
+ * Most of the strings related to multifactor authentication have
245
+ been changed to refer to multifactor authentication instead of
246
+ two factor authentication, or changed to refer to a specific
247
+ multifactor authentication type (such as TOTP), as appropriate.
248
+
249
+ * Periods at the end of some default flash messages have been
250
+ removed for consistency.
251
+
252
+ * The remember feature no longer depends on the confirm_password
253
+ feature. You must now enable confirm_password separately if you
254
+ want to use it.
255
+
256
+ * Login confirmation is no longer required by default when
257
+ verifying accounts or verifying login changes. In both cases,
258
+ entering an invalid login causes no problems.
259
+
260
+ * The otp_drift configuration method now defaults to 30, to allow
261
+ 30 seconds of drift. The previous setting of nil generally
262
+ resulted in usability problems, especially without good clock
263
+ synchronization.
264
+
265
+ * The json_response_custom_error_status? configuration method now
266
+ defaults to true, so that custom error statuses are now used by
267
+ default, instead of a generic 400 response.
268
+
269
+ * The jwt_check_accept? configuration method now defaults to true,
270
+ so that the request Accept header is checked.
271
+
272
+ * The verify_account_set_password? configuration method now defaults
273
+ to true, so that passwords will be set when verifying accounts
274
+ instead of when creating accounts. This prevents issues when
275
+ an attacker creates an account with a password they know, if the
276
+ user with access to the email address verifies the account.
277
+
278
+ * The mark_input_fields_as_required? configuration method now defaults
279
+ to true. Most of rodauth's input fields are required, and this
280
+ provides a nicer experience. However, it may cause accessibility
281
+ issues if screen readers do not handle invalid form submissions due
282
+ to missing required fields in an accessible manner.
283
+
284
+ * The login_input_type configuration method now defaults to email if
285
+ login_column is :email (the default setting). This can cause
286
+ accessibility issues if screen readers do not handle invalid form
287
+ submissions due to an invalid login field format in an accessible
288
+ manner. It can also break installations that leave login_column
289
+ as :email but do not use email addresses for logins.
290
+
291
+ * The json_response_success_key configuration method now defaults to
292
+ success, so success messages are included by default. This can be
293
+ set back to nil to not include them.
294
+
295
+ * The single_session and session_expiration plugin now use a
296
+ configurable error status code for JSON requests when the session
297
+ has expired, using inactive_session_error_status and
298
+ session_expiration_error_status configuration methods,
299
+ respectively.
300
+
301
+ * If you are using the jwt_refresh feature and used the migration
302
+ previously recommended in the README, you should mark the account_id
303
+ field as NOT NULL and add an index:
304
+
305
+ DB.alter_table(:account_jwt_refresh_keys) do
306
+ set_column_not_null :account_id
307
+ add_index :account_id, :name=>:account_jwt_rk_account_id_idx
308
+ end
309
+
310
+ * The otp authentication form no longer shows SMS or recovery code
311
+ information on failure. The multifactor authentication page will
312
+ have links to SMS or recovery code authentication if they have been
313
+ setup, and will redirect or show the appropriate links to those
314
+ authentication methods if OTP authentication gets locked out.
315
+
316
+ * Disabling OTP authentication no longer automatically disables SMS
317
+ authentication and recovery codes, and disabling SMS authentication
318
+ no longer disables recovery codes. To disable all multifactor
319
+ authentication methods at once, the new multifactor authentication
320
+ disable page should be used. If you want to revert to the previous
321
+ behavior of automatic disabling, override after_otp_disable to
322
+ disable SMS and recovery codes, and override after_sms_disable to
323
+ disable recovery codes.
324
+
325
+ * HTML id attributes in the recovery_codes and remember features have
326
+ been modified to use - instead of _, for consistency with all other
327
+ Rodauth features.
328
+
329
+ * Ruby 1.8 support has been dropped. The minimum supported version is
330
+ now Ruby 1.9.2. Support for versions of Ruby that are no longer
331
+ supported by ruby-core may be dropped in future minor releases if
332
+ keeping the support becomes a maintenance issue.
333
+
334
+ * The following configuration methods have been replaced:
335
+
336
+ * create_account_link -> create_account_link_text
337
+ * reset_password_request_link -> reset_password_request_link_text
338
+ * verify_account_resend_link -> verify_account_resend_link_text
339
+
340
+ The new methods take only the text of the link, the path to link
341
+ to can already be determined by Rodauth.
342
+
343
+ * The following configuration methods have been removed:
344
+
345
+ * account_model
346
+ * attempt_to_create_unverified_account_notice_message
347
+ * attempt_to_login_to_unverified_account_notice_message
348
+ * before_otp_authentication_route
349
+ * clear_remembered_session_key
350
+ * no_matching_email_auth_key_message
351
+ * no_matching_reset_password_key_message
352
+ * no_matching_unlock_account_key_message
353
+ * no_matching_verify_account_key_message
354
+ * no_matching_verify_login_change_key_message
355
+ * remembered_session_key
356
+ * two_factor_session_key
357
+
358
+ Most of these methods were already deprecated.
359
+
360
+ * Route blocks in external Rodauth features must now have an arity
361
+ of 1.