Skip to content

Commit

Permalink
Add cleartokens cronjob to clear expired tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
thenav56 committed Jan 16, 2025
1 parent 7feb733 commit 0e829a7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions api/management/commands/oauth_cleartokens.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.core import management
from django.core.management.base import BaseCommand
from sentry_sdk.crons import monitor

from main.sentry import SentryMonitor


class Command(BaseCommand):
help = "A wrapper for cleartokens command to track using sentry cron monitor. Feel free to use cleartokens"

@monitor(monitor_slug=SentryMonitor.OAUTH_CLEARTOKENS)
def handle(self, *args, **kwargs):
management.call_command("cleartokens")
3 changes: 3 additions & 0 deletions deploy/helm/ifrcgo-helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ cronjobs:
schedule: '0 3 * * 0'
- command: 'notify_validators'
schedule: '0 0 * * *'
# https://github.com/jazzband/django-oauth-toolkit/blob/master/docs/management_commands.rst#cleartokens
- command: 'oauth_cleartokens'
schedule: '0 1 * * *'


elasticsearch:
Expand Down
1 change: 1 addition & 0 deletions main/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class SentryMonitor(models.TextChoices):
INGEST_NS_INITIATIVES = "ingest_ns_initiatives", "0 0 * * 0"
INGEST_ICRC = "ingest_icrc", "0 3 * * 0"
NOTIFY_VALIDATORS = "notify_validators", "0 0 * * *"
OAUTH_CLEARTOKENS = "oauth_cleartokens", "0 1 * * *"

@staticmethod
def load_cron_data() -> typing.List[typing.Tuple[str, str]]:
Expand Down

0 comments on commit 0e829a7

Please sign in to comment.