rodauth 1.21.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +182 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +211 -79
- data/doc/account_expiration.rdoc +12 -26
- data/doc/active_sessions.rdoc +49 -0
- data/doc/audit_logging.rdoc +44 -0
- data/doc/base.rdoc +75 -128
- data/doc/change_login.rdoc +7 -14
- data/doc/change_password.rdoc +9 -13
- data/doc/change_password_notify.rdoc +2 -2
- data/doc/close_account.rdoc +9 -16
- data/doc/confirm_password.rdoc +12 -5
- data/doc/create_account.rdoc +11 -22
- data/doc/disallow_password_reuse.rdoc +6 -13
- data/doc/email_auth.rdoc +15 -14
- data/doc/email_base.rdoc +6 -15
- data/doc/guides/admin_activation.rdoc +46 -0
- data/doc/guides/already_authenticated.rdoc +10 -0
- data/doc/guides/alternative_login.rdoc +46 -0
- data/doc/guides/create_account_programmatically.rdoc +38 -0
- data/doc/guides/delay_password.rdoc +25 -0
- data/doc/guides/email_only.rdoc +16 -0
- data/doc/guides/i18n.rdoc +26 -0
- data/doc/{internals.rdoc → guides/internals.rdoc} +0 -0
- data/doc/guides/links.rdoc +12 -0
- data/doc/guides/login_return.rdoc +37 -0
- data/doc/guides/password_column.rdoc +25 -0
- data/doc/guides/password_confirmation.rdoc +37 -0
- data/doc/guides/password_requirements.rdoc +30 -0
- data/doc/guides/paths.rdoc +36 -0
- data/doc/guides/query_params.rdoc +9 -0
- data/doc/guides/redirects.rdoc +17 -0
- data/doc/guides/registration_field.rdoc +68 -0
- data/doc/guides/require_mfa.rdoc +30 -0
- data/doc/guides/reset_password_autologin.rdoc +21 -0
- data/doc/guides/status_column.rdoc +28 -0
- data/doc/guides/totp_or_recovery.rdoc +16 -0
- data/doc/http_basic_auth.rdoc +10 -1
- data/doc/jwt.rdoc +22 -22
- data/doc/jwt_cors.rdoc +22 -0
- data/doc/jwt_refresh.rdoc +18 -8
- data/doc/lockout.rdoc +17 -15
- data/doc/login.rdoc +10 -2
- data/doc/login_password_requirements_base.rdoc +15 -37
- data/doc/logout.rdoc +2 -2
- data/doc/otp.rdoc +25 -19
- data/doc/password_complexity.rdoc +10 -26
- data/doc/password_expiration.rdoc +11 -25
- data/doc/password_grace_period.rdoc +16 -2
- data/doc/recovery_codes.rdoc +18 -12
- data/doc/release_notes/1.22.0.txt +11 -0
- data/doc/release_notes/1.23.0.txt +32 -0
- data/doc/release_notes/2.0.0.txt +361 -0
- data/doc/release_notes/2.1.0.txt +31 -0
- data/doc/release_notes/2.2.0.txt +39 -0
- data/doc/remember.rdoc +40 -64
- data/doc/reset_password.rdoc +12 -9
- data/doc/session_expiration.rdoc +1 -0
- data/doc/single_session.rdoc +16 -25
- data/doc/sms_codes.rdoc +24 -14
- data/doc/two_factor_base.rdoc +60 -22
- data/doc/verify_account.rdoc +14 -12
- data/doc/verify_account_grace_period.rdoc +6 -2
- data/doc/verify_login_change.rdoc +9 -8
- data/doc/webauthn.rdoc +115 -0
- data/doc/webauthn_login.rdoc +15 -0
- data/doc/webauthn_verify_account.rdoc +9 -0
- data/javascript/webauthn_auth.js +45 -0
- data/javascript/webauthn_setup.js +35 -0
- data/lib/roda/plugins/rodauth.rb +1 -1
- data/lib/rodauth.rb +36 -28
- data/lib/rodauth/features/account_expiration.rb +5 -5
- data/lib/rodauth/features/active_sessions.rb +158 -0
- data/lib/rodauth/features/audit_logging.rb +98 -0
- data/lib/rodauth/features/base.rb +144 -43
- data/lib/rodauth/features/change_password_notify.rb +2 -2
- data/lib/rodauth/features/confirm_password.rb +40 -2
- data/lib/rodauth/features/create_account.rb +8 -13
- data/lib/rodauth/features/disallow_common_passwords.rb +1 -1
- data/lib/rodauth/features/disallow_password_reuse.rb +1 -1
- data/lib/rodauth/features/email_auth.rb +31 -30
- data/lib/rodauth/features/email_base.rb +9 -4
- data/lib/rodauth/features/http_basic_auth.rb +55 -35
- data/lib/rodauth/features/jwt.rb +63 -16
- data/lib/rodauth/features/jwt_cors.rb +53 -0
- data/lib/rodauth/features/jwt_refresh.rb +32 -9
- data/lib/rodauth/features/lockout.rb +12 -14
- data/lib/rodauth/features/login.rb +54 -10
- data/lib/rodauth/features/login_password_requirements_base.rb +4 -4
- data/lib/rodauth/features/otp.rb +77 -80
- data/lib/rodauth/features/password_complexity.rb +8 -13
- data/lib/rodauth/features/password_expiration.rb +2 -2
- data/lib/rodauth/features/password_grace_period.rb +17 -10
- data/lib/rodauth/features/recovery_codes.rb +49 -53
- data/lib/rodauth/features/remember.rb +11 -27
- data/lib/rodauth/features/reset_password.rb +26 -26
- data/lib/rodauth/features/session_expiration.rb +6 -4
- data/lib/rodauth/features/single_session.rb +8 -6
- data/lib/rodauth/features/sms_codes.rb +62 -72
- data/lib/rodauth/features/two_factor_base.rb +134 -30
- data/lib/rodauth/features/verify_account.rb +29 -21
- data/lib/rodauth/features/verify_account_grace_period.rb +18 -9
- data/lib/rodauth/features/verify_login_change.rb +12 -11
- data/lib/rodauth/features/webauthn.rb +505 -0
- data/lib/rodauth/features/webauthn_login.rb +70 -0
- data/lib/rodauth/features/webauthn_verify_account.rb +46 -0
- data/lib/rodauth/version.rb +2 -2
- data/templates/button.str +1 -3
- data/templates/change-login.str +1 -2
- data/templates/change-password.str +3 -5
- data/templates/close-account.str +2 -2
- data/templates/confirm-password.str +1 -1
- data/templates/create-account.str +1 -1
- data/templates/email-auth-email.str +1 -1
- data/templates/email-auth-request-form.str +2 -3
- data/templates/email-auth.str +1 -1
- data/templates/global-logout-field.str +6 -0
- data/templates/login-confirm-field.str +2 -4
- data/templates/login-display.str +3 -2
- data/templates/login-field.str +2 -4
- data/templates/login-form-footer.str +6 -0
- data/templates/login-form.str +7 -0
- data/templates/login.str +1 -9
- data/templates/logout.str +1 -1
- data/templates/multi-phase-login.str +3 -0
- data/templates/otp-auth-code-field.str +5 -3
- data/templates/otp-auth.str +1 -1
- data/templates/otp-disable.str +1 -1
- data/templates/otp-setup.str +3 -3
- data/templates/password-confirm-field.str +2 -4
- data/templates/password-field.str +2 -4
- data/templates/recovery-auth.str +3 -6
- data/templates/recovery-codes.str +1 -1
- data/templates/remember.str +15 -20
- data/templates/reset-password-email.str +1 -1
- data/templates/reset-password-request.str +3 -3
- data/templates/reset-password.str +1 -2
- data/templates/sms-auth.str +1 -1
- data/templates/sms-code-field.str +5 -3
- data/templates/sms-confirm.str +1 -2
- data/templates/sms-disable.str +1 -2
- data/templates/sms-request.str +1 -1
- data/templates/sms-setup.str +6 -4
- data/templates/two-factor-auth.str +5 -0
- data/templates/two-factor-disable.str +6 -0
- data/templates/two-factor-manage.str +16 -0
- data/templates/unlock-account-email.str +1 -1
- data/templates/unlock-account-request.str +4 -4
- data/templates/unlock-account.str +1 -1
- data/templates/verify-account-email.str +1 -1
- data/templates/verify-account-resend.str +3 -3
- data/templates/verify-account.str +1 -2
- data/templates/verify-login-change-email.str +2 -1
- data/templates/verify-login-change.str +1 -1
- data/templates/webauthn-auth.str +11 -0
- data/templates/webauthn-remove.str +14 -0
- data/templates/webauthn-setup.str +12 -0
- metadata +110 -52
- data/Rakefile +0 -179
- data/doc/verify_change_login.rdoc +0 -11
- data/lib/rodauth/features/verify_change_login.rb +0 -20
- data/spec/account_expiration_spec.rb +0 -225
- data/spec/all.rb +0 -1
- data/spec/change_login_spec.rb +0 -156
- data/spec/change_password_notify_spec.rb +0 -33
- data/spec/change_password_spec.rb +0 -202
- data/spec/close_account_spec.rb +0 -162
- data/spec/confirm_password_spec.rb +0 -70
- data/spec/create_account_spec.rb +0 -127
- data/spec/disallow_common_passwords_spec.rb +0 -93
- data/spec/disallow_password_reuse_spec.rb +0 -179
- data/spec/email_auth_spec.rb +0 -285
- data/spec/http_basic_auth_spec.rb +0 -143
- data/spec/jwt_refresh_spec.rb +0 -256
- data/spec/jwt_spec.rb +0 -235
- data/spec/lockout_spec.rb +0 -250
- data/spec/login_spec.rb +0 -328
- data/spec/migrate/001_tables.rb +0 -184
- data/spec/migrate/002_account_password_hash_column.rb +0 -11
- data/spec/migrate_password/001_tables.rb +0 -73
- data/spec/migrate_travis/001_tables.rb +0 -141
- data/spec/password_complexity_spec.rb +0 -109
- data/spec/password_expiration_spec.rb +0 -244
- data/spec/password_grace_period_spec.rb +0 -93
- data/spec/remember_spec.rb +0 -451
- data/spec/reset_password_spec.rb +0 -229
- data/spec/rodauth_spec.rb +0 -343
- data/spec/session_expiration_spec.rb +0 -58
- data/spec/single_session_spec.rb +0 -127
- data/spec/spec_helper.rb +0 -327
- data/spec/two_factor_spec.rb +0 -1462
- data/spec/update_password_hash_spec.rb +0 -40
- data/spec/verify_account_grace_period_spec.rb +0 -171
- data/spec/verify_account_spec.rb +0 -240
- data/spec/verify_change_login_spec.rb +0 -46
- data/spec/verify_login_change_spec.rb +0 -232
- data/spec/views/layout-other.str +0 -11
- data/spec/views/layout.str +0 -11
- data/spec/views/login.str +0 -21
data/doc/close_account.rdoc
CHANGED
@@ -5,28 +5,21 @@ The close account feature allows users to close their accounts.
|
|
5
5
|
== Auth Value Methods
|
6
6
|
|
7
7
|
account_closed_status_value :: The integer representing closed accounts.
|
8
|
-
close_account_additional_form_tags :: HTML fragment containing additional
|
9
|
-
form tags to use on the close account
|
10
|
-
form.
|
8
|
+
close_account_additional_form_tags :: HTML fragment containing additional form tags to use on the close account form.
|
11
9
|
close_account_button :: The text to use for the close account button.
|
12
|
-
|
13
|
-
|
10
|
+
close_account_error_flash :: The flash error to show if there is an error closing the account.
|
11
|
+
close_account_notice_flash :: The flash notice to show after closing the account.
|
12
|
+
close_account_page_title :: The page title to use on the close account form.
|
14
13
|
close_account_redirect :: Where to redirect after closing the account.
|
15
|
-
close_account_requires_password? :: Whether a password is required when
|
16
|
-
|
17
|
-
|
18
|
-
+close-account+.
|
19
|
-
delete_account_on_close? :: Whether to delete the account when closing it,
|
20
|
-
default value is to use +skip_status_checks?+.
|
14
|
+
close_account_requires_password? :: Whether a password is required when closing accounts.
|
15
|
+
close_account_route :: The route to the close account action. Defaults to +close-account+.
|
16
|
+
delete_account_on_close? :: Whether to delete the account when closing it, default value is to use +skip_status_checks?+.
|
21
17
|
|
22
18
|
== Auth Methods
|
23
19
|
|
24
20
|
after_close_account :: Run arbitrary code after closing the account.
|
25
21
|
before_close_account :: Run arbitrary code before closing an account.
|
26
22
|
before_close_account_route :: Run arbitrary code before handling a close account route.
|
27
|
-
close_account :: Close the account, by default setting the account status
|
28
|
-
to closed.
|
23
|
+
close_account :: Close the account, by default setting the account status to closed.
|
29
24
|
close_account_view :: The HTML to use for the close account form.
|
30
|
-
delete_account :: If +delete_account_on_close?+ is true, delete the account
|
31
|
-
when closing it.
|
32
|
-
|
25
|
+
delete_account :: If +delete_account_on_close?+ is true, delete the account when closing it.
|
data/doc/confirm_password.rdoc
CHANGED
@@ -1,24 +1,31 @@
|
|
1
1
|
= Documentation for Confirm Password Feature
|
2
2
|
|
3
3
|
The confirm password feature allows you to redirect users to a page to
|
4
|
-
confirm their password.
|
5
|
-
|
4
|
+
confirm their password.
|
5
|
+
|
6
|
+
When confirming passwords, if authenticated via autologin, a remember token,
|
7
|
+
or an email_auth token, switches the authentication type from that login
|
8
|
+
method to password.
|
6
9
|
|
7
10
|
== Auth Value Methods
|
8
11
|
|
9
12
|
confirm_password_additional_form_tags :: HTML fragment containing additional form tags to use on the confirm password form.
|
10
13
|
confirm_password_button :: The text to use for the confirm password button.
|
11
14
|
confirm_password_error_flash :: The flash error to show if password confirmation is unsuccessful.
|
15
|
+
confirm_password_link_text :: The text to use for the link from the two factor auth page.
|
12
16
|
confirm_password_notice_flash :: The flash notice to show after password confirmed successful.
|
17
|
+
confirm_password_page_title :: The page title to use on the confirm password form.
|
13
18
|
confirm_password_redirect :: Where to redirect after successful password confirmation. By default, uses <tt>session[confirm_password_redirect_session_key]</tt> if set, allowing an easy way to redirect back to the page requesting password confirmation.
|
14
19
|
confirm_password_redirect_session_key :: The session key used to check for the confirm_password_redirect.
|
15
|
-
confirm_password_route :: The route to the confirm password form. Defaults to
|
16
|
-
|
20
|
+
confirm_password_route :: The route to the confirm password form. Defaults to +confirm-password+.
|
21
|
+
password_authentication_required_error_flash :: The flash error to show if going to a page requiring password confirmation.
|
22
|
+
password_authentication_required_error_status :: The response status to use if going to a page requiring password confirmation, 401 by default.
|
23
|
+
password_authentication_required_redirect :: Where to redirect when going to a page requiring password confirmation.
|
17
24
|
|
18
25
|
== Auth Methods
|
19
26
|
|
20
27
|
after_confirm_password :: Run arbitrary code after successful confirmation of password.
|
21
28
|
before_confirm_password :: Run arbitrary code before setting that the password has been confirmed.
|
22
|
-
confirm_password :: Run arbitrary code on correct password confirmation.
|
23
29
|
before_confirm_password_route :: Run arbitrary code before handling the password confirmation route.
|
30
|
+
confirm_password :: Update the session to reflect the password has been confirmed.
|
24
31
|
confirm_password_view :: The HTML to use for the confirm password form.
|
data/doc/create_account.rdoc
CHANGED
@@ -4,34 +4,23 @@ The create account feature allows users to create new accounts.
|
|
4
4
|
|
5
5
|
== Auth Value Methods
|
6
6
|
|
7
|
-
create_account_additional_form_tags :: HTML fragment containing additional
|
8
|
-
form tags to use on the create account
|
9
|
-
form.
|
7
|
+
create_account_additional_form_tags :: HTML fragment containing additional form tags to use on the create account form.
|
10
8
|
create_account_button :: The text to use for the create account button.
|
11
|
-
create_account_error_flash :: The flash error to show for unsuccessful
|
12
|
-
|
13
|
-
|
9
|
+
create_account_error_flash :: The flash error to show for unsuccessful account creation.
|
10
|
+
create_account_notice_flash :: The flash notice to show after successful account creation.
|
11
|
+
create_account_page_title :: The page title to use on the create account form.
|
14
12
|
create_account_redirect :: Where to redirect after creating the account.
|
15
|
-
create_account_route :: The route to the create account action. Defaults to
|
16
|
-
|
17
|
-
create_account_set_password? :: Whether to ask for a password to be set on the create
|
18
|
-
account form. Defaults to true. If set to false, an
|
19
|
-
alternative method to set the password should be used.
|
13
|
+
create_account_route :: The route to the create account action. Defaults to +create-account+.
|
14
|
+
create_account_set_password? :: Whether to ask for a password to be set on the create account form. Defaults to true if not verifying accounts. If set to false, an alternative method to set the password should be used (assuming you want to allow password authentication).
|
20
15
|
|
21
16
|
== Auth Methods
|
22
17
|
|
23
18
|
after_create_account :: Run arbitrary code after creating the account.
|
24
19
|
before_create_account :: Run arbitrary code before creating the account.
|
25
20
|
before_create_account_route :: Run arbitrary code before handling a create account route.
|
26
|
-
create_account_autologin? :: Whether to autologin the user upon
|
27
|
-
|
28
|
-
accounts.
|
29
|
-
create_account_link :: HTML fragment to display with a link to the create
|
30
|
-
account form.
|
21
|
+
create_account_autologin? :: Whether to autologin the user upon successful account creation, true by default unless verifying accounts.
|
22
|
+
create_account_link_text :: The text to use for a link to the create account form.
|
31
23
|
create_account_view :: The HTML to use for the create account form.
|
32
|
-
new_account(login) :: Instantiate a new account hash for the
|
33
|
-
|
34
|
-
|
35
|
-
was not successful.
|
36
|
-
set_new_account_password :: Set the password for a new account if
|
37
|
-
+account_password_hash_column+ is set, without saving.
|
24
|
+
new_account(login) :: Instantiate a new account hash for the given login, without saving it.
|
25
|
+
save_account :: Insert the account into the database, or return nil/false if that was not successful.
|
26
|
+
set_new_account_password :: Set the password for a new account if +account_password_hash_column+ is set, without saving.
|
@@ -17,21 +17,14 @@ current password.
|
|
17
17
|
|
18
18
|
== Auth Value Methods
|
19
19
|
|
20
|
-
password_same_as_previous_password_message :: The error message fragment to display if the
|
21
|
-
|
22
|
-
|
23
|
-
previous_password_account_id_column :: The column in the +previous_password_hash_table+ that
|
24
|
-
stores the account id.
|
25
|
-
previous_password_hash_column :: The column in the +previous_password_hash_table+ that
|
26
|
-
stores the password hash.
|
20
|
+
password_same_as_previous_password_message :: The error message fragment to display if the given password is the same as a previous password.
|
21
|
+
previous_password_account_id_column :: The column in the +previous_password_hash_table+ that stores the account id.
|
22
|
+
previous_password_hash_column :: The column in the +previous_password_hash_table+ that stores the password hash.
|
27
23
|
previous_password_hash_table :: The table storing previous password hashes.
|
28
|
-
previous_password_id_column :: The column in the +previous_password_hash_table+ that
|
29
|
-
stores the autoincrementing primary key.
|
24
|
+
previous_password_id_column :: The column in the +previous_password_hash_table+ that stores the autoincrementing primary key.
|
30
25
|
previous_passwords_to_check :: The number of previous password hashes to store and check.
|
31
26
|
|
32
27
|
== Auth Methods
|
33
28
|
|
34
|
-
add_previous_password_hash(hash) :: Add the given hash to the list of previous hashes for
|
35
|
-
|
36
|
-
password_doesnt_match_previous_password?(password) :: Whether the password given matches any
|
37
|
-
of the previous passwords.
|
29
|
+
add_previous_password_hash(hash) :: Add the given hash to the list of previous hashes for the current account.
|
30
|
+
password_doesnt_match_previous_password?(password) :: Whether the password given matches any of the previous passwords.
|
data/doc/email_auth.rdoc
CHANGED
@@ -1,34 +1,35 @@
|
|
1
1
|
= Documentation for Email Auth Feature
|
2
2
|
|
3
|
-
The email auth feature implements login using links sent via email. It is
|
4
|
-
|
5
|
-
a password, or even have a password to login.
|
3
|
+
The email auth feature implements passwordless login using links sent via email. It is
|
4
|
+
similar to the reset password feature, except you don't need to update
|
5
|
+
a password, or even have a password to login. It depends on the login and
|
6
6
|
email_base features.
|
7
7
|
|
8
8
|
== Auth Value Methods
|
9
9
|
|
10
10
|
email_auth_additional_form_tags :: HTML fragment containing additional form tags to use on the email auth login form.
|
11
|
+
email_auth_deadline_column :: The column name in the +email_auth_table+ storing the deadline after which the token will be ignored.
|
12
|
+
email_auth_deadline_interval :: The amount of time for which to allow users to use email auth keys, 1 day by default. Only used if set_deadline_values? is true.
|
13
|
+
email_auth_email_last_sent_column :: The email auth last sent column in the +email_auth_table+, storing the last time the email was sent. Set to nil to always send an email when requested.
|
11
14
|
email_auth_email_recently_sent_error_flash :: The flash error to show if not sending an email auth email because another was sent recently.
|
12
15
|
email_auth_email_recently_sent_redirect :: Where to redirect after not sending an email auth email because another was sent recently.
|
13
|
-
email_auth_deadline_column :: The column name in the email auth keys table storing the deadline after which the token will be ignored.
|
14
|
-
email_auth_deadline_interval :: The amount of time for which to allow users to reset their passwords, 1 day by default. Only used if set_deadline_values? is true.
|
15
16
|
email_auth_email_sent_notice_flash :: The flash notice to show after an email auth email has been sent.
|
16
17
|
email_auth_email_sent_redirect :: Where to redirect after sending an email auth email.
|
17
18
|
email_auth_email_subject :: The subject to use for email auth emails.
|
18
19
|
email_auth_error_flash :: The flash error to show if unable to login using email authentication.
|
19
|
-
email_auth_id_column :: The id column in the
|
20
|
-
email_auth_key_column :: The email auth key/token column in the
|
20
|
+
email_auth_id_column :: The id column in the +email_auth_table+, should be a foreign key referencing the accounts table.
|
21
|
+
email_auth_key_column :: The email auth key/token column in the +email_auth_table+.
|
21
22
|
email_auth_key_param :: The parameter name to use for the email auth key.
|
22
|
-
|
23
|
+
email_auth_page_title :: The page title to use on the email auth form.
|
23
24
|
email_auth_request_additional_form_tags :: HTML fragment containing additional form tags to use on the email auth request form.
|
24
25
|
email_auth_request_button :: The text to use for the email auth request button.
|
25
26
|
email_auth_request_error_flash :: The flash error to show if not able to send an email auth email.
|
26
27
|
email_auth_request_route :: The route to the email auth request action. Defaults to +email-auth-request+.
|
27
28
|
email_auth_route :: The route to the email auth action. Defaults to +email-auth+.
|
28
29
|
email_auth_session_key :: The key in the session to hold the email auth key temporarily.
|
29
|
-
|
30
|
-
email_auth_table :: The name of the email auth keys
|
31
|
-
force_email_auth? :: Whether email auth should be forced for the account.
|
30
|
+
email_auth_skip_resend_email_within :: The number of seconds required before sending another email auth email, 5 minutes by default.
|
31
|
+
email_auth_table :: The name of the table storing email auth keys.
|
32
|
+
force_email_auth? :: Whether email auth should be forced for the account. False by default, which results in email auth only be used automatically if the account does not have a password.
|
32
33
|
no_matching_email_auth_key_error_flash :: The flash error message to show if attempting to access the email auth form with an invalid key.
|
33
34
|
|
34
35
|
== Auth Methods
|
@@ -42,12 +43,12 @@ create_email_auth_email :: A Mail::Message for the email auth email.
|
|
42
43
|
create_email_auth_key :: Add the email auth key data to the database.
|
43
44
|
email_auth_email_body :: The body to use for the email auth email.
|
44
45
|
email_auth_email_link :: The link to the email auth form in the email auth email.
|
45
|
-
email_auth_key_insert_hash :: The hash to insert into the
|
46
|
+
email_auth_key_insert_hash :: The hash to insert into the +email_auth_table+.
|
46
47
|
email_auth_key_value :: The email auth key for the current account.
|
47
|
-
email_auth_request_form :: The HTML to use for a form to request an email auth email, shown on the login page after the user submits their login, if +force_email_auth?+ is false.
|
48
|
+
email_auth_request_form :: The HTML to use for a form to request an email auth email, shown on the login page after the user submits their login, if +force_email_auth?+ is false and email authentication is not the only possible for of authentication for the user.
|
48
49
|
email_auth_view :: The HTML to use for the email auth form.
|
49
|
-
get_email_auth_key(id) :: Get the email auth key for the given account id from the database.
|
50
50
|
get_email_auth_email_last_sent :: Get the last time an email auth email is sent, or nil if there is no last sent time.
|
51
|
+
get_email_auth_key(id) :: Get the email auth key for the given account id from the database.
|
51
52
|
remove_email_auth_key :: Remove the email auth key for the current account, run after successful email auth.
|
52
53
|
send_email_auth_email :: Send the email auth email.
|
53
54
|
set_email_auth_email_last_sent :: Set the last time an email auth email is sent. This is only called if there is a previous email auth token still active.
|
data/doc/email_base.rdoc
CHANGED
@@ -5,23 +5,14 @@ that requires sending emails.
|
|
5
5
|
|
6
6
|
== Auth Value Methods
|
7
7
|
|
8
|
-
allow_raw_email_token? :: When +
|
9
|
-
|
10
|
-
period from using raw tokens to using HMACed tokens. After the transition
|
11
|
-
period, this should not be set, as setting this to true removes the
|
12
|
-
security that HMACed tokens add.
|
13
|
-
default_post_email_redirect :: Where to redirect after sending an email. This is the default
|
14
|
-
redirect location for all redirects after an email is sent when the
|
15
|
-
account is not logged in. Also includes cases where an email is not
|
16
|
-
sent due to rate limiting.
|
8
|
+
allow_raw_email_token? :: When +hmac_secret+ is used, this allows the use of the raw token. This should only be set to true temporarily during a transition period from using raw tokens to using HMACed tokens. After the transition period, this should not be set, as setting this to true removes the security that HMACed tokens add.
|
9
|
+
default_post_email_redirect :: Where to redirect after sending an email. This is the default redirect location for all redirects after an email is sent when the account is not logged in. Also includes cases where an email is not sent due to rate limiting.
|
17
10
|
email_from :: The from address to use for emails sent by Rodauth.
|
18
11
|
email_subject_prefix :: The prefix to use for email subjects
|
19
|
-
require_mail? :: Set to false to not require mail, useful if using a different
|
20
|
-
library for sending email.
|
12
|
+
require_mail? :: Set to false to not require mail, useful if using a different library for sending email.
|
21
13
|
|
22
14
|
== Auth Methods
|
23
15
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
and body.
|
16
|
+
create_email(subject, body) :: Return a Mail::Message instance with the given subject and body.
|
17
|
+
email_to :: The email address to send emails to, by default the login of the current account.
|
18
|
+
send_email(email) :: Deliver a given Mail::Message instance.
|
@@ -0,0 +1,46 @@
|
|
1
|
+
= Require account verification by admin
|
2
|
+
|
3
|
+
There are scenarios in which, instead of allowing the user to verify they have
|
4
|
+
access to the email for the account, you may want to have an admin or moderator
|
5
|
+
approve new accounts manually. One way this can be achieved by sending the
|
6
|
+
account verification email to the admin:
|
7
|
+
|
8
|
+
plugin :rodauth do
|
9
|
+
enable :login, :logout, :verify_account, :reset_password
|
10
|
+
|
11
|
+
# Send account verification email to the admin
|
12
|
+
email_to do
|
13
|
+
if account[account_status_column] == account_unverified_status_value
|
14
|
+
"admin@myapp.com"
|
15
|
+
else
|
16
|
+
super()
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Do not ask for password when creating or verifying account
|
21
|
+
verify_account_set_password? false
|
22
|
+
create_account_set_password? false
|
23
|
+
|
24
|
+
# Adjust the account verification email subject and body
|
25
|
+
verify_account_email_subject "New User Awaiting Admin Approval"
|
26
|
+
verify_account_email_body do
|
27
|
+
"The user #{account[login_column]} has created an account. Click here to approve it: #{verify_account_email_link}."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Display this message to the user after they've created their account
|
31
|
+
verify_account_email_sent_notice_flash "Your account has been created and is awaiting approval"
|
32
|
+
|
33
|
+
# Prevent the admin from being logged in after confirming the account
|
34
|
+
verify_account_autologin? false
|
35
|
+
verify_account_notice_flash "The account has been approved"
|
36
|
+
|
37
|
+
# Send a reset password email after verifying the account.
|
38
|
+
# This allows the user to choose the password for the account,
|
39
|
+
# and also makes sure the user can only log in if they have
|
40
|
+
# access to the email address for the account.
|
41
|
+
after_verify_account do
|
42
|
+
generate_reset_password_key_value
|
43
|
+
create_reset_password_key
|
44
|
+
send_reset_password_email
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
= Skip login page if already authenticated
|
2
|
+
|
3
|
+
In some cases it may be useful to skip login/registration pages when the user
|
4
|
+
is already logged in. This can be achieved as follows. Note that this only
|
5
|
+
matters if the user manually navigates to the login or create account pages.
|
6
|
+
|
7
|
+
plugin :rodauth do
|
8
|
+
# Redirect logged in users to the wherever login redirects to
|
9
|
+
already_logged_in { redirect login_redirect }
|
10
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
= Use a non-email login
|
2
|
+
|
3
|
+
Rodauth's by default uses email addresses for identifying users, since that is
|
4
|
+
the most common form of identifier currently. In some cases, you might want
|
5
|
+
to allow logging in via alternative identifiers, such as a username. In this
|
6
|
+
case, it is best to choose a different column name for the login, such as
|
7
|
+
+:username+. Among other things, this also makes it so that the login field
|
8
|
+
does not expect an email address to be provided.
|
9
|
+
|
10
|
+
plugin :rodauth do
|
11
|
+
enable :login, :logout
|
12
|
+
login_column :username
|
13
|
+
end
|
14
|
+
|
15
|
+
Note that Rodauth features that require sending email need an email address, and
|
16
|
+
that defaults to the value of the login column. If you have both a username and
|
17
|
+
an email for an account, you can have the login column be the user, and use the
|
18
|
+
value of the email colummn for the email address.
|
19
|
+
|
20
|
+
plugin :rodauth do
|
21
|
+
enable :login, :logout, :reset_password
|
22
|
+
|
23
|
+
login_column :username
|
24
|
+
email_to do
|
25
|
+
account[:email]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
An alternative approach would be to accept a login and automatically change it
|
30
|
+
to an email address. If you have a +username+ field on the +accounts+ table,
|
31
|
+
then you can configure Rodauth to allow entering a username instead of email
|
32
|
+
during login. See the {Adding new registration field}[rdoc-ref:doc/guides/registration_field.rdoc]
|
33
|
+
guide for instructions on requiring add an additional field during registration.
|
34
|
+
|
35
|
+
plugin :rodauth do
|
36
|
+
enable :login, :logout
|
37
|
+
|
38
|
+
account_from_login do |login|
|
39
|
+
# handle the case when login parameter is a username
|
40
|
+
unless login.include?("@")
|
41
|
+
login = db[:accounts].where(username: login).get(:email)
|
42
|
+
end
|
43
|
+
|
44
|
+
super(login)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
= Create an account record programmatically
|
2
|
+
|
3
|
+
In some scenarios you might want to create an account records programmatically,
|
4
|
+
for example in your tests.
|
5
|
+
|
6
|
+
If you're storing passwords in a separate table, you can create an account
|
7
|
+
records as follows:
|
8
|
+
|
9
|
+
account_id = DB[:accounts].insert(
|
10
|
+
email: "name@example.com",
|
11
|
+
status_id: 2, # verified
|
12
|
+
)
|
13
|
+
|
14
|
+
DB[:account_password_hashes].insert(
|
15
|
+
id: account_id,
|
16
|
+
password_hash: BCrypt::Password.create("secret").to_s,
|
17
|
+
)
|
18
|
+
|
19
|
+
If the password is stored in a column in the accounts table:
|
20
|
+
|
21
|
+
account_id = DB[:accounts].insert(
|
22
|
+
email: "name@example.com",
|
23
|
+
password_hash: BCrypt::Password.create("secret").to_s,
|
24
|
+
status_id: 2, # verified
|
25
|
+
)
|
26
|
+
|
27
|
+
If you are creating accounts in your tests, you probably want to use
|
28
|
+
the +:cost+ option, otherwise you will have very slow tests:
|
29
|
+
|
30
|
+
account_id = DB[:accounts].insert(
|
31
|
+
email: "name@example.com",
|
32
|
+
status_id: 2, # verified
|
33
|
+
)
|
34
|
+
|
35
|
+
DB[:account_password_hashes].insert(
|
36
|
+
id: account_id,
|
37
|
+
password_hash: BCrypt::Password.create("secret", cost: BCrypt::Engine::MIN_COST).to_s,
|
38
|
+
)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
= Set password when verifying account
|
2
|
+
|
3
|
+
If you want to request less information from the user on registration, you can
|
4
|
+
ask the user to set their password only when they verify their account:
|
5
|
+
|
6
|
+
plugin :rodauth do
|
7
|
+
enable :login, :logout, :verify_account
|
8
|
+
verify_account_set_password? true
|
9
|
+
end
|
10
|
+
|
11
|
+
Note that this is already the default behaviour when verify account feature is
|
12
|
+
loaded, but it's not when verify account grace period is used, because it would
|
13
|
+
prevent the account from logging in during the grace period. You can work around
|
14
|
+
this by automatically remebering their login during account creation using the
|
15
|
+
remember feature. Be aware that remembering accounts has effects beyond the
|
16
|
+
verification period, and this would only allow automatic logins from the browser
|
17
|
+
that created the account.
|
18
|
+
|
19
|
+
plugin :rodauth do
|
20
|
+
enable :login, :logout, :verify_account_grace_period, :remember
|
21
|
+
verify_account_set_password? true
|
22
|
+
after_create_account do
|
23
|
+
remember_login
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
= Allow only email authentication
|
2
|
+
|
3
|
+
When using the email authentication feature, you can avoid other authentication
|
4
|
+
mechanisms entirely as follows:
|
5
|
+
|
6
|
+
plugin :rodauth do
|
7
|
+
enable :login, :email_auth, :create_account, :verify_account
|
8
|
+
|
9
|
+
create_account_set_password? false
|
10
|
+
verify_account_set_password? false
|
11
|
+
force_email_auth? true
|
12
|
+
end
|
13
|
+
|
14
|
+
With this configuration, users won't be required to enter a password on
|
15
|
+
registration, and on login the email authentication link will automatically be
|
16
|
+
sent after the email address is entered.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
= Translate with i18n gem
|
2
|
+
|
3
|
+
Rodauth allows transforming user-facing text configuration such as flash
|
4
|
+
messages, validation errors, labels etc. via the +translate+ configuration
|
5
|
+
method. This method receives a name of a configuration along with its default
|
6
|
+
value, and is expected to return the result text.
|
7
|
+
|
8
|
+
You can use this to perform translations using the
|
9
|
+
{i18n gem}[https://github.com/ruby-i18n/i18n]:
|
10
|
+
|
11
|
+
plugin :rodauth do
|
12
|
+
enable :login, :logout, :reset_password
|
13
|
+
|
14
|
+
translate do |key, default|
|
15
|
+
I18n.translate("rodauth.#{key}") || default
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Your translation file may then look something like this:
|
20
|
+
|
21
|
+
en:
|
22
|
+
rodauth:
|
23
|
+
login_notice_flash: "You have been signed in"
|
24
|
+
require_login_error_flash: "Login is required for accessing this page"
|
25
|
+
no_matching_login_message: "user with this email address doesn't exist"
|
26
|
+
reset_password_email_subject: "Password Reset Instructions"
|