Skip to content

Commit ad43d44

Browse files
author
Janek Mangold
committed
feat: enhance security settings in staging.py for SSL and cookie protection
1 parent 698616b commit ad43d44

File tree

1 file changed

+30
-1
lines changed
  • django/{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/settings

1 file changed

+30
-1
lines changed

django/{{ cookiecutter.project_slug }}/{{ cookiecutter.project_slug }}/settings/staging.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,33 @@
1515
CORS_ALLOWED_ORIGIN_REGEXES = [
1616
r"^https://.*\.v2\.singular-it-test\.de$",
1717
]
18-
{% endif %}
18+
{% endif %}
19+
20+
# SECURITY
21+
22+
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
23+
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
24+
25+
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-ssl-redirect
26+
SECURE_SSL_REDIRECT = True
27+
28+
# https://docs.djangoproject.com/en/dev/ref/settings/#session-cookie-secure
29+
SESSION_COOKIE_SECURE = True
30+
SESSION_COOKIE_NAME = "{{ random_ascii_string(20) }}"
31+
32+
# https://docs.djangoproject.com/en/dev/ref/settings/#csrf-cookie-secure
33+
CSRF_COOKIE_SECURE = True
34+
CSRF_COOKIE_NAME = "{{ random_ascii_string(20) }}"
35+
36+
# https://docs.djangoproject.com/en/dev/topics/security/#ssl-https
37+
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-seconds
38+
SECURE_HSTS_SECONDS = 60 * 60 * 24 * 7 # 1 week
39+
40+
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-include-subdomains
41+
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
42+
43+
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-preload
44+
SECURE_HSTS_PRELOAD = True
45+
46+
# https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
47+
SECURE_CONTENT_TYPE_NOSNIFF = True

0 commit comments

Comments
 (0)