fix: support token blacklist feature in rest_auth#1392
fix: support token blacklist feature in rest_auth#1392bartvanandel wants to merge 2 commits intotfranzel:masterfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1392 +/- ##
=======================================
Coverage 98.58% 98.58%
=======================================
Files 76 76
Lines 9176 9191 +15
=======================================
+ Hits 9046 9061 +15
Misses 130 130 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c4a3456 to
af4d4d1
Compare
|
@tfranzel could you have a look, and enable the workflow that requires approval? |
|
Hi @bartvanandel, sry for the delay. Could you please rebase your change because the the GH worker image got retired and rescheduling the actions won't make use of the new one. |
ae1a062 to
fe3ce1e
Compare
|
@tfranzel Rebase done! |
|
Finally had some time to review. I think this looks good. However, I believe there is another conditional missing. Shouldn't this also be dependant on |
Add correct serializer when rest_framework_simplejwt.token_blacklist is detected, mirroring the approach taken by dj-rest-auth.
fe3ce1e to
e359755
Compare
|
Yeah probably a good idea. One can have Updated and rebased on top of current master. |
|
@tfranzel Anything else you want to change? Need more testing? |
|
Hey @bartvanandel sry for this delay, but I am finally catching up. Got 2 more issues left for a release. On revisiting this, I noticed another thing. I think its basically three conditions to end up with that POST body
Also your condition
I don't think that is correct. If we end up in the branch with those 3 conditions the 'refresh' field is mandatory, not optional. Otherwise it will just be ignored. you agree?
Afair there is not a direct way to turn it off, but if you have a serializer with zero required "write" fields, the whole payload becomes optional and that check turns it off then. So constructing the serializer in that way should remove drf-spectacular/drf_spectacular/openapi.py Line 1371 in 39cb3d5 |
|
Hi @tfranzel, We've moved on from Python to C# in the meantime, so I'm not actively using your project anymore. Having said that...
From what I remember, yes, it's a combination of settings. Mind you, since you took a while to respond, we were using a private fork to get around the issues we were experiencing. This PR is basically the code that we were using in production.
I'd have to retrace my steps to get the exact details, but I think I remember that with
I really can't remember the detail. This is just what I ran into, at the time, I did some research into the issue, and this is what I noticed.
I really can't remember, sorry. However, I'd be careful to consider 'zero required "write" fields' the same as Anyway, like I said, we have moved away. I guess it can still be beneficial to fix this issue, especially while other projects (not to mention Django itself) point to drf-spectacular as the go-to way for rendering OpenAPI specs. |
|
Thanks for getting back at me even though you moved on. Much appreciated. I wish you good luck with C# 😄
I guess so, but I don't think it matter much here. DRF might also accept closed by 5221afd |
Add correct serializer when
rest_framework_simplejwt.token_blacklistis detected, mirroring the approach taken by dj-rest-auth. This serializer currently requires the token to be sent along with the request.Note: the code in
dj-rest-authcurrently marks the body as optional, but:a) I could not find a way to specify that the request body is entirely optional in drf-spectacular (I think
drf-spectacularcurrently forcesrequired: truewhen the request body is notNone); andb)
dj-rest-authwill currently definitely fail anyway when theblacklistapp is enabled and/logoutis called without a proper body.We rely on a code generator to generate out front-end auth client. Without this patch, we can't use the
/logoutendpoint in that client.