fix: encode JWT expiry time as int, not float

fixes #46
This commit is contained in:
Stefan Stammberger 2021-11-22 20:44:14 +01:00
parent 7b94aac3d8
commit 63c52d2ba7
No known key found for this signature in database
GPG key ID: 645FA807E935D9D5

View file

@ -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)