Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stores tokens in Redis #38

Merged
merged 8 commits into from
Oct 24, 2023
Merged

Conversation

simonbs
Copy link
Contributor

@simonbs simonbs commented Oct 23, 2023

This PR rewrites our authentication logic to store access tokens and refresh tokens in Redis.

The motivation is to make way fewer calls to Auth0's Management API which has strict rate limits. Previously we would make a call to the Management API every time we needed the GitHub access token as it was not stored locally. Now we only call the Management API when the user logs in.

As a great side effect the portal has now become slightly faster as it makes fewer network calls.

The flow when logging in is now as follows:

  1. Catch the call to /api/auth/callback to exchange Auth0's access token and refresh token for authentication with GitHub for tokens we own.
  2. Store the newly created GitHub tokens in Redis.
  3. Use the tokens in Redis going forward.

When using the tokens we rely on the expiry dates to determine if we should renew the tokens or now. At this point we do not invoke the Github API with credentials and examine the response to determine if we should refresh the credentials. This was left out as I'm unsure it's needed when we can rely on expiry dates. If the user have revoked the tokens there is nothing we can do anyway to renew them.

@simonbs simonbs self-assigned this Oct 23, 2023
@simonbs simonbs merged commit 02217db into develop Oct 24, 2023
@simonbs simonbs deleted the enhancement/stores-tokens-in-redis branch October 24, 2023 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant