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

add redis and sidekiq to clean up expired blacklisted jwt #171

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

chris-t-li
Copy link
Collaborator

This addresses Issue #149

  1. Add gems: sidekiq and sidekiq-cron;
  2. Create sidekiq_cron.rb that specifies when and what task shall be run;
  3. Create cleanup_expired_jwt_job.rb that provies the function for deleting blacklisted expired JWT;
  4. Update docker-compose.yaml to add redis and sidekiq services

To test;

  1. Uncomment Line 4 of cleanup_expired_jwt.rb and comment out Line 3. (This changes the timing of the background task to run every minute rather than every day. This is just for testing purposes. After test. Reverse this step).

  2. Rebuild application given changes to gemfile and docker compose file;

docker-compose up --build
  1. Console should show 5 services: db, api, client, redis and sidekiq;
  2. In a new terminal, run
docker compose run api rails console
BlacklistedToken.all

This should show a list of all blacklisted tokens.
5. Navigate to localhost:4000. Login as any user and then logout (to create the blacklisted token).
6. In the rails console, run BlacklistedToken.all again. You should see 2 new instances that were created by logging out in step 4.
7. Wait ~ 1 minute then check the docker terminal. You should see something like this:

Screen Shot 2023-06-06 at 5 42 48 PM

  1. In the rails console, run BlacklistedToken.all again. You should see the two instances have been deleted:

Screen Shot 2023-06-06 at 5 44 48 PM

  1. After testing is complete. Reverse step 1 by commenting out Line 4 of cleanup_expired_jwt.rb and uncomment Line 3.

Note: have only tested this in localhost and dev environment. Will test in production next.

@chris-t-li chris-t-li added bug Something isn't working functionality authentication Related to user authentication on client and api labels Jun 6, 2023
@chris-t-li chris-t-li self-assigned this Jun 6, 2023
@netlify
Copy link

netlify bot commented Jun 6, 2023

Deploy Preview for fantasyfit canceled.

Name Link
🔨 Latest commit 6724455
🔍 Latest deploy log https://app.netlify.com/sites/fantasyfit/deploys/647fd2ba605fc5000836b56d

@chris-t-li chris-t-li changed the title add redis and sidekiq to clean up expired jwt add redis and sidekiq to clean up expired blacklisted jwt Jun 6, 2023
@chris-t-li chris-t-li temporarily deployed to fantasyfit June 7, 2023 00:12 Inactive
@chris-t-li chris-t-li temporarily deployed to fantasyfit June 7, 2023 00:28 Inactive
@chris-t-li chris-t-li temporarily deployed to fantasyfit June 7, 2023 00:40 Inactive
@chris-t-li chris-t-li temporarily deployed to fantasyfit June 7, 2023 00:44 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authentication Related to user authentication on client and api bug Something isn't working functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants