fix: Drop expiry from internal only JWT #4207
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's the problem?
Internal requests from the API to Hasura are failing due to expired JWTs. See recent failures in the
#planx-notifications-internal
Slack channel (OSL).This is happening as the
$api
client is a singleton, generated once, along with its associated JWT. Calls made by users via the API pass along their JWTs, generated at login, along with their associated roles. The internal JWT used by the API to access Haura is used for various cron jobs, admin endpoints, and other utilities.Some cron processes are passing as their rely on the admin secret and not the JWT.
We haven't hit this (at time of writing) on staging or production as it's not yet been 24hrs since a deploy.
What's the solution?
Remove the expiry on internal-only JWTs. This isn't actually required and it's only needed for user instantiated requests.
We could (should?) implement a process where this token is still time-limited, but can be automatically refreshed when expired. I'm just opting for a simple and pragmatic roll-back here just now.