Styria-Digital / django-rest-framework-jwt

JSON Web Token Authentication support for Django REST Framework
https://styria-digital.github.io/django-rest-framework-jwt/
MIT License
191 stars 57 forks source link

Improve logout security #84

Closed ashokdelphia closed 3 years ago

ashokdelphia commented 3 years ago

The overall aim here is to try to improve logout security in two ways:

My general preference would be to phase out support for JWT_TOKEN_ID='off', and start making require the default for new installations. That could substantially simplify matters here. It would take some more thought about how to do that and ensure that people upgrading had a graceful upgrade path, but I think it's something we could consider for a major version bump. In the meantime, I'd still like to stop storing whole token values (or emitting them in query logs) for a system that's using the require setting; this PR should allow that.

Apologies for making a relatively large PR; hopefully the individual commits are each relatively simple to review in turn.


ashokdelphia commented 3 years ago

I'm reasonably sure that the broken build is the same as on master, but haven't got all of the versions running locally in order to reproduce and try and fix it (in a separate PR).

ashokdelphia commented 3 years ago

@fitodic Sorry this is a fairly hefty change, so I appreciate it'll take longer to get to for review.

I'm pretty itchy about having almost-valid tokens hanging about in the database as it opens up a handful of potential security problems that would be best solved by never storing whole tokens.

If you'd like to discuss whether we should do that a different way, please let me know.

fitodic commented 3 years ago

@ashokdelphia Thanks for the hard work you've put into this and sorry for taking so long to answer.

I went through it change-by-change as you've described it and I have nothing to add or object. It's outstanding 👏🏼

As to setting the JWT_TOKEN_ID's default value to 'require', I agree that this would be a breaking change that could be shipped as a major version.

Regarding the failing test, that's my fault. I merged one PR too late, but I'll fix it as soon as I find the time.

I'll merge this and release a new minor version shortly.

ashokdelphia commented 3 years ago

I'll merge this and release a new minor version shortly.

@fitodic That's great. Thank you!