From 420075af15f4a06b915705c28cdf4b31720c4483 Mon Sep 17 00:00:00 2001 From: Adrian Coveney Date: Wed, 4 Dec 2024 10:33:31 +0000 Subject: [PATCH 1/2] Change DEBUG to False --- monitoring/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitoring/settings.py b/monitoring/settings.py index 29dd4b6..724f7d9 100644 --- a/monitoring/settings.py +++ b/monitoring/settings.py @@ -24,7 +24,7 @@ SECRET_KEY = 'ge^fd9rf)htmxji8kf=jk8frh3=^11@^n=h14gu*fqt^0-lnr$' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False try: From 64d78718f26d355ee076cadade54773213bf4c22 Mon Sep 17 00:00:00 2001 From: Adrian Coveney Date: Wed, 4 Dec 2024 10:34:21 +0000 Subject: [PATCH 2/2] Move SECRET_KEY to settings.ini for config man Move SECRET_KEY to be set from settings.ini so that configuration managment can set it from a secrets file. Also update link to docs for deployment checklist. --- monitoring/settings.ini | 3 +++ monitoring/settings.py | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/monitoring/settings.ini b/monitoring/settings.ini index 33ac1ba..222b25c 100644 --- a/monitoring/settings.ini +++ b/monitoring/settings.ini @@ -1,6 +1,9 @@ # This file will be parsed by settings.py. [common] +# A new key can be generated using django.core.management.utils.get_random_secret_key() +secret_key = + # `allowed_hosts` values should be comma separated list of hostnames (fqdn's) allowed_hosts = diff --git a/monitoring/settings.py b/monitoring/settings.py index 724f7d9..fcd1764 100644 --- a/monitoring/settings.py +++ b/monitoring/settings.py @@ -18,10 +18,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'ge^fd9rf)htmxji8kf=jk8frh3=^11@^n=h14gu*fqt^0-lnr$' +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False @@ -33,6 +30,9 @@ file_path = os.path.join(BASE_DIR, 'monitoring', 'settings.ini') cp.read(file_path) + # SECURITY WARNING: keep the secret key used in production secret! + SECRET_KEY = cp.get('common', 'secret_key') + ALLOWED_HOSTS = cp.get('common', 'allowed_hosts').split(',') # Database