Skip to main content

This provides a Flask-based HTTP service which can be used with mod_http_upload_external.

Configuration

The configuration file is specified using the environment variable XMPP_HTTP_UPLOAD_CONFIG. It must contain the full path to the configuration file.

The configuration file must contain the following keys:

SECRET_KEY

A bytes object which is the shared secret between the Prosody module and this service. See the mod_http_upload_external documentation for details.

DATA_ROOT

Path to the directory where the service stores the uploaded files.

NON_ATTACHMENT_MIME_TYPES

A list of string globs which specify the content types which are not sent 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 with Content-Disposition: attachment in order to prevent funny attacks.

It is not recommended to add things like text/html or * to this list.

ENABLE_CORS

Allow cross-origin access to all endpoints unconditionally. This is needed to allow web clients to use the upload feature.

Issues, Bugs, Limitations

  • This service does not handle any kind of quota.

  • The format in which the files are stored is not compatible with mod_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 instructions

Example 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 then apt-get on 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 with wsgi which should yield in better performance.

I assume your webserver uses www-data as 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-flask

Edit config.py and change SECRET_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-upload

Enable 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.service

Configure your webserver:

As final step you need to point your external webserver to your xmpp-http-upload flask app. Check the contrib directory, there is an example for nginx there.

Release files for xmpp-http-upload 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xmpp-http-upload 0.4.0
File Size Uploaded
xmpp-http-upload-0.4.0.tar.gz 15.7 kB Details

Release files / xmpp-http-upload-0.4.0.tar.gz

Download URL xmpp-http-upload-0.4.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d7a8fac7feda5194efe0dfdfe4889579777d85de520866af8d942e23dc9cbab5
BLAKE2b-256 checksum
How to use checksums
62605186b6cceb55622747ae913df9776e037c130c1067b8083f6834c804dcdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.4.2 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.8.0 tqdm/4.48.1 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.4.0 This release

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page