From 1b08628c224ad8c452b03485e232b701dc531398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Robles?= Date: Wed, 26 Jun 2024 16:21:23 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=F0=9F=90=9E=20Improve/rethink/fix=20L?= =?UTF-8?q?ive=20Preview=20(#358)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Parent issue: https://github.com/sequentech/meta/issues/752 --- config.yml | 1 + iam/templates/deploy.py | 4 ++++ iam/templates/test_settings.py | 5 +++++ oneserver/templates/nginx.conf | 1 + 4 files changed, 11 insertions(+) diff --git a/config.yml b/config.yml index 377d6ab..0bee87a 100644 --- a/config.yml +++ b/config.yml @@ -183,6 +183,7 @@ config: # play.http.parser.maxDiskBuffer (in ballot-box config) # play.http.parser.maxMemoryBuffer (in ballot-box config) # parsers.text.maxLength (in ballot-box config) + # DATA_UPLOAD_MAX_MEMORY_SIZE (in iam config) # client_max_body_size (in nginx) max_body_size: 2m diff --git a/iam/templates/deploy.py b/iam/templates/deploy.py index 607ceb5..49c3471 100644 --- a/iam/templates/deploy.py +++ b/iam/templates/deploy.py @@ -78,6 +78,7 @@ def on_celery_setup_logging(**kwargs): } STATIC_ROOT = '/home/iam/webstatic' +STATIC_PREVIEW_PATH = '/home/iam/webstatic/preview' MEDIA_ROOT = '/home/iam/webstatic/media' ALLOWED_HOSTS = ['*'] @@ -222,4 +223,7 @@ def on_celery_setup_logging(**kwargs): {{extra_option}} {% endfor %} +{% set max_body_size_bytes = (config.http.max_body_size[:-1] | int) * 1024 * 1024 %} + +DATA_UPLOAD_MAX_MEMORY_SIZE = {{ max_body_size_bytes }} diff --git a/iam/templates/test_settings.py b/iam/templates/test_settings.py index 13a470b..3c2f30f 100644 --- a/iam/templates/test_settings.py +++ b/iam/templates/test_settings.py @@ -174,6 +174,7 @@ class CeleryConfig: STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') +STATIC_PREVIEW_PATH = os.path.join(BASE_DIR, 'static', 'preview') # cors CORS_ORIGIN_ALLOW_ALL = False @@ -248,6 +249,10 @@ class CeleryConfig: ENABLE_MULTIPLE_TALLIES = False +{% set max_body_size_bytes = (config.http.max_body_size[:-1] | int) * 1024 * 1024 %} + +DATA_UPLOAD_MAX_MEMORY_SIZE = {{ max_body_size_bytes }} + if not os.path.exists(IMAGE_STORE_PATH): os.mkdir(IMAGE_STORE_PATH) diff --git a/oneserver/templates/nginx.conf b/oneserver/templates/nginx.conf index 1f702f5..fc3aa72 100644 --- a/oneserver/templates/nginx.conf +++ b/oneserver/templates/nginx.conf @@ -134,6 +134,7 @@ http { default 1; "~^GET:/elections/api/(authorities|election/(\d+)(|/results|/hash/))" 0; "~^GET:/elections/public/\d+/\d+.tar" 0; + "~^GET:/iam/api/auth-event/([a-f0-9\-]+)/live-preview" 0; "~^POST:/elections/api/election/(\d+)/voter/" 0; "~^GET:/iam/api/(legal/|auth-event/(\d+)/?)" 0; "~^POST:/iam/api/auth-event/(\d+)/(register|authenticate|resend_auth_code|ping)" 0;