diff --git a/coldbrew/settings.py b/coldbrew/settings.py index fd7b7c1..bbc27d3 100644 --- a/coldbrew/settings.py +++ b/coldbrew/settings.py @@ -23,15 +23,18 @@ BASE_DIR = Path(__file__).resolve().parent.parent ASK = AutoSecretKey("settings.ini") SECRET_KEY = ASK.secret_key CONFIG = ASK.config -DEBUG = CONFIG.getboolean("ColdBrew", "Debug", fallback=False) -if not (FIELD_ENCRYPTION_KEY := CONFIG.get("ColdBrew", "EncryptionKey")): - FIELD_ENCRYPTION_KEY = base64.urlsafe_b64encode(os.urandom(32)) +if "ColdBrew" not in CONFIG: + CONFIG["ColdBrew"] = {} + +if not (FIELD_ENCRYPTION_KEY := CONFIG.get("ColdBrew", "EncryptionKey", fallback=None)): + FIELD_ENCRYPTION_KEY = base64.urlsafe_b64encode(os.urandom(32)).decode() CONFIG["ColdBrew"]["EncryptionKey"] = FIELD_ENCRYPTION_KEY ASK.write() -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = CONFIG.get("ColdBrew", "AllowedHosts", fallback="*").split(",") +DEBUG = CONFIG.getboolean("ColdBrew", "Debug", fallback=False) if ALLOWED_HOSTS else True # Application definition