rodauth 2.5.0 → 2.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +42 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +18 -6
- data/doc/argon2.rdoc +49 -0
- data/doc/base.rdoc +3 -2
- data/doc/guides/migrate_password_hash_algorithm.rdoc +15 -0
- data/doc/json.rdoc +47 -0
- data/doc/jwt.rdoc +1 -28
- data/doc/jwt_refresh.rdoc +8 -0
- data/doc/login_password_requirements_base.rdoc +1 -1
- data/doc/recovery_codes.rdoc +2 -1
- data/doc/release_notes/2.10.0.txt +47 -0
- data/doc/release_notes/2.6.0.txt +37 -0
- data/doc/release_notes/2.7.0.txt +33 -0
- data/doc/release_notes/2.8.0.txt +20 -0
- data/doc/release_notes/2.9.0.txt +21 -0
- data/doc/remember.rdoc +1 -1
- data/javascript/webauthn_auth.js +9 -9
- data/javascript/webauthn_setup.js +9 -6
- data/lib/rodauth.rb +14 -6
- data/lib/rodauth/features/argon2.rb +69 -0
- data/lib/rodauth/features/base.rb +12 -3
- data/lib/rodauth/features/confirm_password.rb +2 -2
- data/lib/rodauth/features/disallow_password_reuse.rb +20 -7
- data/lib/rodauth/features/json.rb +189 -0
- data/lib/rodauth/features/jwt.rb +22 -170
- data/lib/rodauth/features/jwt_refresh.rb +63 -13
- data/lib/rodauth/features/login_password_requirements_base.rb +4 -0
- data/lib/rodauth/features/otp.rb +0 -2
- data/lib/rodauth/features/recovery_codes.rb +22 -1
- data/lib/rodauth/features/remember.rb +6 -1
- data/lib/rodauth/features/update_password_hash.rb +1 -1
- data/lib/rodauth/features/verify_account.rb +6 -7
- data/lib/rodauth/features/webauthn_verify_account.rb +1 -1
- data/lib/rodauth/migrations.rb +31 -5
- data/lib/rodauth/version.rb +1 -1
- metadata +55 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5286a570d72b6bc951ca489e12a696a4c2348d789d09f2782cfbd3521e63ee6d
|
4
|
+
data.tar.gz: be5d4e5bef18f6f62978bc84e07da1c4b31db4f03bf104d01abf8510812c5719
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98a849b965bfee4d80b8b6f6fc286d22f57673bf37da4e2cb338c114275795b665e46b561781f688dbb2ddfdd312e8b393f545d1920ac9f83024e042ff97cee0
|
7
|
+
data.tar.gz: 46da808a9d2e38c647339eed1554183b0e175fb3dbf4fd04d49d78015ff523bc0960091b3643bbc3913cfce88b7f78a240bd1857002de889a2d9455f106e4e03
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,45 @@
|
|
1
|
+
=== 2.10.0 (2021-02-22)
|
2
|
+
|
3
|
+
* Add argon2 feature to allow use of the argon2 password hash algorithm instead of bcrypt (AlexeyMatskevich, jeremyevans) (#147)
|
4
|
+
|
5
|
+
* Avoid unnecessary previous password queries when using disallow_password_reuse feature with create_account or verify_account features (AlexeyMatskevich, jeremyevans) (#148)
|
6
|
+
|
7
|
+
=== 2.9.0 (2021-01-22)
|
8
|
+
|
9
|
+
* Split jwt feature into json and jwt features, with the json feature using standard session support (janko, jeremyevans) (#145)
|
10
|
+
|
11
|
+
* Mark remember cookie as only transmitted over HTTPS by default if created via an HTTPS request (janko) (#144)
|
12
|
+
|
13
|
+
=== 2.8.0 (2021-01-06)
|
14
|
+
|
15
|
+
* [SECURITY] Set HttpOnly on remember cookie by default so it cannot be accessed by Javascript (janko) (#142)
|
16
|
+
|
17
|
+
* Clear JWT session when rodauth.clear_session is called if the Roda sessions plugin is used (janko) (#140)
|
18
|
+
|
19
|
+
=== 2.7.0 (2020-12-22)
|
20
|
+
|
21
|
+
* Avoid method redefinition warnings in verbose warning mode (jeremyevans)
|
22
|
+
|
23
|
+
* Return expired access token error message in the JWT refresh feature when using an expired token when it isn't allowed (AlexyMatskevich) (#133)
|
24
|
+
|
25
|
+
* Allow Rodauth features to be preloaded, instead of always trying to require them (janko) (#136)
|
26
|
+
|
27
|
+
* Use a default remember cookie path of '/', though this may cause problem with multiple Rodauth configurations on the same domain (janko) (#134)
|
28
|
+
|
29
|
+
* Add auto_remove_recovery_codes? to the recovery_codes feature, for automatically removing the codes when disabling multifactor authentication (SilasSpet, jeremyevans) (#135)
|
30
|
+
|
31
|
+
=== 2.6.0 (2020-11-20)
|
32
|
+
|
33
|
+
* Avoid loading features multiple times (janko) (#131)
|
34
|
+
|
35
|
+
* Add around_rodauth method for running code around the handling of all Rodauth routes (bjeanes) (#129)
|
36
|
+
|
37
|
+
* Fix javascript for registration of multiple webauthn keys (bjeanes) (#127)
|
38
|
+
|
39
|
+
* Add allow_refresh_with_expired_jwt_access_token? configuration method to jwt_refresh feature, for allowing refresh with expired access token (jeremyevans)
|
40
|
+
|
41
|
+
* Promote setup_account_verification to public API, useful for automatically sending account verification emails (jeremyevans)
|
42
|
+
|
1
43
|
=== 2.5.0 (2020-10-22)
|
2
44
|
|
3
45
|
* Add change_login_needs_verification_notice_flash for easier translation of change_login_notice_flash when using verify_login_change (bjeanes, janko, jeremyevans) (#126)
|
data/MIT-LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -52,10 +52,12 @@ HTML and JSON API for all supported features.
|
|
52
52
|
* Session Expiration
|
53
53
|
* Active Sessions (Prevent session reuse after logout, allow logout of all sessions)
|
54
54
|
* Single Session (Only one active session per account)
|
55
|
-
*
|
55
|
+
* JSON (JSON API support for all other features)
|
56
|
+
* JWT (JSON Web Token support for all other features)
|
56
57
|
* JWT Refresh (Access & Refresh Token)
|
57
58
|
* JWT CORS (Cross-Origin Resource Sharing)
|
58
59
|
* Update Password Hash (when hash cost changes)
|
60
|
+
* Argon2
|
59
61
|
* HTTP Basic Auth
|
60
62
|
* Change Password Notify
|
61
63
|
|
@@ -79,8 +81,10 @@ rack_csrf :: Used for CSRF support if the :csrf=>:rack_csrf plugin
|
|
79
81
|
option is given (the default is to use Roda's route_csrf
|
80
82
|
plugin, as that allows for more secure request-specific
|
81
83
|
tokens).
|
82
|
-
bcrypt :: Used by default for password
|
84
|
+
bcrypt :: Used by default for password hashing, can be skipped
|
83
85
|
if password_match? is overridden for custom authentication.
|
86
|
+
argon2 :: Used by the argon2 feature as alternative to bcrypt for
|
87
|
+
password hashing.
|
84
88
|
mail :: Used by default for mailing in the reset password, verify
|
85
89
|
account, verify_login_change, change_password_notify,
|
86
90
|
lockout, and email_auth features.
|
@@ -105,7 +109,7 @@ correctly without it. There may be cases where you cannot use
|
|
105
109
|
this feature, such as when using a different database or when you
|
106
110
|
do not have full control over the database you are using.
|
107
111
|
|
108
|
-
Passwords are hashed using bcrypt, and the password hashes are
|
112
|
+
Passwords are hashed using bcrypt by default, and the password hashes are
|
109
113
|
kept in a separate table from the accounts table, with a foreign key
|
110
114
|
referencing the accounts table. Two database functions are added,
|
111
115
|
one to retrieve the salt for a password, and the other to check
|
@@ -332,7 +336,7 @@ things for the schema changes:
|
|
332
336
|
foreign_key :id, Sequel[:${DATABASE_NAME}][:accounts], :primary_key=>true, :type=>:Bignum
|
333
337
|
String :password_hash, :null=>false
|
334
338
|
end
|
335
|
-
Rodauth.create_database_authentication_functions(self, :table_name=>
|
339
|
+
Rodauth.create_database_authentication_functions(self, :table_name=>Sequel[:${DATABASE_NAME}_password][:account_password_hashes])
|
336
340
|
|
337
341
|
# if using the disallow_password_reuse feature:
|
338
342
|
create_table(:account_previous_password_hashes) do
|
@@ -340,7 +344,7 @@ things for the schema changes:
|
|
340
344
|
foreign_key :account_id, Sequel[:${DATABASE_NAME}][:accounts], :type=>:Bignum
|
341
345
|
String :password_hash, :null=>false
|
342
346
|
end
|
343
|
-
Rodauth.create_database_previous_password_check_functions(self, :table_name=>
|
347
|
+
Rodauth.create_database_previous_password_check_functions(self, :table_name=>Sequel[:${DATABASE_NAME}_password][:account_previous_password_hashes])
|
344
348
|
|
345
349
|
You'll also need to use the following Rodauth configuration methods so that the
|
346
350
|
app account calls functions in a separate schema:
|
@@ -862,6 +866,7 @@ view the appropriate file in the doc directory.
|
|
862
866
|
* {Account Expiration}[rdoc-ref:doc/account_expiration.rdoc]
|
863
867
|
* {Active Sessions}[rdoc-ref:doc/active_sessions.rdoc]
|
864
868
|
* {Audit Logging}[rdoc-ref:doc/audit_logging.rdoc]
|
869
|
+
* {Argon2}[rdoc-ref:doc/argon2.rdoc]
|
865
870
|
* {Change Login}[rdoc-ref:doc/change_login.rdoc]
|
866
871
|
* {Change Password}[rdoc-ref:doc/change_password.rdoc]
|
867
872
|
* {Change Password Notify}[rdoc-ref:doc/change_password_notify.rdoc]
|
@@ -872,6 +877,7 @@ view the appropriate file in the doc directory.
|
|
872
877
|
* {Disallow Password Reuse}[rdoc-ref:doc/disallow_password_reuse.rdoc]
|
873
878
|
* {Email Authentication}[rdoc-ref:doc/email_auth.rdoc]
|
874
879
|
* {HTTP Basic Auth}[rdoc-ref:doc/http_basic_auth.rdoc]
|
880
|
+
* {JSON}[rdoc-ref:doc/json.rdoc]
|
875
881
|
* {JWT CORS}[rdoc-ref:doc/jwt_cors.rdoc]
|
876
882
|
* {JWT Refresh}[rdoc-ref:doc/jwt_refresh.rdoc]
|
877
883
|
* {JWT}[rdoc-ref:doc/jwt.rdoc]
|
@@ -1320,7 +1326,13 @@ use the necessary *_email_body configuration options to specify
|
|
1320
1326
|
the body of the emails.
|
1321
1327
|
|
1322
1328
|
The JWT feature enables JSON API support for all of the other features
|
1323
|
-
that Rodauth ships with.
|
1329
|
+
that Rodauth ships with. If you would like JSON API access that still uses
|
1330
|
+
rack session for storing session data, enable the JSON feature instead:
|
1331
|
+
|
1332
|
+
plugin :rodauth, :json=>true do
|
1333
|
+
enable :login, :logout, :json
|
1334
|
+
only_json? true # if you want to only handle JSON requests
|
1335
|
+
end
|
1324
1336
|
|
1325
1337
|
=== Adding Custom Methods to the +rodauth+ Object
|
1326
1338
|
|
data/doc/argon2.rdoc
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
= Documentation for Argon2 Feature
|
2
|
+
|
3
|
+
The argon2 feature adds the ability to replace the bcrypt password hash
|
4
|
+
algorithm with argon2 (specifically, argon2id). Argon2 is an alternative to
|
5
|
+
bcrypt that offers the ability to be memory-hard. However, if you are storing
|
6
|
+
password hashes in a table that the database user does not have access to
|
7
|
+
(the recommended way to use Rodauth), argon2 does not offer significant
|
8
|
+
security advantages over bcrypt.
|
9
|
+
|
10
|
+
If you are using this feature with Rodauth's database authentication functions,
|
11
|
+
you need to make sure that the database authentication functions are configured
|
12
|
+
to support argon2 in addition to bcrypt. You can do this by passing the
|
13
|
+
+:argon2+ option when calling the method to define the database functions.
|
14
|
+
In this example, +DB+ should be your Sequel::Database object:
|
15
|
+
|
16
|
+
require 'rodauth/migrations'
|
17
|
+
|
18
|
+
# If the functions are already defined and you are not using PostgreSQL,
|
19
|
+
# you need to drop the existing functions.
|
20
|
+
Rodauth.drop_database_authentication_functions(DB)
|
21
|
+
|
22
|
+
# If you are using the disallow_password_reuse feature, also drop the
|
23
|
+
# database functions related to that if not using PostgreSQL:
|
24
|
+
Rodauth.drop_database_previous_password_check_functions(DB)
|
25
|
+
|
26
|
+
# Define new functions that support argon2:
|
27
|
+
Rodauth.create_database_authentication_functions(DB, argon2: true)
|
28
|
+
|
29
|
+
# If you are using the disallow_password_reuse feature, also define
|
30
|
+
# new functions that support argon2 for that:
|
31
|
+
Rodauth.create_database_previous_password_check_functions(DB, argon2: true)
|
32
|
+
|
33
|
+
The argon2 feature provides the ability to allow for a gradual migration
|
34
|
+
from transitioning from bcrypt to argon2 and vice-versa, if you are using the
|
35
|
+
update_password_hash.
|
36
|
+
|
37
|
+
Argon2 is more configurable than bcrypt in terms of password hash cost
|
38
|
+
speficiation. Instead of specifying the password_hash_cost value as
|
39
|
+
an integer, you must specify the password hash cost as a hash, such as
|
40
|
+
(<tt>{t_cost: 2, m_cost: 16}</tt>).
|
41
|
+
|
42
|
+
If you are using the argon2 feature and if you have no bcrypt passwords in
|
43
|
+
your database, you should use <tt>require_bcrypt? false</tt> in your
|
44
|
+
Rodauth configuration to prevent loading the bcrypt library, which will save
|
45
|
+
memory.
|
46
|
+
|
47
|
+
== Auth Value Methods
|
48
|
+
|
49
|
+
use_argon2? :: Whether to use the argon2 password hash algorithm for new passwords (true by default). The only reason to set this to false is if you have existing passwords using argon2 that you want to support, but want to use bcrypt for new passwords.
|
data/doc/base.rdoc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= Documentation for Base Feature
|
2
2
|
|
3
3
|
The base feature is automatically loaded when you use Rodauth. It contains
|
4
|
-
shared functionality that is used by multiple features.
|
4
|
+
shared functionality that is used by multiple features.
|
5
5
|
|
6
6
|
== Auth Value Methods
|
7
7
|
|
@@ -15,7 +15,7 @@ domain :: The domain to use, required by some other features. It is recommended
|
|
15
15
|
hmac_secret :: This sets the secret to use for all of Rodauth's HMACs. This is not set by default, in which case Rodauth does not use HMACs for additional security. However, it is highly recommended that you set this, and some features require it.
|
16
16
|
mark_input_fields_as_required? :: Whether input fields should be marked as required, so browsers will not allow submission without filling out the field (default: true).
|
17
17
|
prefix :: The routing prefix used for Rodauth routes. If you are calling in a routing subtree, this should be set to the root path of the subtree. This should include a leading slash if set, but not a trailing slash.
|
18
|
-
require_bcrypt? :: Set to false to not require bcrypt, useful if using custom authentication.
|
18
|
+
require_bcrypt? :: Set to false to not require bcrypt, useful if using custom authentication or when using the argon2 feature without existing bcrypt password hashes.
|
19
19
|
session_key :: The key in the session hash storing the primary key of the logged in account.
|
20
20
|
session_key_prefix :: The string that will be prepended to the default value for all session keys.
|
21
21
|
skip_status_checks? :: Whether status checks should be skipped for accounts. Defaults to true unless enabling the verify_account or close_account features.
|
@@ -88,6 +88,7 @@ account_session_value :: The primary value of the current account to store in th
|
|
88
88
|
after_login :: Run arbitrary code after a successful login.
|
89
89
|
after_login_failure :: Run arbitrary code after a login failure due to an invalid password.
|
90
90
|
already_logged_in :: What action to take if you are already logged in and attempt to access a page that only makes sense if you are not logged in.
|
91
|
+
around_rodauth(&block) :: Run arbitrary code around handling any rodauth route. Call <tt>super(&block)</tt> for Rodauth to handle the action.
|
91
92
|
authenticated? :: Whether the user has been authenticated. If multifactor authentication has been enabled for the account, this is true only if the session is multifactor authenticated.
|
92
93
|
before_login :: Run arbitrary code after password has been checked, but before updating the session.
|
93
94
|
before_login_attempt :: Run arbitrary code after an account has been located, but before the password has been checked.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
= Migrate users passwords from bcrypt to argon2 or back
|
2
|
+
|
3
|
+
If you are currently using the default bcrypt password hash algorithm, and want to
|
4
|
+
gradually migrate to the argon2 password hash algorithm, you can use both the argon2
|
5
|
+
and update_password_hash features:
|
6
|
+
|
7
|
+
plugin :rodauth do
|
8
|
+
enable :login, :update_password_hash, :argon2
|
9
|
+
end
|
10
|
+
|
11
|
+
When a user with a current bcrypt password hash next successfully uses their
|
12
|
+
password, their password hash will be migrated to argon2.
|
13
|
+
|
14
|
+
If for some reason you want to migrate back from argon2 to bcrypt, you can set
|
15
|
+
<tt>use_argon2? false</tt> in your Rodauth configuration.
|
data/doc/json.rdoc
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
= Documentation for JSON Feature
|
2
|
+
|
3
|
+
The json feature adds support for JSON API access for all other
|
4
|
+
features that ship with Rodauth.
|
5
|
+
|
6
|
+
When this feature is used, all other features become accessible via a
|
7
|
+
JSON API. The JSON API uses the POST method for all requests, using
|
8
|
+
the same parameter names as the features uses. JSON API requests to
|
9
|
+
Rodauth endpoints that use a method other than POST will result in a
|
10
|
+
405 Method Not Allowed response.
|
11
|
+
|
12
|
+
Responses are returned as JSON hashes. In case of an error, the +error+
|
13
|
+
entry is set to an error message, and the <tt>field-error</tt> entry is set to
|
14
|
+
an array containing the field name and the error message for that field.
|
15
|
+
Successful requests by default store a +success+ entry with a success
|
16
|
+
message, though that can be disabled.
|
17
|
+
|
18
|
+
The session state is managed in the rack session, so make sure that
|
19
|
+
CSRF protection is enabled. This will be the case when passing the
|
20
|
+
<tt>json: true</tt> option when loading the rodauth plugin. If you
|
21
|
+
want to only handle JSON requests, set <tt>only_json? true</tt> in
|
22
|
+
your rodauth configuration.
|
23
|
+
|
24
|
+
If you want token-based authentication sent via the Authorization
|
25
|
+
header, consider using the jwt feature.
|
26
|
+
|
27
|
+
== Auth Value Methods
|
28
|
+
|
29
|
+
json_accept_regexp :: The regexp to use to check the Accept header for JSON if +json_check_accept?+ is true.
|
30
|
+
json_check_accept? :: Whether to check the Accept header to see if the client supports JSON responses, true by default.
|
31
|
+
json_non_post_error_message :: The error message to use when a JSON non-POST request is sent.
|
32
|
+
json_not_accepted_error_message :: The error message to display if +json_check_accept?+ is true and the Accept header is present but does not match +json_request_content_type_regexp+.
|
33
|
+
json_request_content_type_regexp :: The regexp to use to recognize a request as a json request.
|
34
|
+
json_response_content_type :: The content type to set for json responses, <tt>application/json</tt> by default.
|
35
|
+
json_response_custom_error_status? :: Whether to use custom error statuses, instead of always using +json_response_error_status+, true by default, can be set to false for backwards compatibility with Rodauth 1.
|
36
|
+
json_response_error_key :: The JSON result key containing an error message, +error+ by default.
|
37
|
+
json_response_error_status :: The HTTP status code to use for JSON error responses if not using custom error statuses, 400 by default.
|
38
|
+
json_response_field_error_key :: The JSON result key containing an field error message, <tt>field-error</tt> by default.
|
39
|
+
json_response_success_key :: The JSON result key containing a success message for successful request, if set. +success+ by default.
|
40
|
+
non_json_request_error_message :: The error message to use when a non-JSON request is sent and +only_json?+ is set.
|
41
|
+
only_json? :: Whether to have Rodauth only allow JSON requests. True by default if <tt>json: :only</tt> option was given when loading the plugin. If set, rodauth endpoints will issue an error for non-JSON requests.
|
42
|
+
use_json? :: Whether to return a JSON response. By default, a JSON response is returned if +only_json?+ is true, or if the request uses a json content type.
|
43
|
+
|
44
|
+
== Auth Methods
|
45
|
+
|
46
|
+
json_request? :: Whether the current request is a JSON request, looks at the Content-Type request header by default.
|
47
|
+
json_response_body(hash) :: The body to use for JSON response. By default just converts hash to JSON. Can be used to reformat JSON output in arbitrary ways.
|
data/doc/jwt.rdoc
CHANGED
@@ -2,19 +2,7 @@
|
|
2
2
|
|
3
3
|
The jwt feature adds support for JSON API access for all other features
|
4
4
|
that ship with Rodauth, using JWT (JSON Web Tokens) to hold the
|
5
|
-
session information.
|
6
|
-
|
7
|
-
When this feature is used, all other features become accessible via a
|
8
|
-
JSON API. The JSON API uses the POST method for all requests, using
|
9
|
-
the same parameter names as the features uses. JSON API requests to
|
10
|
-
Rodauth endpoints that use a method other than POST will result in a
|
11
|
-
405 Method Not Allowed response.
|
12
|
-
|
13
|
-
Responses are returned as JSON hashes. In case of an error, the +error+
|
14
|
-
entry is set to an error message, and the <tt>field-error</tt> entry is set to
|
15
|
-
an array containing the field name and the error message for that field.
|
16
|
-
Successful requests by default store a +success+ entry with a success
|
17
|
-
message, though that can be disabled.
|
5
|
+
session information. It depends on the json feature.
|
18
6
|
|
19
7
|
In order to use this feature, you have to set the +jwt_secret+ configuration
|
20
8
|
option the secret used to cryptographically protect the token.
|
@@ -41,32 +29,17 @@ from +rodauth.session+.
|
|
41
29
|
== Auth Value Methods
|
42
30
|
|
43
31
|
invalid_jwt_format_error_message :: The error message to use when a JWT with an invalid format is submitted in the Authorization header.
|
44
|
-
json_accept_regexp :: The regexp to use to check the Accept header for JSON if +jwt_check_accept?+ is true.
|
45
|
-
json_non_post_error_message :: The error message to use when a JSON non-POST request is sent.
|
46
|
-
json_not_accepted_error_message :: The error message to display if +jwt_check_accept?+ is true and the Accept header is present but does not match +json_request_content_type_regexp+.
|
47
|
-
json_request_content_type_regexp :: The regexp to use to recognize a request as a json request.
|
48
|
-
json_response_content_type :: The content type to set for json responses, <tt>application/json</tt> by default.
|
49
|
-
json_response_custom_error_status? :: Whether to use custom error statuses, instead of always using +json_response_error_status+, true by default, can be set to false for backwards compatibility with Rodauth 1.
|
50
|
-
json_response_error_key :: The JSON result key containing an error message, +error+ by default.
|
51
|
-
json_response_error_status :: The HTTP status code to use for JSON error responses if not using custom error statuses, 400 by default.
|
52
|
-
json_response_field_error_key :: The JSON result key containing an field error message, <tt>field-error</tt> by default.
|
53
|
-
json_response_success_key :: The JSON result key containing a success message for successful request, if set. +success+ by default.
|
54
32
|
jwt_algorithm :: The JWT algorithm to use, +HS256+ by default.
|
55
33
|
jwt_authorization_ignore :: A regexp matched against the Authorization header, which skips JWT processing if it matches. By default, HTTP Basic and Digest authentication are ignored.
|
56
34
|
jwt_authorization_remove :: A regexp to remove from the Authorization header before processing the JWT. By default, a Bearer prefix is removed.
|
57
|
-
jwt_check_accept? :: Whether to check the Accept header to see if the client supports JSON responses, true by default, can be set to false for backwards compatibility with Rodauth 1.
|
58
35
|
jwt_decode_opts :: An optional hash to pass to +JWT.decode+. Can be used to set JWT verifiers.
|
59
36
|
jwt_secret :: The JWT secret to use. Access to this should be protected the same as a session secret.
|
60
37
|
jwt_session_key :: A key to nest the session hash under in the JWT payload. nil by default, for no nesting.
|
61
38
|
jwt_symbolize_deeply? :: Whether to symbolize the session hash deeply. false by default.
|
62
|
-
non_json_request_error_message :: The error message to use when a non-JSON request is sent and +only_json?+ is set.
|
63
|
-
only_json? :: Whether to have Rodauth only allow JSON requests. True by default if <tt>json: :only</tt> option was given when loading the plugin. If set, rodauth endpoints will issue an error for non-JSON requests.
|
64
39
|
use_jwt? :: Whether to use the JWT in the Authorization header for authentication information. If false, falls back to using the rack session. By default, the Authorization header is used if it is present, if +only_json?+ is true, or if the request uses a json content type.
|
65
40
|
|
66
41
|
== Auth Methods
|
67
42
|
|
68
|
-
json_request? :: Whether the current request is a JSON request, looks at the Content-Type request header by default.
|
69
|
-
json_response_body(hash) :: The body to use for JSON response. By default just converts hash to JSON. Can be used to reformat JSON output in arbitrary ways.
|
70
43
|
jwt_session_hash :: The session hash used to create the session_jwt. Can be used to set JWT claims.
|
71
44
|
jwt_token :: Retrieve the JWT token from the request, by default taking it from the Authorization header.
|
72
45
|
session_jwt :: An encoded JWT for the current session.
|
data/doc/jwt_refresh.rdoc
CHANGED
@@ -21,19 +21,27 @@ a value of <tt>all</tt> as the token value.
|
|
21
21
|
|
22
22
|
When using the refresh token, you must provide a valid access token, as that contains
|
23
23
|
information about the current session, which is used to create the new access token.
|
24
|
+
If you change the +allow_refresh_with_expired_jwt_access_token?+ setting to +true+,
|
25
|
+
an expired but otherwise valid access token will be accepted, and Rodauth will check
|
26
|
+
that the access token was issued in the same session as the refresh token.
|
24
27
|
|
25
28
|
This feature depends on the jwt feature.
|
26
29
|
|
27
30
|
== Auth Value Methods
|
28
31
|
|
32
|
+
allow_refresh_with_expired_jwt_access_token? :: Whether refreshing should be allowed with an expired access token. Default is +false+. You must set an +hmac_secret+ if setting this value to +true+.
|
33
|
+
expired_jwt_access_token_status :: The HTTP status code to use when a access token (JWT) is expired is submitted in the Authorization header. Default is 400 for backwards compatibility, and it is recommended to set it to 401.
|
34
|
+
expired_jwt_access_token_message :: The error message to use when a access token (JWT) is expired is submitted in the Authorization header.
|
29
35
|
jwt_access_token_key :: Name of the key in the response json holding the access token. Default is +access_token+.
|
30
36
|
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.
|
31
37
|
jwt_access_token_period :: Validity of an access token in seconds, default is 1800 (30 minutes).
|
32
38
|
jwt_refresh_route :: The route to the login action. Defaults to <tt>jwt-refresh</tt>.
|
33
39
|
jwt_refresh_invalid_token_message :: Error message when the provided refresh token is non existent, invalid or expired.
|
34
40
|
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.
|
41
|
+
jwt_refresh_token_data_session_key :: The key in the session hash storing random data, for access checking during refresh if +allow_refresh_with_expired_jwt_access_token?+ is set.
|
35
42
|
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
43
|
jwt_refresh_token_deadline_interval :: Validity of a refresh token. Default is 14 days.
|
44
|
+
jwt_refresh_token_hmac_session_key :: The key in the session hash storing the hmac, for access checking during refresh if +allow_refresh_with_expired_jwt_access_token?+ is set.
|
37
45
|
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).
|
38
46
|
jwt_refresh_token_key :: Name of the key in the response json holding the refresh token. Default is +refresh_token+.
|
39
47
|
jwt_refresh_token_key_column :: The column name in the +jwt_refresh_token_table+ holding the refresh token key value.
|
@@ -19,7 +19,7 @@ logins_do_not_match_message :: The error message to display when login and login
|
|
19
19
|
password_confirm_label :: The label to use for password confirmations.
|
20
20
|
password_confirm_param :: The parameter name to use for password confirmations.
|
21
21
|
password_does_not_meet_requirements_message :: The error message to display when the password does not meet the requirements you have set.
|
22
|
-
password_hash_cost :: The
|
22
|
+
password_hash_cost :: The cost to use for the password hash algorithm. This should be an integer when using bcrypt (the default), and a hash if using argon2 (supported by the argon2 feature).
|
23
23
|
password_minimum_length :: The minimum length for passwords, 6 by default.
|
24
24
|
password_too_short_message :: The error message fragment to show if the password is too short.
|
25
25
|
passwords_do_not_match_message :: The error message to display when password and password confirmation do not match.
|
data/doc/recovery_codes.rdoc
CHANGED
@@ -17,7 +17,8 @@ add_recovery_codes_error_flash :: The flash error to show when adding recovery c
|
|
17
17
|
add_recovery_codes_heading :: Text to use for heading above the form to add recovery codes.
|
18
18
|
add_recovery_codes_page_title :: The page title to use on the add recovery codes form.
|
19
19
|
add_recovery_codes_param :: The parameter name to use for adding recovery codes.
|
20
|
-
auto_add_recovery_codes? :: Whether to automatically add recovery codes (or any missing recovery codes) when
|
20
|
+
auto_add_recovery_codes? :: Whether to automatically add recovery codes (or any missing recovery codes) when enabling otp, webauthn, or sms authentication (false by default).
|
21
|
+
auto_remove_recovery_codes? :: Whether to automatically remove recovery codes when disabling otp, webauthn, or sms authentication and not having one of the other two authentication methods enabled (false by default).
|
21
22
|
invalid_recovery_code_error_flash :: The flash error to show when an invalid recovery code is used.
|
22
23
|
invalid_recovery_code_message :: The error message to show when an invalid recovery code is used.
|
23
24
|
recovery_auth_additional_form_tags :: HTML fragment containing additional form tags when authenticating via a recovery code.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* An argon2 feature has been added that supports using the argon2
|
4
|
+
password hashing algorithm instead of the bcrypt password hashing
|
5
|
+
algorithm. While argon2 does not provide an advantage over bcrypt
|
6
|
+
if the attacker cannot access the password hashes directly (which
|
7
|
+
is how Rodauth is recommended to be used), in cases where attackers
|
8
|
+
can access the password hashes directly, argon2 is thought to be
|
9
|
+
more difficult or expensive to crack due to requiring more memory
|
10
|
+
(bcrypt is not a memory-hard password hash algorithm).
|
11
|
+
|
12
|
+
If you are using this feature with Rodauth's database authentication
|
13
|
+
functions, you need to make sure that the database authentication
|
14
|
+
functions are configured to support argon2 in addition to bcrypt.
|
15
|
+
You can do this by passing the :argon2 option when calling the
|
16
|
+
method to define the database functions. In this example, DB should
|
17
|
+
be your Sequel::Database object (this could be self if used in a
|
18
|
+
Sequel migration):
|
19
|
+
|
20
|
+
require 'rodauth/migrations'
|
21
|
+
|
22
|
+
# If the functions are already defined and you are not using PostgreSQL,
|
23
|
+
# you need to drop the existing functions.
|
24
|
+
Rodauth.drop_database_authentication_functions(DB)
|
25
|
+
|
26
|
+
# If you are using the disallow_password_reuse feature, also drop the
|
27
|
+
# database functions related to that if you are not using PostgreSQL:
|
28
|
+
Rodauth.drop_database_previous_password_check_functions(DB)
|
29
|
+
|
30
|
+
# Define new functions that support argon2:
|
31
|
+
Rodauth.create_database_authentication_functions(DB, argon2: true)
|
32
|
+
|
33
|
+
# If you are using the disallow_password_reuse feature, also define
|
34
|
+
# new functions that support argon2 for that:
|
35
|
+
Rodauth.create_database_previous_password_check_functions(DB, argon2: true)
|
36
|
+
|
37
|
+
You can transparently migrate bcrypt password hashes to argon2
|
38
|
+
password hashes whenever a user successfully uses their password
|
39
|
+
by using the argon2 feature in combination with the
|
40
|
+
update_password_hash feature.
|
41
|
+
|
42
|
+
= Other Improvements
|
43
|
+
|
44
|
+
* Unnecessary queries to determine whether the new password matches
|
45
|
+
a previous password are now skipped when using the create_account
|
46
|
+
or verify_account features with the disallow_password_reuse
|
47
|
+
feature.
|
@@ -0,0 +1,37 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* An around_rodauth configuration method has been added, which is
|
4
|
+
called around all Rodauth actions. This configuration method
|
5
|
+
is passed a block, and is useful for cases where you want to wrap
|
6
|
+
Rodauth's handling of the request.
|
7
|
+
|
8
|
+
For example, if you had a method named time_block in your Roda scope
|
9
|
+
that timed block execution and added a response header, you could
|
10
|
+
time Rodauth actions using something like:
|
11
|
+
|
12
|
+
around_rodauth do |&block|
|
13
|
+
scope.time_block('Rodauth') do
|
14
|
+
super(&block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
* The allow_refresh_with_expired_jwt_access_token? configuration has
|
19
|
+
been added to the jwt_refresh feature, allowing refreshing with an
|
20
|
+
expired but otherwise valid access token. When using this method,
|
21
|
+
it is required to have an hmac_secret specified, so that Rodauth
|
22
|
+
can make sure the access token matches the refresh token.
|
23
|
+
|
24
|
+
= Other Improvements
|
25
|
+
|
26
|
+
* The javascript for setting up a WebAuthn token has been fixed to
|
27
|
+
allow it to work correctly if there is already an existing
|
28
|
+
WebAuthn token for the account.
|
29
|
+
|
30
|
+
* The rodauth.setup_account_verification method has been promoted to
|
31
|
+
public API. You can use this method for automatically sending
|
32
|
+
account verification emails when automatically creating accounts.
|
33
|
+
|
34
|
+
* Rodauth no longer loads the same feature multiple times into a
|
35
|
+
single configuration. This didn't cause any problems before, but
|
36
|
+
could result in duplicate entries when looking at the loaded
|
37
|
+
features.
|