Skip to content

Commit

Permalink
Add token expired response
Browse files Browse the repository at this point in the history
  • Loading branch information
radupotop committed Apr 15, 2024
1 parent b22ae62 commit d27d8c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/api/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def bad_token():
return build_response('"Could not verify access token."', code=hs.FORBIDDEN)


def expired_token():
return build_response('"Token has expired."', code=hs.FORBIDDEN)


@Request.application
def application(request):
"""
Expand Down Expand Up @@ -56,7 +60,7 @@ def application(request):
log.warning('Token expired: %s', token)
# Try to cleanup iptables
ipt.delete_rule(src_ip)
return bad_token()
return expired_token()
else:
log.warning('Invalid Token: %s', token)
return bad_token()
2 changes: 1 addition & 1 deletion app/cli/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# ADD
if args.maincmd == 'add':
ret = storage.add_token(args.expires_days, args.reason)
log.info('Added token %s, expires=%s', *ret)
log.info('Added token %s expires=%s', *ret)
# CHECK
if args.maincmd == 'check':
tok = storage.get_token(args.uuid)
Expand Down

0 comments on commit d27d8c4

Please sign in to comment.