rodauth 1.23.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +184 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +221 -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 +76 -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/guides/admin_activation.rdoc +46 -0
  19. data/doc/guides/already_authenticated.rdoc +10 -0
  20. data/doc/guides/alternative_login.rdoc +46 -0
  21. data/doc/guides/create_account_programmatically.rdoc +38 -0
  22. data/doc/guides/delay_password.rdoc +25 -0
  23. data/doc/guides/email_only.rdoc +16 -0
  24. data/doc/guides/i18n.rdoc +26 -0
  25. data/doc/{internals.rdoc → guides/internals.rdoc} +0 -0
  26. data/doc/guides/links.rdoc +12 -0
  27. data/doc/guides/login_return.rdoc +37 -0
  28. data/doc/guides/password_column.rdoc +25 -0
  29. data/doc/guides/password_confirmation.rdoc +37 -0
  30. data/doc/guides/password_requirements.rdoc +30 -0
  31. data/doc/guides/paths.rdoc +36 -0
  32. data/doc/guides/query_params.rdoc +9 -0
  33. data/doc/guides/redirects.rdoc +17 -0
  34. data/doc/guides/registration_field.rdoc +68 -0
  35. data/doc/guides/require_mfa.rdoc +30 -0
  36. data/doc/guides/reset_password_autologin.rdoc +21 -0
  37. data/doc/guides/status_column.rdoc +28 -0
  38. data/doc/guides/totp_or_recovery.rdoc +16 -0
  39. data/doc/http_basic_auth.rdoc +10 -1
  40. data/doc/jwt.rdoc +22 -22
  41. data/doc/jwt_cors.rdoc +2 -3
  42. data/doc/jwt_refresh.rdoc +23 -8
  43. data/doc/lockout.rdoc +17 -15
  44. data/doc/login.rdoc +17 -2
  45. data/doc/login_password_requirements_base.rdoc +18 -37
  46. data/doc/logout.rdoc +2 -2
  47. data/doc/otp.rdoc +25 -19
  48. data/doc/password_complexity.rdoc +10 -26
  49. data/doc/password_expiration.rdoc +11 -25
  50. data/doc/password_grace_period.rdoc +16 -2
  51. data/doc/password_pepper.rdoc +44 -0
  52. data/doc/recovery_codes.rdoc +18 -12
  53. data/doc/release_notes/2.0.0.txt +361 -0
  54. data/doc/release_notes/2.1.0.txt +31 -0
  55. data/doc/release_notes/2.2.0.txt +39 -0
  56. data/doc/release_notes/2.3.0.txt +37 -0
  57. data/doc/release_notes/2.4.0.txt +22 -0
  58. data/doc/remember.rdoc +40 -64
  59. data/doc/reset_password.rdoc +12 -9
  60. data/doc/session_expiration.rdoc +1 -0
  61. data/doc/single_session.rdoc +16 -25
  62. data/doc/sms_codes.rdoc +24 -14
  63. data/doc/two_factor_base.rdoc +60 -22
  64. data/doc/verify_account.rdoc +14 -12
  65. data/doc/verify_account_grace_period.rdoc +6 -2
  66. data/doc/verify_login_change.rdoc +9 -8
  67. data/doc/webauthn.rdoc +115 -0
  68. data/doc/webauthn_login.rdoc +15 -0
  69. data/doc/webauthn_verify_account.rdoc +9 -0
  70. data/javascript/webauthn_auth.js +45 -0
  71. data/javascript/webauthn_setup.js +35 -0
  72. data/lib/roda/plugins/rodauth.rb +1 -1
  73. data/lib/rodauth.rb +33 -28
  74. data/lib/rodauth/features/account_expiration.rb +5 -5
  75. data/lib/rodauth/features/active_sessions.rb +158 -0
  76. data/lib/rodauth/features/audit_logging.rb +98 -0
  77. data/lib/rodauth/features/base.rb +152 -49
  78. data/lib/rodauth/features/change_password_notify.rb +1 -1
  79. data/lib/rodauth/features/close_account.rb +8 -6
  80. data/lib/rodauth/features/confirm_password.rb +40 -2
  81. data/lib/rodauth/features/create_account.rb +8 -13
  82. data/lib/rodauth/features/disallow_common_passwords.rb +1 -1
  83. data/lib/rodauth/features/disallow_password_reuse.rb +5 -3
  84. data/lib/rodauth/features/email_auth.rb +30 -28
  85. data/lib/rodauth/features/email_base.rb +3 -3
  86. data/lib/rodauth/features/http_basic_auth.rb +55 -35
  87. data/lib/rodauth/features/jwt.rb +63 -16
  88. data/lib/rodauth/features/jwt_cors.rb +15 -15
  89. data/lib/rodauth/features/jwt_refresh.rb +42 -13
  90. data/lib/rodauth/features/lockout.rb +11 -13
  91. data/lib/rodauth/features/login.rb +58 -13
  92. data/lib/rodauth/features/login_password_requirements_base.rb +13 -8
  93. data/lib/rodauth/features/otp.rb +76 -82
  94. data/lib/rodauth/features/password_complexity.rb +8 -13
  95. data/lib/rodauth/features/password_expiration.rb +1 -1
  96. data/lib/rodauth/features/password_grace_period.rb +17 -10
  97. data/lib/rodauth/features/password_pepper.rb +45 -0
  98. data/lib/rodauth/features/recovery_codes.rb +47 -51
  99. data/lib/rodauth/features/remember.rb +13 -27
  100. data/lib/rodauth/features/reset_password.rb +25 -25
  101. data/lib/rodauth/features/session_expiration.rb +7 -10
  102. data/lib/rodauth/features/single_session.rb +8 -6
  103. data/lib/rodauth/features/sms_codes.rb +58 -68
  104. data/lib/rodauth/features/two_factor_base.rb +134 -30
  105. data/lib/rodauth/features/verify_account.rb +28 -20
  106. data/lib/rodauth/features/verify_account_grace_period.rb +18 -9
  107. data/lib/rodauth/features/verify_login_change.rb +11 -10
  108. data/lib/rodauth/features/webauthn.rb +505 -0
  109. data/lib/rodauth/features/webauthn_login.rb +70 -0
  110. data/lib/rodauth/features/webauthn_verify_account.rb +46 -0
  111. data/lib/rodauth/migrations.rb +16 -5
  112. data/lib/rodauth/version.rb +2 -2
  113. data/templates/button.str +1 -3
  114. data/templates/change-login.str +1 -2
  115. data/templates/change-password.str +3 -5
  116. data/templates/close-account.str +2 -2
  117. data/templates/confirm-password.str +1 -1
  118. data/templates/create-account.str +1 -1
  119. data/templates/email-auth-request-form.str +1 -2
  120. data/templates/email-auth.str +1 -1
  121. data/templates/global-logout-field.str +6 -0
  122. data/templates/login-confirm-field.str +2 -4
  123. data/templates/login-display.str +3 -2
  124. data/templates/login-field.str +2 -4
  125. data/templates/login-form-footer.str +6 -0
  126. data/templates/login-form.str +7 -0
  127. data/templates/login.str +1 -9
  128. data/templates/logout.str +1 -1
  129. data/templates/multi-phase-login.str +3 -0
  130. data/templates/otp-auth-code-field.str +5 -3
  131. data/templates/otp-auth.str +1 -1
  132. data/templates/otp-disable.str +1 -1
  133. data/templates/otp-setup.str +3 -3
  134. data/templates/password-confirm-field.str +2 -4
  135. data/templates/password-field.str +2 -4
  136. data/templates/recovery-auth.str +3 -6
  137. data/templates/recovery-codes.str +1 -1
  138. data/templates/remember.str +15 -20
  139. data/templates/reset-password-request.str +2 -2
  140. data/templates/reset-password.str +1 -2
  141. data/templates/sms-auth.str +1 -1
  142. data/templates/sms-code-field.str +5 -3
  143. data/templates/sms-confirm.str +1 -2
  144. data/templates/sms-disable.str +1 -2
  145. data/templates/sms-request.str +1 -1
  146. data/templates/sms-setup.str +6 -4
  147. data/templates/two-factor-auth.str +5 -0
  148. data/templates/two-factor-disable.str +6 -0
  149. data/templates/two-factor-manage.str +16 -0
  150. data/templates/unlock-account-request.str +2 -2
  151. data/templates/unlock-account.str +1 -1
  152. data/templates/verify-account-resend.str +1 -1
  153. data/templates/verify-account.str +1 -2
  154. data/templates/verify-login-change.str +1 -1
  155. data/templates/webauthn-auth.str +11 -0
  156. data/templates/webauthn-remove.str +14 -0
  157. data/templates/webauthn-setup.str +12 -0
  158. metadata +96 -13
  159. data/doc/verify_change_login.rdoc +0 -11
  160. data/lib/rodauth/features/verify_change_login.rb +0 -20
@@ -11,13 +11,12 @@ This feature depends on the jwt feature.
11
11
 
12
12
  == Auth Value Methods
13
13
 
14
- jwt_cors_allow_origin :: Which origins are allowed to perform CORS requests. The default is +false+. This can be a String, Array of Strings, Regexp, or +true+ to allow CORS requests from any domain.
15
- jwt_cors_allow_methods :: For allowed CORS-preflight requests, the value returned in the Access-Control-Allow-Methods header (default: 'POST'). This specifies which methods are allowed in CORS requests.
16
14
  jwt_cors_allow_headers :: For allowed CORS-preflight requests, the value returned in the Access-Control-Allow-Headers header (default: 'Content-Type, Authorization, Accept'). This specifies which headers can be included in CORS requests.
15
+ jwt_cors_allow_methods :: For allowed CORS-preflight requests, the value returned in the Access-Control-Allow-Methods header (default: 'POST'). This specifies which methods are allowed in CORS requests.
16
+ jwt_cors_allow_origin :: Which origins are allowed to perform CORS requests. The default is +false+. This can be a String, Array of Strings, Regexp, or +true+ to allow CORS requests from any domain.
17
17
  jwt_cors_expose_headers :: For allowed CORS requests, the value returned in the Access-Control-Expose-Headers header (default: 'Authorization'). This specifies which headers the browser is allowed to access from a response to a CORS request.
18
18
  jwt_cors_max_age :: For allowed CORS-preflight requests, the value returned in the Access-Control-Max-Age header (default: 86400). This specifies how long before the information returned should be considered stale and another CORS preflight request made.
19
19
 
20
20
  == Auth Methods
21
21
 
22
22
  jwt_cors_allow? :: Whether the request should be allowed. This is called for all requests for a Rodauth route that include an Origin header. It should return true or false for whether to specially handle the cross-origin request. By default, uses the +jwt_cors_allow_origin+ setting to check the origin.
23
-
@@ -5,11 +5,22 @@ setting a short lifetime on JWT access tokens.
5
5
 
6
6
  When this feature is used, the access and refresh token are provided
7
7
  at login in the response body (the access token is still provided in the Authorization
8
- header), and for any subsequent POST to /jwt-refresh.
8
+ header), and for any subsequent POST to <tt>/jwt-refresh</tt>.
9
9
 
10
- Note that using the refresh token invalides the old refresh token and creates
10
+ Note that using the refresh token invalides the token and creates
11
11
  a new access token with an updated lifetime. However, it does not invalidate
12
- older access tokens. Older access tokens remain valid until they expire.
12
+ older access tokens. Older access tokens remain valid until they expire. You
13
+ can use the active_sessions feature if you want previous access tokens to be invalid
14
+ as soon as the refresh token is used.
15
+
16
+ You can have multiple active refresh tokens active at a time, since each browser session
17
+ will generally use a separate refresh token. If you would like to revoke a refresh token
18
+ when logging out, provide the refresh token when submitting the JSON request to logout.
19
+ If you would like to remove all refresh tokens for the account when logging out, provide
20
+ a value of <tt>all</tt> as the token value.
21
+
22
+ When using the refresh token, you must provide a valid access token, as that contains
23
+ information about the current session, which is used to create the new access token.
13
24
 
14
25
  This feature depends on the jwt feature.
15
26
 
@@ -18,18 +29,22 @@ This feature depends on the jwt feature.
18
29
  jwt_access_token_key :: Name of the key in the response json holding the access token. Default is +access_token+.
19
30
  jwt_access_token_not_before_period :: How many seconds before the current time will the jwt be considered valid (to account for inaccurate clocks). Default is 5.
20
31
  jwt_access_token_period :: Validity of an access token in seconds, default is 1800 (30 minutes).
32
+ jwt_refresh_route :: The route to the login action. Defaults to <tt>jwt-refresh</tt>.
21
33
  jwt_refresh_invalid_token_message :: Error message when the provided refresh token is non existent, invalid or expired.
22
- jwt_refresh_token_account_id_column :: The column name in the refresh token table storing the account id, should be a foreign key referencing the accounts table.
23
- jwt_refresh_token_deadline_column :: The column name in the refresh token keys table storing the deadline after which the refresh token will no longer be valid.
24
- jwt_refresh_token_deadline_interval :: validity of a refresh token. Default is 14 days.
34
+ jwt_refresh_token_account_id_column :: The column name in the +jwt_refresh_token_table+ storing the account id, should be a foreign key referencing the accounts table.
35
+ jwt_refresh_token_deadline_column :: The column name in the +jwt_refresh_token_table+ storing the deadline after which the refresh token will no longer be valid.
36
+ jwt_refresh_token_deadline_interval :: Validity of a refresh token. Default is 14 days.
25
37
  jwt_refresh_token_id_column :: The column name in the refresh token keys table storing the id of each token (the primary key of the table).
26
38
  jwt_refresh_token_key :: Name of the key in the response json holding the refresh token. Default is +refresh_token+.
27
- jwt_refresh_token_key_column :: The column name in the refresh token keys table holding the refresh token key value.
39
+ jwt_refresh_token_key_column :: The column name in the +jwt_refresh_token_table+ holding the refresh token key value.
28
40
  jwt_refresh_token_key_param :: Name of parameter in which the refresh token is provided when requesting a new token. Default is +refresh_token+.
29
41
  jwt_refresh_token_table :: Name of the table holding refresh token keys.
42
+ jwt_refresh_without_access_token_message :: Error message when trying to refresh with providing an access token.
43
+ jwt_refresh_without_access_token_status :: The HTTP status code to use when trying to refresh without providing an access token.
30
44
 
31
45
  == Auth Methods
32
46
 
33
- after_refresh_token :: Hooks for specific processing once the refresh token has been set.
34
47
  account_from_refresh_token(token) :: Returns the account hash for the given refresh token.
48
+ after_refresh_token :: Hooks for specific processing once the refresh token has been set.
49
+ before_jwt_refresh_route :: Run arbitrary code before handling a jwt_refresh route.
35
50
  before_refresh_token :: Hooks for specific processing before the refresh token is computed.
@@ -8,37 +8,39 @@ unlock via an email sent to them.
8
8
 
9
9
  == Auth Value Methods
10
10
 
11
- account_lockouts_id_column :: The id column in the account lockouts table, should be a foreign key referencing the accounts table.
12
- account_lockouts_deadline_column :: The deadline column in the account lockouts table, containing how long the account is locked out until.
13
- account_lockouts_deadline_interval :: The amount of time for which to lock out accounts, 1 day by default. Only used if set_deadline_values? is true.
14
- account_lockouts_email_last_sent_column :: The email last sent column in the account lockouts table. nil by default, so an unlock account email is always sent when requested by default.
15
- account_lockouts_key_column :: The unlock key column in the account lockouts table.
11
+ account_lockouts_deadline_column :: The deadline column in the +account_lockouts_table+, containing the timestamp until which the account is locked out.
12
+ account_lockouts_deadline_interval :: The amount of time for which to lock out accounts, 1 day by default. Only used if +set_deadline_values?+ is true.
13
+ account_lockouts_email_last_sent_column :: The email last sent column in the +account_lockouts_table+. Set to nil to always send an unlock account email when requested.
14
+ account_lockouts_id_column :: The id column in the +account_lockouts_table+, should be a foreign key referencing the accounts table.
15
+ account_lockouts_key_column :: The unlock key column in the +account_lockouts_table+.
16
16
  account_lockouts_table :: The table containing account lockout information.
17
- account_login_failures_id_column :: The id column in the account login failures table, should be a foreign key referencing the accounts table.
18
- account_login_failures_number_column :: The column in the account login failures table containing the number of login failures for the account.
17
+ account_login_failures_id_column :: The id column in the +account_login_failures_table+, should be a foreign key referencing the accounts table.
18
+ account_login_failures_number_column :: The column in the +account_login_failures_table+ containing the number of login failures for the account.
19
19
  account_login_failures_table :: The table containing number of login failures per account.
20
20
  login_lockout_error_flash :: The flash error to show if there if the account is or becomes locked out after a login attempt.
21
- max_invalid_logins :: The maximum number of failed logins before account lockout. As this feature is just designed for bruteforce protection, this is set to 100.
21
+ max_invalid_logins :: The maximum number of failed logins before account lockout. As this feature is just designed for bruteforce protection, this defaults to 100.
22
22
  no_matching_unlock_account_key_error_flash :: The flash error message to show if attempting to access the unlock account form with an invalid key.
23
23
  unlock_account_additional_form_tags :: HTML fragment with additional form tags to use on the unlock account form.
24
- unlock_account_autologin? :: Whether to autologin users after successful account unlock.
24
+ unlock_account_autologin? :: Whether to autologin users after successful account unlock. This defaults to true, as otherwise an attacker can prevent an account from logging in by continually locking out their account.
25
25
  unlock_account_button :: The text to use on the unlock account button.
26
26
  unlock_account_email_recently_sent_error_flash :: The flash error to show if not sending an unlock account email because another was sent recently.
27
27
  unlock_account_email_recently_sent_redirect :: Where to redirect after not sending an unlock account email because another was sent recently.
28
28
  unlock_account_email_subject :: The subject to use for the unlock account email.
29
- unlock_account_explanatory_text :: The text to display above the button to unlock an account.
30
29
  unlock_account_error_flash :: The flash error to display upon unsuccessful account unlock.
30
+ unlock_account_explanatory_text :: The text to display above the button to unlock an account.
31
31
  unlock_account_key_param :: The parameter name to use for the unlock account key.
32
32
  unlock_account_notice_flash :: The flash notice to display upon successful account unlock.
33
+ unlock_account_page_title :: The page title to use on the unlock account form.
33
34
  unlock_account_redirect :: Where to redirect after successful account unlock.
34
35
  unlock_account_request_additional_form_tags :: HTML fragment with additional form tags to use on the form to request an account unlock.
35
36
  unlock_account_request_button :: The text to use on the unlock account request button.
36
37
  unlock_account_request_explanatory_text :: The text to display above the button to request an account unlock.
37
38
  unlock_account_request_notice_flash :: The flash notice to display upon successful sending of the unlock account email.
38
- unlock_account_request_redirect :: Where to redirect after account unlock email is sent.
39
+ unlock_account_request_page_title :: The page title to use on the unlock account request form.
40
+ unlock_account_request_redirect :: Where to redirect after the account unlock email is sent.
39
41
  unlock_account_request_route :: The route to the unlock account request action. Defaults to +unlock-account-request+.
40
42
  unlock_account_requires_password? :: Whether a password is required when unlocking accounts, false by default. May want to set to true if not allowing password resets.
41
- unlock_account_route :: Alias for lockout_route.
43
+ unlock_account_route :: The route to the unlock account action. Defaults to +unlock-account+.
42
44
  unlock_account_session_key :: The key in the session to hold the unlock account key temporarily.
43
45
  unlock_account_skip_resend_email_within :: The number of seconds before sending another unlock account email, if +account_lockouts_email_last_sent_column+ is set.
44
46
 
@@ -55,15 +57,15 @@ before_unlock_account_route :: Run arbitrary code before handling an unlock acco
55
57
  clear_invalid_login_attempts :: Clear any stored login failures or lockouts for the current account.
56
58
  create_unlock_account_email :: A Mail::Message for the account unlock email to send.
57
59
  generate_unlock_account_key :: A random string to use for a new unlock account key.
58
- get_unlock_account_email_last_sent :: Get the last time an unlock_account email is sent, or nil if there is no last sent time.
60
+ get_unlock_account_email_last_sent :: Get the last time an unlock account email is sent, or nil if there is no last sent time.
59
61
  get_unlock_account_key :: Retrieve the unlock account key for the current account.
60
- invalid_login_attempt :: Record an invalid login attempt, incrementing the number of login failures, and possibly locking out the account.
62
+ invalid_login_attempted :: Record an invalid login attempt, incrementing the number of login failures, and possibly locking out the account.
61
63
  locked_out? :: Whether the current account is locked out.
62
64
  send_unlock_account_email :: Send the account unlock email.
63
65
  set_unlock_account_email_last_sent :: Set the last time an unlock_account email is sent.
66
+ unlock_account :: Unlock the account.
64
67
  unlock_account_email_body :: The body to use for the unlock account email.
65
68
  unlock_account_email_link :: The link to the unlock account form to include in the unlock account email.
66
- unlock_account :: Unlock the account.
67
69
  unlock_account_key :: The unlock account key for the current account.
68
70
  unlock_account_request_view :: The HTML to use for the unlock account request form.
69
71
  unlock_account_view :: The HTML to use for the unlock account form.
@@ -3,6 +3,13 @@
3
3
  The login feature implements a login page. It's the most commonly
4
4
  used feature.
5
5
 
6
+ In addition to the auth methods below, it provides a +login+ method that wraps
7
+ +login_session+, running login hooks and redirecting to the configured
8
+ location.
9
+
10
+ rodauth.account #=> { id: 123, ... }
11
+ rodauth.login('password') # login the current account
12
+
6
13
  == Auth Value Methods
7
14
 
8
15
  login_additional_form_tags :: HTML fragment containing additional form tags to use on the login form.
@@ -10,13 +17,21 @@ login_button :: The text to use for the login button.
10
17
  login_error_flash :: The flash error to show for an unsuccesful login.
11
18
  login_error_status :: The response status to use when using an invalid login or password to login, 401 by default.
12
19
  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.
20
+ 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.
21
+ login_form_footer_links_heading :: A heading to show before the login form footer links.
14
22
  login_notice_flash :: The flash notice to show after successful login.
23
+ login_page_title :: The page title to use on the login form.
15
24
  login_redirect :: Where to redirect after a sucessful login.
25
+ login_redirect_session_key :: The key in the session hash storing the location to redirect to after successful login.
26
+ 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
27
  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.
28
+ 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).
29
+ multi_phase_login_page_title :: The page title to use on the login form after login has been entered when using multi phase login.
30
+ need_password_notice_flash :: The flash notice to show during multi phase login after the login has been entered, when requesting the password.
31
+ 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
32
 
19
33
  == Auth Methods
20
34
 
21
35
  before_login_route :: Run arbitrary code before handling a login route.
22
36
  login_view :: The HTML to use for the login form.
37
+ 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,33 @@ 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.
12
+ login_email_regexp :: The regular expression used to validate whether login is a valid email address.
16
13
  login_maximum_length :: The maximum length for logins, 255 by default.
17
14
  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.
15
+ login_not_valid_email_message :: The error message to display when login is not a valid email address.
16
+ login_too_long_message :: The error message fragment to show if the login is too long.
17
+ login_too_short_message :: The error message fragment to show if the login is too short.
18
+ logins_do_not_match_message :: The error message to display when login and login confirmation do not match.
24
19
  password_confirm_label :: The label to use for password confirmations.
25
20
  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.
21
+ password_does_not_meet_requirements_message :: The error message to display when the password does not meet the requirements you have set.
29
22
  password_hash_cost :: The bcrypt cost to use for the password hash.
30
23
  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.
24
+ password_too_short_message :: The error message fragment to show if the password is too short.
25
+ passwords_do_not_match_message :: The error message to display when password and password confirmation do not match.
26
+ require_email_address_logins? :: Whether logins need to be valid email addresses, true by default.
27
+ require_login_confirmation? :: Whether login confirmations are required when changing logins or creating accounts. True by default if not verifying the account.
28
+ require_password_confirmation? :: Whether password confirmations are required when changing/resetting passwords and creating accounts.
29
+ same_as_existing_password_message :: The error message to display when a new password is the same as the existing password.
44
30
 
45
31
  == Auth Methods
46
32
 
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.
33
+ login_meets_requirements?(login) :: Whether the given login meets the requirements. By default, just checks that the login is a valid email address.
34
+ login_valid_email?(login) :: Whether the login is a valid email address.
53
35
  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
-
36
+ password_meets_requirements?(password) :: Whether the given password meets the requirements. Can be used to implement complexity requirements for passwords.
37
+ 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,18 +61,19 @@ 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.
68
73
  otp_disable_view :: The HTML to use for the OTP disable form.
69
74
  otp_exists? :: Whether the current account has setup OTP.
70
75
  otp_key :: The stored OTP secret for the account.
76
+ otp_last_use :: The last time OTP authentication was successful for the account.
71
77
  otp_locked_out? :: Whether the current account has been locked out of OTP authentication.
72
78
  otp_new_secret :: A new secret to use when setting up OTP.
73
79
  otp_provisioning_name :: The provisioning name to use during OTP setup, defaults to the account's email.
@@ -75,9 +81,9 @@ otp_provisioning_uri :: The provisioning URI displayed during OTP setup.
75
81
  otp_qr_code :: The QR code containing the otp_provisioning_uri, by default an SVG image.
76
82
  otp_record_authentication_failure :: Record an OTP authentication failure.
77
83
  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.
84
+ otp_remove_auth_failures :: Removes OTP authentication failures for the current account, used after successful multifactor authentication.
79
85
  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.
86
+ otp_tmp_key(secret) :: Set the secret to use for the temporary OTP key, during OTP setup.
81
87
  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
88
  otp_valid_code?(auth_code) :: Whether the given code is the currently valid OTP auth code for the account.
83
89
  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.