From 63c52d2ba708317c82da4f41341df8f040e4d687 Mon Sep 17 00:00:00 2001 From: Stefan Stammberger Date: Mon, 22 Nov 2021 20:44:14 +0100 Subject: [PATCH] fix: encode JWT expiry time as int, not float fixes #46 --- app/auth/auth_handler.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/auth/auth_handler.py b/app/auth/auth_handler.py index 402a033..386264c 100644 --- a/app/auth/auth_handler.py +++ b/app/auth/auth_handler.py @@ -6,11 +6,14 @@ from decouple import config JWT_SECRET = config("secret") JWT_ALGORITHM = config("algorithm") -JWT_EXPIRY_TIME = config("jwt_expiry_time", default=300.0, cast=float) +JWT_EXPIRY_TIME = config("jwt_expiry_time", default=300, cast=int) def signJWT() -> Dict[str, str]: - payload = {"user_id": "admin", "expires": time.time() + JWT_EXPIRY_TIME} + payload = { + "user_id": "admin", + "expires": int(round(time.time() * 1000) + JWT_EXPIRY_TIME), + } token = jwt.encode(payload, JWT_SECRET, algorithm=JWT_ALGORITHM) return token_response(token)