reaction icon indicating copy to clipboard operation
reaction copied to clipboard

Add AccountsJS configurations as env vars

Open tedraykov opened this issue 2 years ago • 1 comments

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:

  1. Set the ACCOUNTS_JS_RETURN_TOKENS_AFTER_RESET_PASSWORD env var to true.
  2. Run the password reset workflow and run the resetPassword mutation with the tokens in 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:

  1. Set the ACCOUNTS_JS_ACCESS_TOKEN_EXPIRES_IN to 7d for example
  2. Authenitcate with the authenticate mutation or with the Kinetic Admin
  3. Overserve the generated jwt token expiration date after you decoded it: Screenshot 2023-05-19 at 11 51 16 Screenshot 2023-05-19 at 11 51 26

tedraykov avatar May 19 '23 08:05 tedraykov

🦋 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

changeset-bot[bot] avatar May 19 '23 08:05 changeset-bot[bot]