settings.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """
  2. sudo.settings
  3. ~~~~~~~~~~~~~
  4. :copyright: (c) 2020 by Matt Robenolt.
  5. :license: BSD, see LICENSE for more details.
  6. """
  7. from django.conf import settings
  8. # Default url to be redirected to after elevating permissions
  9. REDIRECT_URL = getattr(settings, "SUDO_REDIRECT_URL", "/")
  10. # The querystring argument to be used for redirection
  11. REDIRECT_FIELD_NAME = getattr(settings, "SUDO_REDIRECT_FIELD_NAME", "next")
  12. # How long should sudo mode be active for? Duration in seconds.
  13. COOKIE_AGE = getattr(settings, "SUDO_COOKIE_AGE", 10800)
  14. # The domain to bind the sudo cookie to. Default to the current domain.
  15. COOKIE_DOMAIN = getattr(settings, "SUDO_COOKIE_DOMAIN", settings.SESSION_COOKIE_DOMAIN)
  16. # Should the cookie only be accessible via http requests?
  17. # Note: If this is set to False, any JavaScript files have the ability to access
  18. # this cookie, so this should only be changed if you have a good reason to do so.
  19. COOKIE_HTTPONLY = getattr(settings, "SUDO_COOKIE_HTTPONLY", True)
  20. # The name of the cookie to be used for sudo mode.
  21. COOKIE_NAME = getattr(settings, "SUDO_COOKIE_NAME", "sudo")
  22. # Restrict the sudo cookie to a specific path.
  23. COOKIE_PATH = getattr(settings, "SUDO_COOKIE_PATH", "/")
  24. # Only transmit the sudo cookie over https if True.
  25. # By default, this will match the current protocol. If your site is
  26. # https already, this will be True.
  27. COOKIE_SECURE = getattr(settings, "SUDO_COOKIE_SECURE", None)
  28. # An extra salt to be added into the cookie signature
  29. COOKIE_SALT = getattr(settings, "SUDO_COOKIE_SALT", "")
  30. # The name of the session attribute used to preserve the redirect destination
  31. # between the original page request and successful sudo login.
  32. REDIRECT_TO_FIELD_NAME = getattr(settings, "SUDO_REDIRECT_TO_FIELD_NAME", "sudo_redirect_to")
  33. # The url for the sudo page itself. May be a url or a view name
  34. URL = getattr(settings, "SUDO_URL", "sudo.views.sudo")