yourlabs / django-session-security

A little javascript and middleware work together to ensure that the user was active during the past X minutes in any tab he has open. Otherwise, display a warning leaving a couple of minutes to show any kind of activity like moving the mouse. Otherwise, logout the user.
http://django-session-security.rtfd.org
MIT License
309 stars 142 forks source link

Move `user.is_authenticated` check to method so it can be overridden by subclasses #138

Closed theunraveler closed 5 months ago

theunraveler commented 4 years ago

Hello. I'm try to subclass the SessionSecurityMiddleware middleware so that I can use it on something other than users authenticated with Django's auth framework. Most of the logic in process_request still applies, but I'd have to copy all of that over to my subclassed middleware in order to bypass the is_authenticated check.

This PR moves that check into a method on the middleware class so subclasses can just override that if they want to handle authentication a little differently. It also does the same for the call to django.contrib.auth.logout for the same reason.

Thanks!