Add AccountsJS configurations as env vars
Impact: minor Type: feature
Issue
Developers can't customize the JWT access and refresh tokens' expiration date. Also, there is no way to configure whether the reset password mutation returns new auth tokens or not.
Solution
This PR adds environmental variables that allow to configure the aforementioned accounts js server properties, i.e. the jwt access and refresh token expiration time and the password reset mutation return type.
Breaking changes
None. The default values of the env vars are identical to the accounts js library default values.
Testing
Testing the password reset returned tokens:
- Set the
ACCOUNTS_JS_RETURN_TOKENS_AFTER_RESET_PASSWORDenv var totrue. - Run the password reset workflow and run the
resetPasswordmutation with thetokensin the return body like so:
mutation resetPassword($token: String!, $newPassword: String!) {
resetPassword(token: $token, newPassword: $newPassword) {
tokens {
accessToken
refreshToken
}
}
}
If the env var is set to true, you should see the newly generated access and refresh tokens in the response
If the env var is set to false, you should see null in the response
Testing the jwt token expiration time:
- Set the
ACCOUNTS_JS_ACCESS_TOKEN_EXPIRES_INto7dfor example - Authenitcate with the
authenticatemutation or with the Kinetic Admin - Overserve the generated jwt token expiration date after you decoded it:
🦋 Changeset detected
Latest commit: 82f2d5fea1dfbb9f62efaa97d356a5214dabf763
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 2 packages
| Name | Type |
|---|---|
| @reactioncommerce/api-plugin-authentication | Minor |
| reaction | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR