Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Fix: Always require a set, non-empty, not whitespace secret key, even in DEBUG (#12680)

Trenton H4a915f8e3adf
diff --git a/src/paperless/settings/__init__.py b/src/paperless/settings/__init__.py
index 95bbe46c5..db57173cd 100644
--- a/src/paperless/settings/__init__.py
+++ b/src/paperless/settings/__init__.py
@@ -464,8 +464,7 @@ SECURE_PROXY_SSL_HEADER = (
)
SECRET_KEY = os.getenv("PAPERLESS_SECRET_KEY")
-_INSECURE_SECRET_KEYS = {None, "", "change-me"}
-if not DEBUG and SECRET_KEY in _INSECURE_SECRET_KEYS: # pragma: no cover
+if not (SECRET_KEY or "").strip() or SECRET_KEY == "change-me": # pragma: no cover
raise ImproperlyConfigured(
"PAPERLESS_SECRET_KEY is not set or is the default 'change-me' value. "
"A unique, secret key is required for secure operation. "