feat: export state corp exchange sections
All checks were successful
CI/CD Pipeline / Quality Gate (push) Successful in 30s
CI/CD Pipeline / Build and Push Images (push) Successful in 22s
CI/CD Pipeline / Internal Notify (push) Successful in 0s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Successful in 1s

This commit is contained in:
2026-05-27 23:13:40 +02:00
parent 76a99a4a1e
commit a5995e04b6
3 changed files with 293 additions and 9 deletions

View File

@@ -17,12 +17,21 @@ def _require_env(name: str) -> str:
return value
def _parse_allowed_hosts(raw_value: str) -> list[str]:
def _is_truthy_env(name: str) -> bool:
return os.getenv(name, "false").strip().lower() in {"1", "true", "yes", "on"}
def _parse_allowed_hosts(raw_value: str, *, allow_any_host: bool = False) -> list[str]:
hosts = [host.strip() for host in raw_value.split(",") if host.strip()]
if not hosts:
raise ImproperlyConfigured("ALLOWED_HOSTS must contain at least one host")
if "*" in hosts:
raise ImproperlyConfigured("ALLOWED_HOSTS must not contain '*' in production")
if allow_any_host:
return ["*"]
raise ImproperlyConfigured(
"ALLOWED_HOSTS must not contain '*' in production unless "
"ALLOW_ANY_HOSTS=true is set"
)
return hosts
@@ -30,7 +39,10 @@ SECRET_KEY = _require_env("SECRET_KEY")
DEBUG = os.getenv("DEBUG", "false").strip().lower() == "true"
if DEBUG:
raise ImproperlyConfigured("DEBUG must be False in production")
ALLOWED_HOSTS = _parse_allowed_hosts(_require_env("ALLOWED_HOSTS"))
ALLOWED_HOSTS = _parse_allowed_hosts(
_require_env("ALLOWED_HOSTS"),
allow_any_host=_is_truthy_env("ALLOW_ANY_HOSTS"),
)
# JWT
SIMPLE_JWT["SIGNING_KEY"] = SECRET_KEY