Skip to content

Commit 01fe05d

Browse files
committed
Allow overriding secure cookies for local development
CSRF and session cookies are configured to use the secure flag, i.e. only send the cookies over HTTPS. Chrome seems to ignore the secure flag when the origin is localhost, which is why it hasn't been much of problem before now, but Safari (correctly) does not set the cookie after login. By making it an environment variable we can override for local environments.
1 parent a33763f commit 01fe05d

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

manage_breast_screening/config/.env.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ DATABASE_HOST=localhost
1111
LOG_QUERIES=0
1212
PERSONAS_ENABLED=1
1313

14+
CSRF_COOKIE_SECURE=False
15+
SESSION_COOKIE_SECURE=False
16+
1417
# Set to FQDN in deployed environments
1518
BASE_URL=http://localhost:8000
1619

manage_breast_screening/config/settings/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def list_env(key):
3737
ALLOWED_HOSTS = list_env("ALLOWED_HOSTS")
3838
CSRF_TRUSTED_ORIGINS = list_env("CSRF_TRUSTED_ORIGINS")
3939

40-
CSRF_COOKIE_SECURE = True
41-
SESSION_COOKIE_SECURE = True
40+
CSRF_COOKIE_SECURE = boolean_env("CSRF_COOKIE_SECURE", default=True)
41+
SESSION_COOKIE_SECURE = boolean_env("SESSION_COOKIE_SECURE", default=True)
4242
# SECURE_SSL_REDIRECT is set to False because TLS termination is handled at the Azure Container Apps layer
4343
SECURE_SSL_REDIRECT = False
4444

0 commit comments

Comments
 (0)