From 639166cde38f6244c20c76dd711f033770ea9a5d Mon Sep 17 00:00:00 2001 From: Liam Keegan Date: Mon, 13 Jan 2025 14:41:19 +0100 Subject: [PATCH] Fix issue with pyJWT2.10 - sub must now be a string, in our case this was an int (the user id) - simple fix is to cast to a string for the token, and cast back to int when the token is decoded --- backend/src/sample_flow_server/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/sample_flow_server/app.py b/backend/src/sample_flow_server/app.py index faf2895..60c41c4 100644 --- a/backend/src/sample_flow_server/app.py +++ b/backend/src/sample_flow_server/app.py @@ -62,12 +62,12 @@ def create_app(data_path: str = "/sample_flow_data"): # https://flask-jwt-extended.readthedocs.io/en/stable/api/#flask_jwt_extended.JWTManager.user_identity_loader @jwt.user_identity_loader def user_identity_lookup(user): - return user.id + return str(user.id) # https://flask-jwt-extended.readthedocs.io/en/stable/api/#flask_jwt_extended.JWTManager.user_lookup_loader @jwt.user_lookup_loader def user_lookup_callback(_jwt_header, jwt_data): - identity = jwt_data["sub"] + identity = int(jwt_data["sub"]) return db.session.execute( db.select(User).filter(User.id == identity) ).scalar_one_or_none()