add new endpoints for app v2 #116
2 changed files with 16 additions and 0 deletions
|
|
@ -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():
|
||||||
|
|
|
||||||
15
bumper/db.py
15
bumper/db.py
|
|
@ -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:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue