From 39aac9228b770ea828b17fea5f4ef20ec82a7263 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Sat, 9 Jul 2022 07:45:18 -0400 Subject: [PATCH] ejabberd: Enable mod_http_upload - Upgrade existing config. Tests: - Install ejabberd. Configuration is set as expected and ejabberd is running. - Upgrade from existing ejabberd install. Configuration is set as expected and ejabberd is running. - Send a file between two users in dino-im and Conversations app. Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- plinth/modules/ejabberd/__init__.py | 2 +- .../apache2/conf-available/jwchat-plinth.conf | 8 +++++++ plinth/modules/ejabberd/privileged.py | 22 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/plinth/modules/ejabberd/__init__.py b/plinth/modules/ejabberd/__init__.py index 22276b5de..b4ebd11b1 100644 --- a/plinth/modules/ejabberd/__init__.py +++ b/plinth/modules/ejabberd/__init__.py @@ -50,7 +50,7 @@ class EjabberdApp(app_module.App): app_id = 'ejabberd' - _version = 4 + _version = 5 def __init__(self): """Create components for the app.""" diff --git a/plinth/modules/ejabberd/data/etc/apache2/conf-available/jwchat-plinth.conf b/plinth/modules/ejabberd/data/etc/apache2/conf-available/jwchat-plinth.conf index e76c32809..847228f8e 100644 --- a/plinth/modules/ejabberd/data/etc/apache2/conf-available/jwchat-plinth.conf +++ b/plinth/modules/ejabberd/data/etc/apache2/conf-available/jwchat-plinth.conf @@ -4,3 +4,11 @@ ProxyPassReverse /bosh/ http://localhost:5443/bosh/ Require all granted + +## +## Proxy for XEP-0363 HTTP File Upload +## + + ProxyPreserveHost On + ProxyPass http://localhost:5443/upload/ + diff --git a/plinth/modules/ejabberd/privileged.py b/plinth/modules/ejabberd/privileged.py index 4e6037d1f..d0e9c3bd4 100644 --- a/plinth/modules/ejabberd/privileged.py +++ b/plinth/modules/ejabberd/privileged.py @@ -55,6 +55,28 @@ def setup(domainname: str): listen_port['tls'] = False if 'use_turn' in listen_port: conf['listen'].remove(listen_port) # Use coturn instead + if listen_port['port'] == 5443: + # Enable XEP-0363 HTTP File Upload + listen_port['request_handlers']['/upload'] = 'mod_http_upload' + + origin_key = scalarstring.DoubleQuotedScalarString( + 'Access-Control-Allow-Origin') + origin_value = scalarstring.DoubleQuotedScalarString('https://@HOST@') + methods_key = scalarstring.DoubleQuotedScalarString( + 'Access-Control-Allow-Methods') + methods_value = scalarstring.DoubleQuotedScalarString( + 'GET,HEAD,PUT,OPTIONS') + headers_key = scalarstring.DoubleQuotedScalarString( + 'Access-Control-Allow-Headers') + headers_value = scalarstring.DoubleQuotedScalarString('Content-Type') + conf['modules']['mod_http_upload'] = { + 'put_url': 'https://@HOST@/upload', + 'custom_headers': { + origin_key: origin_value, + methods_key: methods_value, + headers_key: headers_value, + }, + } conf['auth_method'] = 'ldap' conf['ldap_servers'] = [scalarstring.DoubleQuotedScalarString('localhost')]