Skip to content

Commit 639166c

Browse files
committed
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
1 parent f346c9f commit 639166c

File tree

1 file changed

+2
-2
lines changed
  • backend/src/sample_flow_server

1 file changed

+2
-2
lines changed

backend/src/sample_flow_server/app.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ def create_app(data_path: str = "/sample_flow_data"):
6262
# https://flask-jwt-extended.readthedocs.io/en/stable/api/#flask_jwt_extended.JWTManager.user_identity_loader
6363
@jwt.user_identity_loader
6464
def user_identity_lookup(user):
65-
return user.id
65+
return str(user.id)
6666

6767
# https://flask-jwt-extended.readthedocs.io/en/stable/api/#flask_jwt_extended.JWTManager.user_lookup_loader
6868
@jwt.user_lookup_loader
6969
def user_lookup_callback(_jwt_header, jwt_data):
70-
identity = jwt_data["sub"]
70+
identity = int(jwt_data["sub"])
7171
return db.session.execute(
7272
db.select(User).filter(User.id == identity)
7373
).scalar_one_or_none()

0 commit comments

Comments
 (0)