-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix user_id type mismatch when user claim is not pk #851
Fix user_id type mismatch when user claim is not pk #851
Conversation
token.blacklist() | ||
outstanding_token = OutstandingToken.objects.get(token=token) | ||
self.assertEqual(outstanding_token.user, self.user) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please also add a test which will ensure that the User.DoesNotExist
error is properly handled when the user does not exist anymore?
E.g:
- create the token,
- delete
self.user
object withself.user.delete()
- call
token.blacklist()
- assert that there is a BlacklistedToken record
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, sorry I just saw your review just now. I'll get on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've added that test.
Hi, When can we expect this to be merged ? |
Regarding changes made at https://github.com/jazzband/djangorestframework-simplejwt/pull/806/files We're using a USER_ID_CLAIM that is neither the primary key field nor is it the same type as the primary key, and these previous changes fail at this point when attempting to create an OutstandingToken, because it assumes that the ID pulled out of the token claims is usable as the database key for a user. So to mitigate this gets the user from the database using the USER_ID_FIELD setting and uses that in the get_or_create call. Also include a test of handling the case where the user is deleted when the token is blacklisted.
834a89d
to
49b84ed
Compare
for more information, see https://pre-commit.ci
Regarding changes made at https://github.com/jazzband/djangorestframework-simplejwt/pull/806/files
We're using a USER_ID_CLAIM that is neither the primary key field nor is it the
same type as the primary key, (tests are using the email column but we use a
UUID column secondary key) and these previous changes fail at this point when
attempting to create an OutstandingToken, because it assumes that the ID pulled
out of the token claims is usable as the database key for a user.
So to mitigate this gets the user from the database using the USER_ID_FIELD
setting and uses that in the get_or_create call.