📝 JWT token blacklist app: design conditional apps (#462)
We need to design how we can add conditional django apps that have models to the framework.
For example, right now we can add an app to blacklist some jwt tokens.
What's interesting about that?
1. We need to design this app in a way that it is not required by default, with no visible parts
2. We need to design it that it will be very easy to install and use. For example: it should provide a mixin class that can be used together with
JWTSyncAuth / JWTAsyncAuth and a pre-existing common subclassSo, usage will look something like:
from django_modern_rest.some.place.for.app.models import BlacklistedJWTToken
class BlacklistMixin:
def check_auth(self, user: 'AbstractBaseUser', token: JWTToken) -> None:
super().check_user()
if BlacklistedJWTToken.objects.filter(jti=token.jti).exists():
# Token was blacklisted:
raise NotAuthenticatedError
We use
jti to identify tokens, as other jwt's do.It is now possible after #461
Sources of inspiration:
• https://github.com/jazzband/djangorestframework-simplejwt/blob/master/rest_framework_simplejwt/token_blacklist/models.py
• https://django-rest-framework-simplejwt.readthedocs.io/en/latest/blacklist_app.html
#enhancement #good_first_issue #help_wanted #django_modern_rest
sent via relator