From d27d8c4cfaee8aada82d5c72acfec28b75792285 Mon Sep 17 00:00:00 2001 From: Radu Potop Date: Mon, 15 Apr 2024 22:17:35 +0100 Subject: [PATCH] Add token expired response --- app/api/web.py | 6 +++++- app/cli/tokens.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/api/web.py b/app/api/web.py index bcedf76..175389e 100644 --- a/app/api/web.py +++ b/app/api/web.py @@ -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): """ @@ -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() diff --git a/app/cli/tokens.py b/app/cli/tokens.py index b0d0403..ff5870c 100644 --- a/app/cli/tokens.py +++ b/app/cli/tokens.py @@ -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)