Skip to content

Commit af8c7a9

Browse files
committed
PPHA-369: Include CSRF_TRUSTED_ORIGINS to terraform env vars
1 parent 8a3e518 commit af8c7a9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

infrastructure/modules/container-apps/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ module "webapp" {
2424
environment_variables = merge(
2525
local.common_env,
2626
{
27-
ALLOWED_HOSTS = "${var.app_short_name}-web-${var.environment}.${var.default_domain}"
27+
ALLOWED_HOSTS = "${var.app_short_name}-web-${var.environment}.${var.default_domain}"
28+
CSRF_TRUSTED_ORIGINS = "https://${var.app_short_name}-web-${var.environment}.${var.default_domain}"
2829
},
2930
var.deploy_database_as_container ? local.container_db_env : local.azure_db_env
3031
)

lung_cancer_screening/settings.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def boolean_env(key, default=None):
1919
value = environ.get(key)
2020
return default if value is None else value in ("True", "true", "1")
2121

22+
def list_env(key):
23+
value = environ.get(key)
24+
return value.split(",") if value else []
25+
26+
2227
# Build paths inside the project like this: BASE_DIR / 'subdir'.
2328
BASE_DIR = Path(__file__).resolve().parent
2429

@@ -32,9 +37,8 @@ def boolean_env(key, default=None):
3237
# SECURITY WARNING: don't run with debug turned on in production!
3338
DEBUG = boolean_env("DEBUG", default=False)
3439

35-
allowed_hosts = environ.get("ALLOWED_HOSTS")
36-
ALLOWED_HOSTS = allowed_hosts.split(",") if allowed_hosts else []
37-
40+
ALLOWED_HOSTS = list_env("ALLOWED_HOSTS")
41+
CSRF_TRUSTED_ORIGINS = list_env("CSRF_TRUSTED_ORIGINS")
3842

3943
# Application definition
4044

0 commit comments

Comments
 (0)