add revoke expired oauths

This commit is contained in:
Robert Resch 2021-04-19 21:04:14 +02:00
parent c9257f3fdf
commit a5359ac4c6
No known key found for this signature in database
GPG key ID: 6B360759EB2ACAEE
2 changed files with 16 additions and 0 deletions

View file

@ -265,6 +265,7 @@ async def start():
async def maintenance(): async def maintenance():
revoke_expired_tokens() revoke_expired_tokens()
revoke_expired_oauths()
async def shutdown(): async def shutdown():

View file

@ -203,6 +203,21 @@ def user_revoke_authcode(userid, token, authcode):
) )
def revoke_expired_oauths():
opendb = db_get()
with opendb:
table = opendb.table("oauth")
entries = table.all()
for i in entries:
oauth = OAuth(**i)
if datetime.now() >= datetime.fromisoformat(oauth.expire_at):
bumperlog.debug(
"Removing oauth {} due to expiration".format(oauth.access_token)
)
table.remove(doc_ids=[i.doc_id])
def user_revoke_expired_oauths(userid): def user_revoke_expired_oauths(userid):
opendb = db_get() opendb = db_get()
with opendb: with opendb: