3

Is there an easy way to configure or modify the Django Rest Framework JWT Auth library to refresh tokens based on user activity? Right now, a token generated will expire based on the value of JWT_EXPIRATION_DELTA (e.g. 1 day), but let's say that I'd like to expire the token 15 minutes after the last user action. Is this possible? According the docs, it doesn't seem like it.

Update:

Just for the record, I read this post and it sounds like what the best solution is, in the application, to just keep track of user activity on the one hand and the expiration of the token on the other. That way, when I have a timer that tries to refresh the token, it sees if the user has been inactive and then decides whether of not to refresh. But this seems like a sloppy solution. I was hoping to encapsulate all that on the server.

Community
  • 1
  • 1
daveslab
  • 10,000
  • 21
  • 60
  • 86
  • 1
    Why is it sloppy? What if the user spends more than 15 minutes admiring your well-crafted website, and never POSTs or GETs anything from the server? Only a local js-timer will be able to warn her. – bavaza Feb 08 '17 at 08:15

0 Answers0