I'd like to revoke the prior token each time a user logs in. That would mean generating a new token (or at least changing the key of existing model entity). It all sounds straightforward, but in the DRF docs, I don't see any mention of that scenario. The docs seem to assume that the token always stays the same. Is that just a simple case, or am I missing something? My question is: Is there something wrong with changing the token each time a user logs in?
相关问题
- Django Attribute error 'datetime.timedelta'
- Uploading multiples image with Django Rest Framewo
- How do I mock a third party library inside a Djang
- Django serializers vs rest_framework serializers
- Django Rest Framework does not show content from S
相关文章
- Serialise choice text for IntegerField with choice
- Django Rest Framework custom response message
- Django REST Framework - OAuth2 Consumer API from e
- Django Rest Framework Without Database
- Django Rest Framework - AssertionError Fix your UR
- Django rest framework nested viewsets and routes
- How can I use pagination_class in django-rest-fram
- How would I override the perform_destroy method in
The
TokenAuthentication
provided by Django REST Framework is intended to be used for simple cases where the token never needs to change, and there is only a single token for a user.This is correct. Anything extra has to be implemented independently.
You can do this in the authentication view by removing any tokens for the user who is logged in.
If you are using the views provided for token authentication, then you will need to subclass them to always get a new token for the user.
This will always invalidate the previous key and generate a new key.