I have an app which uses Django DRF with simple AuthToken, Postgres for database and Redis for caching.
I am trying to reduce the number of calls to my DB and one of most common action is SELECT on AuthToken table. In fact, it needs to be called for every request on a protected endpoint to verify the permission of the user.
We could reduce the number of calls to our DB by caching the token of users in Redis as {user_id: token}
.
Assuming we set a decent expiration for the key and that we invalidate it in case of revoked token AuthToken, is caching the auth token an anti-pattern? Is there any security issue I should be concerned about?