security: add ENFORCE_PRODUCTION

can provide a safety check so debug mode never gets enabled on production environments by accident
This commit is contained in:
justcool393 2022-11-20 09:50:01 -06:00 committed by Ben Rog-Wilhelm
parent 0db174b90b
commit 86c0eea85a
2 changed files with 4 additions and 0 deletions

View file

@ -27,6 +27,9 @@ app.jinja_env.cache = {}
app.jinja_env.auto_reload = True
faulthandler.enable()
if environ.get("ENFORCE_PRODUCTION", False) and app.config["DEBUG"]:
raise ValueError("Debug mode is not allowed! If this is a dev environment, please set ENFORCE_PRODUCTION to false")
if environ.get("SITE_ID") is None:
from dotenv import load_dotenv
load_dotenv(dotenv_path=Path("env"))