rodauth 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/README.rdoc +61 -15
- data/doc/change_login.rdoc +2 -1
- data/doc/change_password.rdoc +2 -1
- data/doc/close_account.rdoc +2 -1
- data/doc/confirm_password.rdoc +2 -1
- data/doc/create_account.rdoc +2 -2
- data/doc/lockout.rdoc +1 -0
- data/doc/login.rdoc +1 -1
- data/doc/logout.rdoc +1 -1
- data/doc/otp.rdoc +3 -3
- data/doc/recovery_codes.rdoc +7 -1
- data/doc/release_notes/1.9.0.txt +15 -0
- data/doc/remember.rdoc +2 -1
- data/doc/reset_password.rdoc +3 -1
- data/doc/sms_codes.rdoc +5 -5
- data/doc/verify_account.rdoc +3 -1
- data/lib/rodauth.rb +22 -0
- data/lib/rodauth/features/base.rb +21 -4
- data/lib/rodauth/features/change_login.rb +1 -0
- data/lib/rodauth/features/change_password.rb +1 -0
- data/lib/rodauth/features/close_account.rb +1 -0
- data/lib/rodauth/features/confirm_password.rb +1 -0
- data/lib/rodauth/features/create_account.rb +1 -0
- data/lib/rodauth/features/lockout.rb +1 -0
- data/lib/rodauth/features/login.rb +1 -0
- data/lib/rodauth/features/logout.rb +1 -0
- data/lib/rodauth/features/otp.rb +1 -0
- data/lib/rodauth/features/recovery_codes.rb +1 -0
- data/lib/rodauth/features/remember.rb +1 -0
- data/lib/rodauth/features/reset_password.rb +3 -0
- data/lib/rodauth/features/sms_codes.rb +1 -0
- data/lib/rodauth/features/verify_account.rb +1 -0
- data/lib/rodauth/version.rb +1 -1
- data/spec/login_spec.rb +1 -1
- data/spec/password_expiration_spec.rb +1 -1
- data/spec/reset_password_spec.rb +4 -0
- data/spec/rodauth_spec.rb +13 -0
- data/spec/spec_helper.rb +6 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63d284b3ed1dc87ff182d472e730e52d823e4dae
|
4
|
+
data.tar.gz: 47599804ed740325e00c8c7bda5dcafde8b669c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4f64fc7c93e5a97c4ef7a100d26dcb286b157a7085c939db4bdce203b3b63f18e239f71ea09cc4881740facacc695c00a220427e91f9daea0aec7f1e65a51d3
|
7
|
+
data.tar.gz: 3424177852d8cbf98f1acca6f75c46e23316664950febab7af6af720a55038570fe6d4655d4dc983e0ee29df70ad011a7cff468b5f0169604c3baed09da1e94f
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 1.9.0 (2017-02-22)
|
2
|
+
|
3
|
+
* Make reset-password use existing password reset key if one is present (jeremyevans) (#26)
|
4
|
+
|
5
|
+
* Add Roda.precompile_rodauth_templates method, useful to save memory when forking, or when chrooting (jeremyevans)
|
6
|
+
|
1
7
|
=== 1.8.0 (2017-01-06)
|
2
8
|
|
3
9
|
* Add json_response_custom_error_status? option to jwt feature to use specific 4xx statuses instead of 400 (jeremyevans)
|
data/README.rdoc
CHANGED
@@ -757,12 +757,21 @@ Conversely, if you implement the rodauth_get_salt and
|
|
757
757
|
rodauth_valid_password_hash functions on a database that isn't
|
758
758
|
PostgreSQL, MySQL, or Microsoft SQL Server, you can set this value to true.
|
759
759
|
|
760
|
-
=== With Custom Authentication
|
760
|
+
=== With Custom Authentication
|
761
761
|
|
762
|
-
You can use Rodauth with other authentication types, by
|
763
|
-
|
764
|
-
|
765
|
-
|
762
|
+
You can use Rodauth with other authentication types, by using some
|
763
|
+
of Rodauth's configuration methods.
|
764
|
+
|
765
|
+
Note that when using custom authentication, using some of Rodauth's
|
766
|
+
features such as change login and change password either would not
|
767
|
+
make sense or would require some additional custom configuration.
|
768
|
+
The login and logout features should work correctly with the examples
|
769
|
+
below, though.
|
770
|
+
|
771
|
+
==== Using LDAP Authentication
|
772
|
+
|
773
|
+
If you have accounts stored in the database, but authentication happens
|
774
|
+
via LDAP, you can use the +simple_ldap_authenticator+ library:
|
766
775
|
|
767
776
|
require 'simple_ldap_authenticator'
|
768
777
|
plugin :rodauth do
|
@@ -783,26 +792,51 @@ any valid LDAP user to login, you can do something like this:
|
|
783
792
|
# Don't require the bcrypt library, since using LDAP for auth
|
784
793
|
require_bcrypt? false
|
785
794
|
|
786
|
-
#
|
787
|
-
|
795
|
+
# Store session value in :login key, since the :account_id
|
796
|
+
# default wouldn't make sense
|
797
|
+
session_key :login
|
788
798
|
|
789
799
|
# Use the login provided as the session value
|
790
800
|
account_session_value{account}
|
791
801
|
|
792
|
-
#
|
793
|
-
|
794
|
-
session_key :login
|
802
|
+
# Treat the login itself as the account
|
803
|
+
account_from_login{|l| l.to_s}
|
795
804
|
|
796
805
|
password_match? do |password|
|
797
806
|
SimpleLdapAuthenticator.valid?(account, password)
|
798
807
|
end
|
799
808
|
end
|
800
809
|
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
810
|
+
==== Using Facebook Authentication
|
811
|
+
|
812
|
+
Here's an example of authentication using Facebook with a JSON API.
|
813
|
+
This setup assumes you have client-side code to submit JSON POST requests
|
814
|
+
to +/login+ with an +access_token+ parameter that is set to the user's
|
815
|
+
Facebook OAuth access token.
|
816
|
+
|
817
|
+
|
818
|
+
require 'koala'
|
819
|
+
plugin :rodauth do
|
820
|
+
enable :login, :logout, :jwt
|
821
|
+
|
822
|
+
require_bcrypt? false
|
823
|
+
session_key :facebook_email
|
824
|
+
account_session_value{account}
|
825
|
+
|
826
|
+
login_param 'access_token'
|
827
|
+
|
828
|
+
account_from_login do |access_token|
|
829
|
+
fb = Koala::Facebook::API.new(access_token)
|
830
|
+
if me = fb.get_object('me', :fields=>[:email])
|
831
|
+
me['email']
|
832
|
+
end
|
833
|
+
end
|
834
|
+
|
835
|
+
# there is no password!
|
836
|
+
password_match? do |pass|
|
837
|
+
true
|
838
|
+
end
|
839
|
+
end
|
806
840
|
|
807
841
|
=== With Other Web Frameworks
|
808
842
|
|
@@ -1008,6 +1042,18 @@ by adding an appropriate route before calling +r.rodauth+:
|
|
1008
1042
|
r.rodauth
|
1009
1043
|
end
|
1010
1044
|
|
1045
|
+
=== Precompiling Rodauth Templates
|
1046
|
+
|
1047
|
+
Rodauth serves templates from it's gem folder. If you are using
|
1048
|
+
a forking webserver and want to preload the compiled templates
|
1049
|
+
to save memory, or if you are chrooting your application, you can
|
1050
|
+
benefit from precompiling your rodauth templates:
|
1051
|
+
|
1052
|
+
plugin :rodauth do
|
1053
|
+
# ...
|
1054
|
+
end
|
1055
|
+
precompile_rodauth_templates
|
1056
|
+
|
1011
1057
|
== Upgrading from 0.9.x
|
1012
1058
|
|
1013
1059
|
To upgrade from 0.9.x to the current version, if you were using
|
data/doc/change_login.rdoc
CHANGED
@@ -16,7 +16,8 @@ change_login_notice_flash :: The flash notice to show after a successful
|
|
16
16
|
change_login_redirect :: Where to redirect after a sucessful login change.
|
17
17
|
change_login_requires_password? :: Whether a password is required when
|
18
18
|
changing logins.
|
19
|
-
change_login_route :: The route to the change login action.
|
19
|
+
change_login_route :: The route to the change login action. Defaults to
|
20
|
+
+change-login+.
|
20
21
|
|
21
22
|
== Auth Methods
|
22
23
|
|
data/doc/change_password.rdoc
CHANGED
@@ -16,7 +16,8 @@ change_password_notice_flash :: The flash notice to show after a successful
|
|
16
16
|
change_password_redirect :: Where to redirect after a sucessful password change.
|
17
17
|
change_password_requires_password? :: Whether a password is required when
|
18
18
|
changing passwords.
|
19
|
-
change_password_route :: The route to the change password action.
|
19
|
+
change_password_route :: The route to the change password action. Defaults to
|
20
|
+
+change-password+.
|
20
21
|
|
21
22
|
== Auth Methods
|
22
23
|
|
data/doc/close_account.rdoc
CHANGED
@@ -14,7 +14,8 @@ close_account_notice_flash :: The flash notice to show after closing the
|
|
14
14
|
close_account_redirect :: Where to redirect after closing the account.
|
15
15
|
close_account_requires_password? :: Whether a password is required when
|
16
16
|
closing accounts.
|
17
|
-
close_account_route :: The route to the close account action.
|
17
|
+
close_account_route :: The route to the close account action. Defaults to
|
18
|
+
+close-account+.
|
18
19
|
delete_account_on_close? :: Whether to delete the account when closing it,
|
19
20
|
default value is to use +skip_status_checks?+.
|
20
21
|
|
data/doc/confirm_password.rdoc
CHANGED
@@ -11,7 +11,8 @@ confirm_password_button :: The text to use for the confirm password button.
|
|
11
11
|
confirm_password_error_flash :: The flash error to show if password confirmation is unsuccessful.
|
12
12
|
confirm_password_notice_flash :: The flash notice to show after password confirmed successful.
|
13
13
|
confirm_password_redirect :: Where to redirect after successful password confirmation. By default, uses <tt>session[:confirm_password_redirect]</tt> if set, allowing an easy way to redirect back to the page requesting password confirmation.
|
14
|
-
confirm_password_route :: The route to the confirm password form.
|
14
|
+
confirm_password_route :: The route to the confirm password form. Defaults to
|
15
|
+
+confirm-password+.
|
15
16
|
|
16
17
|
== Auth Methods
|
17
18
|
|
data/doc/create_account.rdoc
CHANGED
@@ -12,8 +12,8 @@ create_account_error_flash :: The flash error to show for unsuccessful
|
|
12
12
|
account creation.
|
13
13
|
create_account_notice_flash :: The flash notice to show after successful
|
14
14
|
create_account_redirect :: Where to redirect after creating the account.
|
15
|
-
create_account_route :: The route to the create account action.
|
16
|
-
account
|
15
|
+
create_account_route :: The route to the create account action. Defaults to
|
16
|
+
+create-account+.
|
17
17
|
|
18
18
|
== Auth Methods
|
19
19
|
|
data/doc/lockout.rdoc
CHANGED
@@ -47,6 +47,7 @@ unlock_account_request_notice_flash :: The flash notice to display upon successf
|
|
47
47
|
the unlock account email.
|
48
48
|
unlock_account_request_redirect :: Where to redirect after account unlock email is sent.
|
49
49
|
unlock_account_request_route :: The route to the unlock account request action.
|
50
|
+
Defaults to +unlock-account-request+.
|
50
51
|
unlock_account_requires_password? :: Whether a password is required when unlocking accounts,
|
51
52
|
false by default. May want to set to true if not
|
52
53
|
allowing password resets.
|
data/doc/login.rdoc
CHANGED
@@ -14,7 +14,7 @@ login_error_status :: The response status to use when using an invalid
|
|
14
14
|
login_form_footer :: A message to display after the login form.
|
15
15
|
login_notice_flash :: The flash notice to show after successful login.
|
16
16
|
login_redirect :: Where to redirect after a sucessful login.
|
17
|
-
login_route :: The route to the login action.
|
17
|
+
login_route :: The route to the login action. Defaults to +login+.
|
18
18
|
|
19
19
|
== Auth Methods
|
20
20
|
|
data/doc/logout.rdoc
CHANGED
@@ -10,7 +10,7 @@ logout_additional_form_tags :: HTML fragment containing additional form
|
|
10
10
|
logout_button :: The text to use for the logout button.
|
11
11
|
logout_notice_flash :: The flash notice to show after logout.
|
12
12
|
logout_redirect :: Where to redirect after a logout.
|
13
|
-
logout_route :: The route to the logout action.
|
13
|
+
logout_route :: The route to the logout action. Defaults to +logout+.
|
14
14
|
|
15
15
|
== Auth Methods
|
16
16
|
|
data/doc/otp.rdoc
CHANGED
@@ -21,7 +21,7 @@ otp_auth_failures_limit :: The number of allowed OTP authentication failures bef
|
|
21
21
|
otp_auth_form_footer :: A footer to display at the bottom of the OTP authentication form.
|
22
22
|
otp_auth_label :: The label for the OTP authentication code.
|
23
23
|
otp_auth_param :: The parameter name for the OTP authentication code.
|
24
|
-
otp_auth_route :: The route to the OTP authentication action.
|
24
|
+
otp_auth_route :: The route to the OTP authentication action. Defaults to +otp-auth+.
|
25
25
|
otp_class :: The class to use for OTP authentication (default: ROTP::TOTP)
|
26
26
|
otp_digits :: The number of digits to use in OTP authentication codes (rotp's default is 6).
|
27
27
|
otp_disable_additional_form_tags :: HTML fragment containing additional form tags to use on
|
@@ -30,7 +30,7 @@ otp_disable_button :: The text to use for button on form to disable OTP authenti
|
|
30
30
|
otp_disable_error_flash :: The flash error to show if unable to disable OTP authentication.
|
31
31
|
otp_disable_notice_flash :: The flash notice to show after disabling OTP authentication.
|
32
32
|
otp_disable_redirect :: Where to redirect after disabling OTP authentication.
|
33
|
-
otp_disable_route :: The route to the OTP disable action.
|
33
|
+
otp_disable_route :: The route to the OTP disable action. Defaults to +otp-disable+.
|
34
34
|
otp_drift :: The number of seconds the client and server are allowed to drift apart. The
|
35
35
|
default is nil, to not allow drift.
|
36
36
|
otp_invalid_auth_code_message :: The error message to show when an invalid OTP authentication
|
@@ -61,7 +61,7 @@ otp_setup_error_flash :: The flash error to show if OTP authentication setup was
|
|
61
61
|
otp_setup_notice_flash :: The flash notice to show if OTP authentication setup was successful.
|
62
62
|
otp_setup_param :: The parameter name used for the OTP secret when setting up OTP authentication.
|
63
63
|
otp_setup_redirect :: Where to redirect after sucessful OTP authentication setup.
|
64
|
-
otp_setup_route :: The route to the OTP setup action.
|
64
|
+
otp_setup_route :: The route to the OTP setup action. Defaults to +otp-setup+.
|
65
65
|
|
66
66
|
== Auth Methods
|
67
67
|
|
data/doc/recovery_codes.rdoc
CHANGED
@@ -5,6 +5,10 @@ codes. It is usually used as a backup if OTP authentication is not available or
|
|
5
5
|
has been locked out, but can be used by itself or as a backup to SMS codes. It allows
|
6
6
|
users to view authentication recovery codes as well as regenerate recovery codes.
|
7
7
|
|
8
|
+
Access to recovery codes is limited to authenticated sessions only, so users should
|
9
|
+
be recommended to securely store/preserve a subset of these codes prior to any chance
|
10
|
+
of them being required due to a missing / lost device.
|
11
|
+
|
8
12
|
== Auth Value Methods
|
9
13
|
|
10
14
|
add_recovery_codes_button :: Text to use for button on form to add recovery codes.
|
@@ -21,6 +25,7 @@ recovery_auth_additional_form_tags :: HTML fragment containing additional form t
|
|
21
25
|
recovery_auth_button :: The text to use for the button when authenticating via a recovery code.
|
22
26
|
recovery_auth_redirect :: Where to redirect after authenticating via an recovery code.
|
23
27
|
recovery_auth_route :: The route to the recovery code authentication action.
|
28
|
+
Defaults to +recovery-auth+.
|
24
29
|
recovery_codes_added_notice_flash :: The flash notice to show when recovery codes
|
25
30
|
were added.
|
26
31
|
recovery_codes_additional_form_tags :: HTML fragment containing additional form tags when
|
@@ -34,7 +39,8 @@ recovery_codes_limit :: The number of recovery codes to allow.
|
|
34
39
|
recovery_codes_param :: The parameter name for the recovery code.
|
35
40
|
recovery_codes_primary? :: Whether recovery codes are the primary second factor, true by
|
36
41
|
default if neither the otp or sms_codes features are enabled.
|
37
|
-
recovery_codes_route :: The route to the view recovery codes action.
|
42
|
+
recovery_codes_route :: The route to the view recovery codes action. Defaults to
|
43
|
+
+recovery-codes+.
|
38
44
|
recovery_codes_table :: The table storing the recovery codes.
|
39
45
|
view_recovery_codes_button :: Text for the button to view recovery codes.
|
40
46
|
view_recovery_codes_error_flash :: The flash error to show when viewing recovery codes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* Roda.precompile_rodauth_templates has been added. This method
|
4
|
+
allows for precompiling the templates that rodauth uses, which
|
5
|
+
allows for memory saving when using a forking webserver that
|
6
|
+
preloads the application, and also allows Rodauth to be used
|
7
|
+
with an application that uses chroot after loading.
|
8
|
+
|
9
|
+
= Improvements
|
10
|
+
|
11
|
+
* If requesting a password reset link more than once, the same
|
12
|
+
password reset key will be used. Previously, subsequent
|
13
|
+
emails after the first request would contain an invalid key,
|
14
|
+
so if the email for the original request was lost, you could
|
15
|
+
not generate another key until that key expired.
|
data/doc/remember.rdoc
CHANGED
@@ -37,7 +37,8 @@ remember_period :: The additional time to extend the remember deadline if
|
|
37
37
|
remember_redirect :: Where to redirect after changing the remember settings.
|
38
38
|
remember_remember_param_value :: The parameter value for switching on remembering.
|
39
39
|
remember_remember_label :: The label for turning on remembering.
|
40
|
-
remember_route :: The route to the change remember settings action.
|
40
|
+
remember_route :: The route to the change remember settings action. Defaults to
|
41
|
+
+remember+.
|
41
42
|
remember_table :: The name of the remember keys table.
|
42
43
|
remember_param :: The parameter name to use for the remember password settings
|
43
44
|
choice.
|
data/doc/reset_password.rdoc
CHANGED
@@ -39,7 +39,9 @@ reset_password_request_button :: The text to use for the reset password request
|
|
39
39
|
reset_password_request_error_flash :: The flash error to show if not able to send a reset
|
40
40
|
password email.
|
41
41
|
reset_password_request_route :: The route to the reset password request action.
|
42
|
-
|
42
|
+
Defaults to +reset-password-request+.
|
43
|
+
reset_password_route :: The route to the reset password action. Defaults to
|
44
|
+
+reset-password+.
|
43
45
|
reset_password_session_key :: The key in the session to hold the reset password key temporarily.
|
44
46
|
reset_password_table :: The name of the reset password keys table.
|
45
47
|
|
data/doc/sms_codes.rdoc
CHANGED
@@ -28,7 +28,7 @@ sms_auth_additional_form_tags :: HTML fragment containing additional form tags w
|
|
28
28
|
sms_auth_button :: Text to use for button on form to authenticate via SMS.
|
29
29
|
sms_auth_code_length :: The length of SMS authentication codes, 6 by default.
|
30
30
|
sms_auth_redirect :: Where to redirect if SMS authentication is needed.
|
31
|
-
sms_auth_route :: The route to the SMS authentication action.
|
31
|
+
sms_auth_route :: The route to the SMS authentication action. Defaults to +sms-auth+.
|
32
32
|
sms_code_allowed_seconds :: The number of seconds after an SMS authentication is sent until it is no longer valid, 300 seconds by default.
|
33
33
|
sms_code_column :: The column in the +sms_codes_table+ containing the currently valid SMS authentication/confirmation code.
|
34
34
|
sms_code_label :: The label for SMS codes.
|
@@ -40,13 +40,13 @@ sms_confirm_button :: Text to use for button on form to confirm SMS setup.
|
|
40
40
|
sms_confirm_code_length :: The length of SMS confirmation codes, 12 by default, as there is no lockout.
|
41
41
|
sms_confirm_notice_flash :: The flash notice to show when SMS authentication setup has been confirmed.
|
42
42
|
sms_confirm_redirect ::Where to redirect after SMS authentication setup has been confirmed.
|
43
|
-
sms_confirm_route :: The route to the SMS setup confirmation action.
|
43
|
+
sms_confirm_route :: The route to the SMS setup confirmation action. Defaults to +sms-confirm+.
|
44
44
|
sms_disable_additional_form_tags :: HTML fragment containing additional form tags when disabling SMS authentication.
|
45
45
|
sms_disable_button :: Text to use for button on form to disable SMS authentication.
|
46
46
|
sms_disable_error_flash :: The flash error to show when disabling SMS authentication fails.
|
47
47
|
sms_disable_notice_flash :: The flash notice to show when SMS authentication has been successfully disabled.
|
48
48
|
sms_disable_redirect :: Where to redirect after SMS authentication has been disabled.
|
49
|
-
sms_disable_route :: The route to the SMS authentication disable action.
|
49
|
+
sms_disable_route :: The route to the SMS authentication disable action. Defaults to +sms-disable+.
|
50
50
|
sms_failure_limit :: The number of failures until SMS authentication is locked out.
|
51
51
|
sms_failures_column :: The column in the +sms_codes_table+ containing the number of SMS authentication failures since the last successful authentication.
|
52
52
|
sms_id_column :: The column in the +sms_codes_table+ containing the account id.
|
@@ -70,11 +70,11 @@ sms_request_additional_form_tags :: HTML fragment containing additional form tag
|
|
70
70
|
sms_request_button :: Text to use for button on form to request an SMS authentication code.
|
71
71
|
sms_request_notice_flash :: The flash notice to show when an SMS authentication code is requested.
|
72
72
|
sms_request_redirect :: Where to redirect after requesting an SMS authentication code.
|
73
|
-
sms_request_route :: The route to the SMS authentication code request action.
|
73
|
+
sms_request_route :: The route to the SMS authentication code request action. Defaults to +sms-request+.
|
74
74
|
sms_setup_additional_form_tags :: HTML fragment containing additional form tags when setting up SMS authentication.
|
75
75
|
sms_setup_button :: Text to use for button on form to setup SMS authentication.
|
76
76
|
sms_setup_error_flash :: The flash error to show when setting up SMS authentication fails.
|
77
|
-
sms_setup_route :: The route to the SMS authentication setup action.
|
77
|
+
sms_setup_route :: The route to the SMS authentication setup action. Defaults to +sms-setup+.
|
78
78
|
|
79
79
|
== Auth Methods
|
80
80
|
|
data/doc/verify_account.rdoc
CHANGED
@@ -39,7 +39,9 @@ verify_account_redirect :: Where to redirect after verifying the account.
|
|
39
39
|
verify_account_resend_error_flash :: The flash error to show if unable to resend a
|
40
40
|
verify account email.
|
41
41
|
verify_account_resend_route :: The route to the verify account resend action.
|
42
|
-
|
42
|
+
Defaults to +verify-account-resend+.
|
43
|
+
verify_account_route :: The route to the verify account action. Defaults to
|
44
|
+
+verify-account+.
|
43
45
|
verify_account_session_key :: The key in the session to hold the verify account key temporarily.
|
44
46
|
verify_account_table :: The name of the verify account keys table.
|
45
47
|
|
data/lib/rodauth.rb
CHANGED
@@ -128,6 +128,12 @@ module Rodauth
|
|
128
128
|
auth_methods meth
|
129
129
|
end
|
130
130
|
|
131
|
+
def loaded_templates(v)
|
132
|
+
define_method(:loaded_templates) do
|
133
|
+
super().concat(v)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
131
137
|
def depends(*deps)
|
132
138
|
dependencies.concat(deps)
|
133
139
|
end
|
@@ -244,6 +250,22 @@ module Rodauth
|
|
244
250
|
opts[:rodauths][name]
|
245
251
|
end
|
246
252
|
|
253
|
+
def precompile_rodauth_templates
|
254
|
+
instance = allocate
|
255
|
+
rodauth = instance.rodauth
|
256
|
+
|
257
|
+
view_opts = rodauth.send(:loaded_templates).map do |page|
|
258
|
+
rodauth.send(:_view_opts, page)
|
259
|
+
end
|
260
|
+
view_opts << rodauth.send(:button_opts, '', {})
|
261
|
+
|
262
|
+
view_opts.each do |opts|
|
263
|
+
instance.send(:retrieve_template, opts).send(:compiled_method, opts[:locals].keys.sort_by(&:to_s))
|
264
|
+
end
|
265
|
+
|
266
|
+
nil
|
267
|
+
end
|
268
|
+
|
247
269
|
def freeze
|
248
270
|
if opts[:rodauths]
|
249
271
|
opts[:rodauths].each_value(&:freeze)
|
@@ -232,10 +232,16 @@ module Rodauth
|
|
232
232
|
scope.csrf_tag if scope.respond_to?(:csrf_tag)
|
233
233
|
end
|
234
234
|
|
235
|
-
def
|
235
|
+
def button_opts(value, opts)
|
236
236
|
opts = {:locals=>{:value=>value, :opts=>opts}}
|
237
237
|
opts[:path] = template_path('button')
|
238
|
-
|
238
|
+
opts[:cache] = true
|
239
|
+
opts[:cache_key] = :rodauth_button
|
240
|
+
opts
|
241
|
+
end
|
242
|
+
|
243
|
+
def button(value, opts={})
|
244
|
+
scope.render(button_opts(value, opts))
|
239
245
|
end
|
240
246
|
|
241
247
|
def view(page, title)
|
@@ -431,6 +437,10 @@ module Rodauth
|
|
431
437
|
timestamp
|
432
438
|
end
|
433
439
|
|
440
|
+
def loaded_templates
|
441
|
+
[]
|
442
|
+
end
|
443
|
+
|
434
444
|
# This is used to avoid race conditions when using the pattern of inserting when
|
435
445
|
# an update affects no rows. In such cases, if a row is inserted between the
|
436
446
|
# update and the insert, the insert will fail with a uniqueness error, but
|
@@ -499,19 +509,26 @@ module Rodauth
|
|
499
509
|
update_hash_ds(account, ds, values)
|
500
510
|
end
|
501
511
|
|
502
|
-
def
|
512
|
+
def _view_opts(page)
|
503
513
|
auth_template_path = template_path(page)
|
504
514
|
opts = template_opts.dup
|
505
515
|
opts[:locals] = opts[:locals] ? opts[:locals].dup : {}
|
506
516
|
opts[:locals][:rodauth] = self
|
517
|
+
opts[:cache] = true
|
518
|
+
opts[:cache_key] = :"rodauth_#{page}"
|
507
519
|
|
508
520
|
scope.instance_exec do
|
509
521
|
opts = find_template(parse_template_opts(page, opts))
|
510
522
|
unless File.file?(template_path(opts))
|
511
523
|
opts[:path] = auth_template_path
|
512
524
|
end
|
513
|
-
send(meth, opts)
|
514
525
|
end
|
526
|
+
|
527
|
+
opts
|
528
|
+
end
|
529
|
+
|
530
|
+
def _view(meth, page)
|
531
|
+
scope.send(meth, _view_opts(page))
|
515
532
|
end
|
516
533
|
end
|
517
534
|
end
|
@@ -4,6 +4,7 @@ module Rodauth
|
|
4
4
|
CloseAccount = Feature.define(:close_account) do
|
5
5
|
notice_flash 'Your account has been closed'
|
6
6
|
error_flash 'There was an error closing your account'
|
7
|
+
loaded_templates %w'close-account password-field'
|
7
8
|
view 'close-account', 'Close Account'
|
8
9
|
additional_form_tags
|
9
10
|
button 'Close Account'
|
@@ -4,6 +4,7 @@ module Rodauth
|
|
4
4
|
ConfirmPassword = Feature.define(:confirm_password) do
|
5
5
|
notice_flash "Your password has been confirmed"
|
6
6
|
error_flash "There was an error confirming your password"
|
7
|
+
loaded_templates %w'confirm-password password-field'
|
7
8
|
view 'confirm-password', 'Confirm Password'
|
8
9
|
additional_form_tags
|
9
10
|
button 'Confirm Password'
|
@@ -7,6 +7,7 @@ module Rodauth
|
|
7
7
|
depends :login
|
8
8
|
notice_flash 'Your account has been created'
|
9
9
|
error_flash "There was an error creating your account"
|
10
|
+
loaded_templates %w'create-account login-field login-confirm-field password-field password-confirm-field'
|
10
11
|
view 'create-account', 'Create Account'
|
11
12
|
after
|
12
13
|
before
|
@@ -4,6 +4,7 @@ module Rodauth
|
|
4
4
|
Lockout = Feature.define(:lockout) do
|
5
5
|
depends :login, :email_base
|
6
6
|
|
7
|
+
loaded_templates %w'unlock-account-request unlock-account password-field unlock-account-email'
|
7
8
|
view 'unlock-account-request', 'Request Account Unlock', 'unlock_account_request'
|
8
9
|
view 'unlock-account', 'Unlock Account', 'unlock_account'
|
9
10
|
before 'unlock_account'
|
data/lib/rodauth/features/otp.rb
CHANGED
@@ -38,6 +38,7 @@ module Rodauth
|
|
38
38
|
redirect :otp_already_setup
|
39
39
|
redirect :otp_setup
|
40
40
|
|
41
|
+
loaded_templates %w'otp-disable otp-auth otp-setup otp-auth-code-field password-field'
|
41
42
|
view 'otp-disable', 'Disable Two Factor Authentication', 'otp_disable'
|
42
43
|
view 'otp-auth', 'Enter Authentication Code', 'otp_auth'
|
43
44
|
view 'otp-setup', 'Setup Two Factor Authentication', 'otp_setup'
|
@@ -28,6 +28,7 @@ module Rodauth
|
|
28
28
|
redirect(:recovery_auth){"#{prefix}/#{recovery_auth_route}"}
|
29
29
|
redirect(:add_recovery_codes){"#{prefix}/#{recovery_codes_route}"}
|
30
30
|
|
31
|
+
loaded_templates %w'add-recovery-codes recovery-auth recovery-codes password-field'
|
31
32
|
view 'add-recovery-codes', 'Authentication Recovery Codes', 'add_recovery_codes'
|
32
33
|
view 'recovery-auth', 'Enter Authentication Recovery Code', 'recovery_auth'
|
33
34
|
view 'recovery-codes', 'View Authentication Recovery Codes', 'recovery_codes'
|
@@ -6,6 +6,7 @@ module Rodauth
|
|
6
6
|
|
7
7
|
notice_flash "Your remember setting has been updated"
|
8
8
|
error_flash "There was an error updating your remember setting"
|
9
|
+
loaded_templates %w'remember'
|
9
10
|
view 'remember', 'Change Remember Setting'
|
10
11
|
additional_form_tags
|
11
12
|
button 'Change Remember Setting'
|
@@ -8,6 +8,7 @@ module Rodauth
|
|
8
8
|
notice_flash "An email has been sent to you with a link to reset the password for your account", 'reset_password_email_sent'
|
9
9
|
error_flash "There was an error resetting your password"
|
10
10
|
error_flash "There was an error requesting a password reset", 'reset_password_request'
|
11
|
+
loaded_templates %w'reset-password password-field password-confirm-field reset-password-email'
|
11
12
|
view 'reset-password', 'Reset Password'
|
12
13
|
additional_form_tags
|
13
14
|
additional_form_tags 'reset_password_request'
|
@@ -146,6 +147,8 @@ module Rodauth
|
|
146
147
|
# existing reset password key from the table, or reraise.
|
147
148
|
raise e unless @reset_password_key_value = get_password_reset_key(account_id)
|
148
149
|
end
|
150
|
+
else
|
151
|
+
@reset_password_key_value = get_password_reset_key(account_id)
|
149
152
|
end
|
150
153
|
end
|
151
154
|
end
|
@@ -50,6 +50,7 @@ module Rodauth
|
|
50
50
|
redirect(:sms_needs_setup){"#{prefix}/#{sms_setup_route}"}
|
51
51
|
redirect(:sms_request){"#{prefix}/#{sms_request_route}"}
|
52
52
|
|
53
|
+
loaded_templates %w'sms-auth sms-confirm sms-disable sms-request sms-setup sms-code-field password-field'
|
53
54
|
view 'sms-auth', 'Authenticate via SMS Code', 'sms_auth'
|
54
55
|
view 'sms-confirm', 'Confirm SMS Backup Number', 'sms_confirm'
|
55
56
|
view 'sms-disable', 'Disable Backup SMS Authentication', 'sms_disable'
|
@@ -8,6 +8,7 @@ module Rodauth
|
|
8
8
|
error_flash "Unable to resend verify account email", 'verify_account_resend'
|
9
9
|
notice_flash "Your account has been verified"
|
10
10
|
notice_flash "An email has been sent to you with a link to verify your account", 'verify_account_email_sent'
|
11
|
+
loaded_templates %w'verify-account verify-account-resend verify-account-email'
|
11
12
|
view 'verify-account', 'Verify Account'
|
12
13
|
view 'verify-account-resend', 'Resend Verification Email', 'resend_verify_account'
|
13
14
|
additional_form_tags
|
data/lib/rodauth/version.rb
CHANGED
data/spec/login_spec.rb
CHANGED
@@ -133,7 +133,7 @@ describe 'Rodauth login feature' do
|
|
133
133
|
r.rodauth
|
134
134
|
end
|
135
135
|
next unless session[:login_email] =~ /example/
|
136
|
-
r.get('foo
|
136
|
+
r.get('foo', :email){|e| "Logged In: #{e}"}
|
137
137
|
end
|
138
138
|
app.plugin :render, :views=>'spec/views', :engine=>'str'
|
139
139
|
|
@@ -158,7 +158,7 @@ describe 'Rodauth password expiration feature' do
|
|
158
158
|
roda do |r|
|
159
159
|
r.rodauth
|
160
160
|
rodauth.require_current_password
|
161
|
-
r.get("expire
|
161
|
+
r.get("expire", :d){|d| session[:password_changed_at] = Time.now.to_i - d.to_i; r.redirect '/'}
|
162
162
|
r.root{view :content=>""}
|
163
163
|
end
|
164
164
|
|
data/spec/reset_password_spec.rb
CHANGED
@@ -23,6 +23,10 @@ describe 'Rodauth reset_password feature' do
|
|
23
23
|
visit link[0...-1]
|
24
24
|
page.find('#error_flash').text.must_equal "invalid password reset key"
|
25
25
|
|
26
|
+
login(:pass=>'01234567', :visit=>false)
|
27
|
+
click_button 'Request Password Reset'
|
28
|
+
email_link(/(\/reset-password\?key=.+)$/).must_equal link
|
29
|
+
|
26
30
|
visit link
|
27
31
|
page.title.must_equal 'Reset Password'
|
28
32
|
|
data/spec/rodauth_spec.rb
CHANGED
@@ -25,6 +25,19 @@ describe 'Rodauth' do
|
|
25
25
|
page.title.must_equal 'Foo Login'
|
26
26
|
end
|
27
27
|
|
28
|
+
it "should work without preloading the templates" do
|
29
|
+
@no_precompile = true
|
30
|
+
rodauth do
|
31
|
+
enable :login
|
32
|
+
end
|
33
|
+
roda do |r|
|
34
|
+
r.rodauth
|
35
|
+
end
|
36
|
+
|
37
|
+
visit '/login'
|
38
|
+
page.title.must_equal 'Login'
|
39
|
+
end
|
40
|
+
|
28
41
|
it "should require login to perform certain actions" do
|
29
42
|
rodauth do
|
30
43
|
enable :login, :change_password, :change_login, :close_account
|
data/spec/spec_helper.rb
CHANGED
@@ -42,7 +42,8 @@ require 'tilt/string'
|
|
42
42
|
|
43
43
|
db_url = ENV['RODAUTH_SPEC_DB'] || 'postgres:///?user=rodauth_test&password=rodauth_test'
|
44
44
|
DB = Sequel.connect(db_url, :identifier_mangling=>false)
|
45
|
-
DB.extension
|
45
|
+
DB.extension :freeze_datasets, :date_arithmetic
|
46
|
+
DB.freeze
|
46
47
|
puts "using #{DB.database_type}"
|
47
48
|
|
48
49
|
#DB.loggers << Logger.new($stdout)
|
@@ -98,6 +99,9 @@ class Minitest::HooksSpec
|
|
98
99
|
jwt = type == :jwt || type == :jwt_html
|
99
100
|
|
100
101
|
app = Class.new(jwt_only ? JsonBase : Base)
|
102
|
+
app.opts[:unsupported_block_result] = :raise
|
103
|
+
app.opts[:unsupported_matcher] = :raise
|
104
|
+
app.opts[:verbatim_string_matcher] = true
|
101
105
|
rodauth_block = @rodauth_block
|
102
106
|
opts = type.is_a?(Hash) ? type : {}
|
103
107
|
|
@@ -116,6 +120,7 @@ class Minitest::HooksSpec
|
|
116
120
|
instance_exec(&rodauth_block)
|
117
121
|
end
|
118
122
|
app.route(&block)
|
123
|
+
app.precompile_rodauth_templates unless @no_precompile || jwt_only
|
119
124
|
app.freeze unless @no_freeze
|
120
125
|
self.app = app
|
121
126
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rodauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -235,6 +235,7 @@ extra_rdoc_files:
|
|
235
235
|
- doc/release_notes/1.6.0.txt
|
236
236
|
- doc/release_notes/1.7.0.txt
|
237
237
|
- doc/release_notes/1.8.0.txt
|
238
|
+
- doc/release_notes/1.9.0.txt
|
238
239
|
files:
|
239
240
|
- CHANGELOG
|
240
241
|
- MIT-LICENSE
|
@@ -269,6 +270,7 @@ files:
|
|
269
270
|
- doc/release_notes/1.6.0.txt
|
270
271
|
- doc/release_notes/1.7.0.txt
|
271
272
|
- doc/release_notes/1.8.0.txt
|
273
|
+
- doc/release_notes/1.9.0.txt
|
272
274
|
- doc/remember.rdoc
|
273
275
|
- doc/reset_password.rdoc
|
274
276
|
- doc/session_expiration.rdoc
|