-
-
Notifications
You must be signed in to change notification settings - Fork 245
Description
Recently the version of the PyJWT dependency was upgraded to 2.10.0, which adds new token verification behavior. In this version PyJWT enforces that the sub
claim in the JWT be a string, and deems the token invalid if that verification fails (by default). This issue in PyJWT has a discussion about the change, and ways to work around it: jpadilla/pyjwt#1017
I have only just now become am aware that in the JWT spec the sub
claim is indeed supposed to be a string, and have been using an integer in that field for a long time. This upgrade naturally has caught me out, since any tokens I issue in this way are now deemed invalid and result in a rejection. I don't believe I am alone in this situation, as multiple people piled onto the aforementioned Github issue being caught by the change.
To rectify the situation, it's clear that my application should start using strings for our sub
claim. Unfortunately though, we can't simply make a hard cut over. We need preexisting tokens which haven't expired to continue to be valid. This means we need to be able to verify and parse older tokens that will have sub
as an int
. Right now, I'm not seeing any way to accomplish this besides pinning PyJWT to 2.9.0.
The recommended way (from PyJWT contributors) to navigate this seems to be specifying verify_sub=False
as an option to their jwt.decode
function per this comment. As a user of flask-jwt-extended, the high level functions verify_jwt_in_request
and jwt_required
don't seem to provide any way in the current API to control options like verify_sub
(or any other low level options) in the underlying calls to PyJWT.
I took a look at the code, and I can see many possible avenues for adding such functionality (if desired). Before putting together a PR or anything, I figured I'd first ask:
- If this functionality is something you'd be interested in having or not
- If you have opinions on exactly how this kind of thing should be implemented if it were to exist.
Let me know what you think, thanks in advance for the feedback!