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

Allow integration with django-csp #157

Closed prauscher closed 5 months ago

prauscher commented 5 months ago

django-csp allows setting of Content-Security-Policy-Headers, which aim to improve Web-Security. This includes executing only safe javascript / css-settings, which are identified by policies such as script-src or style-src. More information about CSP can be found at https://content-security-policy.com/

As django-session-security includes a template, both style-src (for the display:none of the overlay) and script-src (for the inline JavaScript enabling sessionSecurity.

My suggestion would be:

  1. Move display:none; to the static CSS-File - changes in this property directly on the DOM via JS would superseed this anyway
  2. Support using request.nonce for the inline-script

In the meantime, the issue can be circumvented by adding 'unsafe-inline' to CSP_SCRIPT_SRC and CSP_STYLE_SRC, but this should not be considered a fix due to the lack of security (unsafe- is meant that way).