Is there a way to configure Django Rest Framework

2019-06-27 20:04发布

问题:

Is there a way to configure Django Rest Framework to store token information in Redis rather than the Database ?

回答1:

You can create your own custom authentication backend which stores tokens in redis. From the documentation:

To implement a custom authentication scheme, subclass BaseAuthentication and override the .authenticate(self, request) method. The method should return a two-tuple of (user, auth) if authentication succeeds, or None otherwise.