Package: xmpp-http-upload
This provides a Flask-based HTTP service which can be used withmod_http_upload_external.ConfigurationThe configuration file is specified using the environment variableXMPP_HTTP_UPLOAD_CONFIG. It must contain the full path to the configuration
file.The configuration file must contain the following keys:SECRET_KEYAbytesobject which is the shared secret between the Prosody module
and this service. See themod_http_upload_external documentationfor details.DATA_ROOTPath to the directory where the service stores the uploaded files.NON_ATTACHMENT_MIME_TYPESA list of string globs which specify the content types which arenotsent
as attachment. Defaults to the empty list if not given.Example use:NON_ATTACHMENT_MIME_TYPES = [
    "image/*",
    "video/*",
    "audio/*",
    "text/plain",
]Everything which does not match any of the entries here will be sent withContent-Disposition:attachmentin order to prevent funny attacks.It is not recommended to add things liketext/htmlor*to this
list.ENABLE_CORSAllow cross-origin access to all endpoints unconditionally. This is needed
to allow web clients to use the upload feature.Issues, Bugs, LimitationsThis servicedoes not handle any kind of quota.The format in which the files are stored isnotcompatible withmod_http_upload– so you’ll lose all uploaded files when switching.This blindly trusts the clients Content-Type. I don’t think this is a major issue, because we also tell the browser to blindly trust the clients MIME type. This, in addition with forcing all but a white list of MIME types to be downloaded instead of shown inline, should provide safety against any type of XSS attacks.I have no idea about web security. The headers I set may be subtly wrong and circumvent all security measures I intend this to have. Please double-check for yourself and report if you find anything amiss.Example Installation instructionsExample instructions for debian based systems, if you don’t use debian check your distributions repositories for the correct python3 flask package name.
You probably also want to use something else thenapt-geton non debian based distributions.In this example we will install the flask http server and proxy requests from an already installed and configured webserver (nginx) to the flask http server.
It is also possible to run the python script withwsgiwhich should yield in better performance.I assume your webserver useswww-dataas service account. If you have a different user update the systemd service and the permissions for the data directory.Clone and install:git clone https://github.com/horazont/xmpp-http-upload
sudo mv xmpp-http-upload /opt/xmpp-http-upload
cd /opt/xmpp-http-upload
copy config.example.py config.py
sudo apt-get install python3-flaskEditconfig.pyand changeSECRET_KEY. Be sure to only change between''.Create the upload directory:sudo mkdir /var/lib/xmpp-http-upload
sudo chown www-data.www-data /var/lib/xmpp-http-uploadEnable systemd service:sudo copy contrib/xmpp-http-upload.service /etc/systemd/system
sudo systemctl enable xmpp-http-upload.service
sudo systemctl start xmpp-http-upload.serviceConfigure your webserver:As final step you need to point your external webserver to your xmpp-http-upload flask app.
Check thecontribdirectory, there is an example for nginx there.