Skip to content

Commit 40d4893

Browse files
committed
OS-89: moved csrf settings from prod to security
1 parent 1192fb5 commit 40d4893

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

openIMIS/openIMIS/settings/prod.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@
3131
USE_X_FORWARDED_HOST = BEHIND_PROXY
3232
SECURE_SSL_REDIRECT = not BEHIND_PROXY # Only redirect if not behind a proxy
3333

34-
# CSRF settings
35-
CSRF_COOKIE_SECURE = True
36-
SESSION_COOKIE_SECURE = True
37-
38-
# CORS settings
39-
CORS_ALLOW_CREDENTIALS = True
40-
41-
# Cookie settings
42-
SESSION_COOKIE_SAMESITE = 'Lax' # or 'None' if cross-site
43-
CSRF_COOKIE_SAMESITE = 'Lax' # or 'None' if cross-site
44-
CSRF_COOKIE_HTTPONLY = False # False if you need to access it from JavaScript
45-
4634
# HSTS settings (if using HTTPS)
4735
if 'https' in protos:
4836
SECURE_HSTS_SECONDS = 31536000 # 1 year

openIMIS/openIMIS/settings/security.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,17 @@
8989
RATELIMIT_GROUP = os.getenv('RATELIMIT_GROUP', 'graphql')
9090
RATELIMIT_SKIP_TIMEOUT = os.getenv('RATELIMIT_SKIP_TIMEOUT', 'False')
9191

92+
# CSRF settings
93+
CSRF_COOKIE_SECURE = True
94+
SESSION_COOKIE_SECURE = True
9295

96+
# CORS settings
97+
CORS_ALLOW_CREDENTIALS = True
9398

99+
# Cookie settings
100+
SESSION_COOKIE_SAMESITE = 'Lax' # or 'None' if cross-site
101+
CSRF_COOKIE_SAMESITE = 'Lax' # or 'None' if cross-site
102+
CSRF_COOKIE_HTTPONLY = False # False if you need to access it from JavaScript
94103

95104
# Adjust other settings as needed for your specific application
96105
# ...

0 commit comments

Comments
 (0)