diff --git a/config/settings/prod.py b/config/settings/prod.py index 91ea2b5..fad001c 100644 --- a/config/settings/prod.py +++ b/config/settings/prod.py @@ -1,8 +1,22 @@ +from django.core.exceptions import ImproperlyConfigured + from .base import * # noqa: F403 -from .base import env +from .base import SECRET_KEY, env DEBUG = False +# base.py falls back to a publicly known placeholder if SECRET_KEY isn't +# set — fine for a throwaway dev DB, but production must never sign +# sessions/CSRF tokens with a key anyone can read in this repo's history. +# Fail startup rather than quietly running with a known key. +if not SECRET_KEY or SECRET_KEY == "django-insecure-change-me-in-production": + raise ImproperlyConfigured( + "SECRET_KEY is missing or still the placeholder default. Set a unique, " + "random SECRET_KEY in .env before running with prod settings — generate " + 'one with: python -c "from django.core.management.utils import ' + 'get_random_secret_key; print(get_random_secret_key())"' + ) + # Health checks (scripts/upgrade.sh, an external uptime monitor, ...) hit # gunicorn directly over loopback, bypassing the reverse proxy entirely — # that request's Host header is "127.0.0.1:", not the public domain