This commit is contained in:
+9
-22
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import os
|
||||
from pathlib import Path
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
@@ -33,23 +34,15 @@ def _validate_production_security(
|
||||
"Onveilige DJANGO_SECRET_KEY in productie. Stel een sterke waarde in via environment."
|
||||
)
|
||||
if len(secret_key.strip()) < 50:
|
||||
raise ImproperlyConfigured(
|
||||
"DJANGO_SECRET_KEY is te kort voor een productieomgeving."
|
||||
)
|
||||
raise ImproperlyConfigured("DJANGO_SECRET_KEY is te kort voor een productieomgeving.")
|
||||
if not allowed_hosts:
|
||||
raise ImproperlyConfigured("ALLOWED_HOSTS mag in productie niet leeg zijn.")
|
||||
if not csrf_trusted_origins:
|
||||
raise ImproperlyConfigured(
|
||||
"CSRF_TRUSTED_ORIGINS is verplicht bij DEBUG=False."
|
||||
)
|
||||
raise ImproperlyConfigured("CSRF_TRUSTED_ORIGINS is verplicht bij DEBUG=False.")
|
||||
if not any(origin.lower().startswith("https://") for origin in csrf_trusted_origins):
|
||||
raise ImproperlyConfigured(
|
||||
"CSRF_TRUSTED_ORIGINS moet HTTPS-origins bevatten in productie."
|
||||
)
|
||||
raise ImproperlyConfigured("CSRF_TRUSTED_ORIGINS moet HTTPS-origins bevatten in productie.")
|
||||
if not session_cookie_secure or not csrf_cookie_secure:
|
||||
raise ImproperlyConfigured(
|
||||
"Session- en CSRF-cookies moeten Secure=True zijn in productie."
|
||||
)
|
||||
raise ImproperlyConfigured("Session- en CSRF-cookies moeten Secure=True zijn in productie.")
|
||||
if not secure_ssl_redirect:
|
||||
raise ImproperlyConfigured("SECURE_SSL_REDIRECT moet True zijn in productie.")
|
||||
|
||||
@@ -148,7 +141,7 @@ if DATABASE_URL:
|
||||
"OPTIONS": {"connect_timeout": 10},
|
||||
}
|
||||
}
|
||||
elif (postgres_cfg := _postgres_database_from_env()):
|
||||
elif postgres_cfg := _postgres_database_from_env():
|
||||
DATABASES = {"default": postgres_cfg}
|
||||
else:
|
||||
DATABASES = {
|
||||
@@ -299,15 +292,9 @@ OLLAMA_TIMEOUT_SECONDS = float(os.getenv("OLLAMA_TIMEOUT_SECONDS", "60"))
|
||||
|
||||
DIGEST_RECIPIENT = os.getenv("DIGEST_RECIPIENT", "")
|
||||
|
||||
AUTH_LOGIN_RATE_LIMIT_MAX_ATTEMPTS = int(
|
||||
os.getenv("AUTH_LOGIN_RATE_LIMIT_MAX_ATTEMPTS", "8")
|
||||
)
|
||||
AUTH_LOGIN_RATE_LIMIT_WINDOW_SECONDS = int(
|
||||
os.getenv("AUTH_LOGIN_RATE_LIMIT_WINDOW_SECONDS", "300")
|
||||
)
|
||||
AUTH_LOGIN_RATE_LIMIT_BLOCK_SECONDS = int(
|
||||
os.getenv("AUTH_LOGIN_RATE_LIMIT_BLOCK_SECONDS", "300")
|
||||
)
|
||||
AUTH_LOGIN_RATE_LIMIT_MAX_ATTEMPTS = int(os.getenv("AUTH_LOGIN_RATE_LIMIT_MAX_ATTEMPTS", "8"))
|
||||
AUTH_LOGIN_RATE_LIMIT_WINDOW_SECONDS = int(os.getenv("AUTH_LOGIN_RATE_LIMIT_WINDOW_SECONDS", "300"))
|
||||
AUTH_LOGIN_RATE_LIMIT_BLOCK_SECONDS = int(os.getenv("AUTH_LOGIN_RATE_LIMIT_BLOCK_SECONDS", "300"))
|
||||
MANUAL_IMPORT_RATE_LIMIT_MAX_ATTEMPTS = int(
|
||||
os.getenv("MANUAL_IMPORT_RATE_LIMIT_MAX_ATTEMPTS", "12")
|
||||
)
|
||||
|
||||
+1
-1
@@ -2,8 +2,8 @@ from __future__ import annotations
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib.auth import views as auth_views
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth import views as auth_views
|
||||
from django.urls import include, path
|
||||
|
||||
from apps.core.views import SecurityAwareLoginView
|
||||
|
||||
Reference in New Issue
Block a user