Skip to content

Commit 172dee8

Browse files
Dev NirwalDev Nirwal
authored andcommitted
Fix: add more security settings for HTTPS and CSRF
1 parent 50d7a89 commit 172dee8

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

pdf_chat_project/settings.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# SECURITY WARNING: don't run with debug turned on in production!
3535
DEBUG = env.bool('DEBUG', default=False)
3636

37-
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=['*'])
37+
ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=['simple-rag.nstsdc.org', 'www.simple-rag.nstsdc.org', 'localhost', '127.0.0.1'])
3838

3939
CSRF_TRUSTED_ORIGINS = env.list('CSRF_TRUSTED_ORIGINS', default=['http://simple-rag.nstsdc.org', 'https://simple-rag.nstsdc.org'])
4040

@@ -43,6 +43,16 @@
4343
USE_X_FORWARDED_HOST = True
4444
USE_X_FORWARDED_PORT = True
4545

46+
# HTTPS settings
47+
SESSION_COOKIE_SECURE = True
48+
CSRF_COOKIE_SECURE = True
49+
SECURE_SSL_REDIRECT = env.bool('SECURE_SSL_REDIRECT', default=False) # Traefik usually handles this
50+
SECURE_HSTS_SECONDS = 31536000
51+
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
52+
SECURE_HSTS_PRELOAD = True
53+
SECURE_CONTENT_TYPE_NOSNIFF = True
54+
SECURE_BROWSER_XSS_FILTER = True
55+
4656

4757
# Application definition
4858

0 commit comments

Comments
 (0)