Add enforce host

This commit is contained in:
Jake Howard 2022-11-16 14:20:21 +00:00
parent 5ec613f7bb
commit 6f6e57a0c7
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 5 additions and 0 deletions

View file

@ -28,6 +28,7 @@ django3-cache-decorator==0.5.2
django-cors-headers==3.13.0 django-cors-headers==3.13.0
django-csp==3.7 django-csp==3.7
django-permissions-policy==4.13.0 django-permissions-policy==4.13.0
django-enforce-host==1.1.0
# DRF OpenAPI dependencies # DRF OpenAPI dependencies
uritemplate uritemplate

View file

@ -94,6 +94,7 @@ MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware", "django.middleware.security.SecurityMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
"corsheaders.middleware.CorsMiddleware", "corsheaders.middleware.CorsMiddleware",
"enforce_host.EnforceHostMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware", "whitenoise.middleware.WhiteNoiseMiddleware",
"django.middleware.common.CommonMiddleware", "django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware", "django.contrib.sessions.middleware.SessionMiddleware",
@ -421,6 +422,9 @@ if not DEBUG:
CSP_BLOCK_ALL_MIXED_CONTENT = True CSP_BLOCK_ALL_MIXED_CONTENT = True
CSP_UPGRADE_INSECURE_REQUESTS = True CSP_UPGRADE_INSECURE_REQUESTS = True
if not TEST:
ENFORCE_HOST = BASE_HOSTNAME
if sentry_dsn := env("SENTRY_DSN"): if sentry_dsn := env("SENTRY_DSN"):
import sentry_sdk import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration from sentry_sdk.integrations.django import DjangoIntegration