Skip to content

Commit

Permalink
Fix issue with pyJWT2.10
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
lkeegan committed Jan 13, 2025
1 parent f346c9f commit 639166c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/src/sample_flow_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 639166c

Please sign in to comment.