Skip to main content
https://secure.travis-ci.org/yourlabs/django-session-security.png?branch=master

This app provides a mechanism to logout inactive authenticated users. An inactive browser should be logged out automatically if the user left his workstation, to protect sensitive data that may be displayed in the browser. It may be useful for CRMs, intranets, and such projects.

For example, if the user leaves for a coffee break, this app can force logout after say 5 minutes of inactivity.

Why not just set the session to expire after X minutes ?

Or “Why does this app even exist” ? Here are the reasons:

  • if the user session expires before the user is done reading a page: he will have to login again.

  • if the user session expires before the user is done filling a form: his work will be lost, and he will have to login again, and probably yell at you, dear django dev … at least I know I would !

This app allows to short circuit those limitations in session expiry.

How does it work ?

When the user loads a page, SessionSecurity middleware will set the last activity to now. The last activity is stored as datetime in request.session['_session_security']. To avoid having the middleware update that last activity datetime for a URL, add the url to settings.SESSION_SECURITY_PASSIVE_URLS.

When the user moves mouse, click, scroll or press a key, SessionSecurity will save the DateTime as a JavaScript attribute. It will send the number of seconds since when the last user activity was recorded to PingView, next time it should ping.

First, a warning should be shown after settings.SESSION_SECURITY_WARN_AFTER seconds. The warning displays a text like “Your session is about to expire, move the mouse to extend it”.

Before displaying this warning, SessionSecurity will upload the time since the last client-side activity was recorded. The middleware will take it if it is shorter than what it already has - ie. another more recent activity was detected in another browser tab. The PingView will respond with the number of seconds since the last activity - all browser tab included.

If there was no other, more recent, activity recorded by the server: it will show the warning. Otherwise it will update the last activity in javascript from the PingView response.

Same goes to expire after settings.SESSION_SECURITY_EXPIRE_AFTER seconds. Javascript will first make an ajax request to PingView to ensure that another more recent activity was not detected anywhere else - in any other browser tab.

Requirements

  • Python 2.7 or 3

  • jQuery 1.7+

  • Django 1.4+

  • django.contrib.staticfiles or django-staticfiles (included in Pinax) or you’re on your own

Resources

You could subscribe to the mailing list ask questions or just be informed of package updates.

Release files for django-session-security 2.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-session-security 2.2.4
File Size Uploaded
django-session-security-2.2.4.tar.gz 14.3 kB Details

Release files / django-session-security-2.2.4.tar.gz

Download URL django-session-security-2.2.4.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e1ab68ed760dea8125620cef286a5535ccfedb98e908a12b22fd49f0b1485547
BLAKE2b-256 checksum
How to use checksums
9d63b648456602ad7045ce221bed95976c1f101aa9fb511ea356b12753786e9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

2.6.8

2 release files

2.6.7

2 release files

2.6.6

1 release file

2.6.5

1 release file

2.6.3

1 release file

2.6.2

1 release file

2.6.1

1 release file

2.6.0

1 release file

2.5.1

1 release file

2.5.0

1 release file

2.4.1

1 release file

2.4.0

1 release file

2.3.2

1 release file

2.3.1

1 release file

2.3.0

1 release file

This release

2.2.4 This release

1 release file

2.2.3

1 release file

2.2.2

1 release file

2.2.1

1 release file

2.2.0

1 release file

2.1.7

1 release file

2.1.6

1 release file

2.1.5

1 release file

2.1.2

1 release file

2.1.1

1 release file

2.1.0

1 release file

2.0.6

1 release file

2.0.5

1 release file

2.0.4

1 release file

2.0.3

1 release file

2.0.2

1 release file

2.0.0

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page