Skip to content
This repository was archived by the owner on May 26, 2020. It is now read-only.
This repository was archived by the owner on May 26, 2020. It is now read-only.

Add support for jti claim #89

Open
@avimeir

Description

@avimeir

Hi all,

I'd like to add the support for jti claim to the package. The idea basically would be to store a list of expired jti's somewhere on the server side, and allow to blacklist specific tokens.

The way I'm thinking about the implementation is:

  • Use pymongo to store the blacklist (rather than a django specific mongo package, makes our solution portable to vanilla python or other frameworks)
  • Generate a long enough jti claim that will have negligible probability of being produced twice before the first one expired (string of 20 random ascii_letters and digits maybe?)
  • Store the jti and the entire payload in mongodb, this will help us clean up the collection when a JWT is past the expiry date (so we don't grow the collection ad infinitum)
  • Add a flag in api_settings.JWT_ENABLE_BLACKLIST, if True we add the jti claim to the payload in jwt_payload_handler()
  • Check against the mongodb collection everytime we decode a JWT (if JWT_ENABLE_BLACKLIST is True) and if the jti is blacklisted treat it as if the JWT is expired

I have made an initial commit to a fork of the package, with my suggestion on how to implement this, you can find it here: https://github.com/avimeir/django-rest-framework-jwt/commits/master

Happy to discuss this!

Cheers,
Avi

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions