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

Add JSON web token ID claim #69

Closed ashokdelphia closed 4 years ago

ashokdelphia commented 4 years ago

I considered doing this with a custom payload handler, but it's not really possible to get the link back to the original token ID that way, so I can add an identifier, but I can't see a good way to preserve the relationship to the original token.

I'm hoping it's reasonable to always add this, rather than making it configurable, but please let me know if you'd like it to be optional. We could also allow someone to configure their own function for creating an identifier, but I chose to make it a random UUID4 for starters, which I believe satisfies the spec's requirement for a "negligible probability" of colliding identifiers.

I'd like to build on this later by strengthening the 'blacklist' check to disallow the whole (potentially branching) chain of tokens, rather than just the current token at the time the user invalidates their token. But I think this is still useful to ship independently.

I have two use cases this will help me solve:

(I'll add release notes if the basic approach here seems acceptable.)

ashokdelphia commented 4 years ago

As to the functionality, I'd be happy to merge it if you're done making changes to this PR.

I'm done making changes. I've guessed at the right version this will ship in. Please let me know if you'd like me to adjust anything else before this merges.

fitodic commented 4 years ago

@ashokdelphia and @nigoroll, thank you both for your contributions. It has been released in 1.17.0.

ashokdelphia commented 4 years ago

@fitodic: Much appreciated. Thanks for merging & releasing this and #72.