diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-03-17 16:03:02 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2023-03-17 16:03:02 +0100 |
commit | 66c343421980b5ce301eaa202d5090d6f45833ab (patch) | |
tree | 80146022464b7c45cd19f5827664250b55ec0ff1 /example_project/settings.py | |
parent | 63c96b0484661419c30a830e2d7ab52c209cf0f0 (diff) | |
download | Ishtar-66c343421980b5ce301eaa202d5090d6f45833ab.tar.bz2 Ishtar-66c343421980b5ce301eaa202d5090d6f45833ab.zip |
settings: add "ISHTAR_SECURE_OPTIONS" to activate Django secured options
Diffstat (limited to 'example_project/settings.py')
-rw-r--r-- | example_project/settings.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/example_project/settings.py b/example_project/settings.py index 8248b6713..cd0d51557 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Django settings for ishtar project. @@ -291,6 +291,7 @@ ISHTAR_DOC_TYPES = {"undefined": "Undefined"} ISHTAR_SEARCH_LANGUAGE = "french" ISHTAR_SECURE = True +ISHTAR_SECURE_OPTIONS = False ISHTAR_DPTS = [] MAX_ATTEMPTS = 1 # django background tasks @@ -442,3 +443,18 @@ if SENTRY_ID and sentry_sdk: send_default_pii=True, release=get_version() + "-" + EXTRA_VERSION ) + + +if ISHTAR_SECURE_OPTIONS: + # verify https is ok before activating + SESSION_COOKIE_SECURE = True + MIDDLEWARE += [ + "django.middleware.security.SecurityMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", + ] + SECURE_HSTS_SECONDS = 31536000 + SECURE_CONTENT_TYPE_NOSNIFF = True + SECURE_BROWSER_XSS_FILTER = True + SECURE_SSL_REDIRECT = True + CSRF_COOKIE_SECURE = True + X_FRAME_OPTIONS = "DENY" |