Add a worker to automatically GC expired app specific tokens

Fixes https://jira.coreos.com/browse/QUAY-822
This commit is contained in:
Joseph Schorr 2018-02-12 14:56:01 -05:00
parent 06d25816be
commit d45161b120
7 changed files with 77 additions and 5 deletions

View file

@ -63,11 +63,11 @@ def get_expiring_tokens(user, soon):
AppSpecificAuthToken.expiration <= soon_datetime))
def gc_expired_tokens(user):
""" Deletes all expired tokens owned by the given user. """
def gc_expired_tokens(expiration_window):
""" Deletes all expired tokens outside of the expiration window. """
(AppSpecificAuthToken
.delete()
.where(AppSpecificAuthToken.user == user, AppSpecificAuthToken.expiration < datetime.now())
.where(AppSpecificAuthToken.expiration < (datetime.now() - expiration_window))
.execute())