From 513abcce25754ef646b42f905a05f53efb827865 Mon Sep 17 00:00:00 2001 From: "Prof. Jayanth R Varma" Date: Fri, 18 Oct 2024 12:21:29 +0530 Subject: [PATCH 1/2] Add ports section to ini.example --- etebase-server.ini.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etebase-server.ini.example b/etebase-server.ini.example index 436efe1..e5632c1 100644 --- a/etebase-server.ini.example +++ b/etebase-server.ini.example @@ -15,6 +15,10 @@ media_root = /path/to/media [allowed_hosts] allowed_host1 = example.com +[ports] +;http_port = 8000 +;https_port = 8043 + [database] engine = django.db.backends.sqlite3 name = db.sqlite3 From 221fd4617446c73f80e4d88e6433dec39ca3b236 Mon Sep 17 00:00:00 2001 From: "Prof. Jayanth R Varma" Date: Fri, 18 Oct 2024 12:24:19 +0530 Subject: [PATCH 2/2] Allow non standard ports in CSRF_TRUSTED_ORIGINS --- etebase_server/settings.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/etebase_server/settings.py b/etebase_server/settings.py index f6c726d..8731083 100644 --- a/etebase_server/settings.py +++ b/etebase_server/settings.py @@ -163,10 +163,18 @@ ETEBASE_REDIS_URI = section.get("redis_uri") if "allowed_hosts" in config: + if "ports" in config and "https_port" in config["ports"]: + https_port = ":" + config["ports"]["https_port"] + else: + https_port = "" + if "ports" in config and "http_port" in config["ports"]: + http_port = ":" + config["ports"]["http_port"] + else: + http_port = "" ALLOWED_HOSTS = [y for x, y in config.items("allowed_hosts")] - CSRF_TRUSTED_ORIGINS = ["https://" + y for x, y in config.items("allowed_hosts")] + \ - ["http://" + y for x, y in config.items("allowed_hosts")] - + CSRF_TRUSTED_ORIGINS = ["https://" + y + https_port for x, y in config.items("allowed_hosts")] + \ + ["http://" + y + http_port for x, y in config.items("allowed_hosts")] + if "database" in config: DATABASES = {"default": {x.upper(): y for x, y in config.items("database")}}