This service is part of the ScienceMesh Interoperability Platform (IOP) and implements a vendor-neutral application gateway compatible with the Web-application Open Platform Interface (WOPI) specifications.
It enables ScienceMesh EFSS storages to integrate Office Online platforms including Microsoft Office Online and Collabora Online. In addition it implements a bridge module with dedicated extensions to support apps like CodiMD and Etherpad.
Author: Giuseppe Lo Presti (@glpatcern)
Contributors (oldest contributions first):
- Michael DSilva (@madsi1m)
- Lovisa Lugnegaard (@LovisaLugnegard)
- Samuel Alfageme (@SamuAlfageme)
- Diogo Castro (@diocas)
- Ishank Arora (@ishank011)
- Willy Kloucek (@wkloucek)
- Gianmaria Del Monte (@gmgigi96)
- Klaas Freitag (@dragotin)
- Jörn Friedrich Dreyer (@butonic)
- Michael Barz (@micbar)
- Robert Kaussow (@xoxys)
- Javier Ferrer (@javfg)
- Vasco Guita (@vascoguita)
- Thomas Mueller (@deepdiver1975)
- Andre Duffeck (@aduffeck)
- Rasmus Welander (@rawe0)
- Gianmaria Del Monte (@gmgigi96)
Initial revision: December 2016
First production version for CERNBox: September 2017 (presented at oCCon17 - slides)
Integration in the CS3 Organisation: April 2020
This WOPI server implements the required APIs to ensure full compatibility with Microsoft Office (as provided via the CSPP Terms), Collabora Online, and ONLYOFFICE.
The WOPI server exposes Prometheus metrics on /metrics, on the same port
as the WOPI endpoints. The endpoint is disabled unless a bearer token is configured:
[monitoring]
metricstokenfile = /etc/wopi/metricstoken
Scrapers must then pass Authorization: Bearer <token>, any other request gets a 401. Use a secret
other than the iopsecret, as the latter grants access to any file. The app label takes one of the
names in metricsapps (by default MS365 Collabora CodiMD EuroOffice Etherpad) or other.
No metric is labelled with user, file, path, token or session identities.
| Metric | Type | Labels | Description |
|---|---|---|---|
wopi_opens_total |
counter | app, mode, filetype, user_type |
access tokens generated, i.e. files opened |
wopi_saves_total |
counter | app, filetype, result |
PutFile operations: ok, recovery (the content, or a conflict copy, could not be written to the storage and was stored in the local recoverypath), error (even that failed) |
wopi_sessions_total |
counter | app |
WOPI calls with a valid access token |
wopi_conflicts_total |
counter | app, kind |
lock conflicts returned to the apps: external (desktop app lock), ms365 (known MS365 false positives), other |
wopi_conflict_resolution_seconds |
histogram | time for a conflicted session to get resolved | |
wopi_storage_request_duration_seconds |
histogram | op |
latency of the storage requests, op one of stat read write lock unlock xattr remove rename other |
wopi_open_files |
gauge | app, mode |
files in the open files map, as returned by /wopi/iop/list: entries are added on lock and save, and removed on unlock |
wopi_conflicted_sessions |
gauge | state |
pending and resolved conflicted sessions |
wopi_active_users |
gauge | users who opened a file since the start of the server | |
wopi_log_messages_total |
counter | level |
log messages at warning level or above, as long as loglevel lets them through |
where mode is one of write read view preview embedded, user_type one of
regular federated ocm anonymous publink, and filetype one of
doc docx xls xlsx ppt pptx odt ods odp md zmd others (templates are accounted as the type they are a template of).
The storage latency covers the request to the storage: with xroot and local storage the open of the file for
read and write, and the EOS commands for the others (locks are xattr operations on xroot); with cs3 storage
read is the time to the first chunk, and write includes the transfer of the content.
The default per-endpoint request metrics of prometheus-flask-exporter
are also exposed.
An example of Prometheus scrape configuration:
scrape_configs:
- job_name: wopiserver
scheme: https
authorization:
type: Bearer
credentials_file: /etc/prometheus/wopi-metricstoken
static_configs:
- targets: ['wopiserver.example.org:8443']The /test folder contains some unit tests for the supported storage interfaces.
No tests are provided (yet) for the core WOPI server, though the test suite aims at covering all
storage access patterns used by the WOPI server.
By default, the local storage is tested, and the CI runs it as well (TODO test against Reva in the CI).
To run the tests, either run pytest if available in your system, or execute the following:
- Run all tests:
python3 test/test_storageiface.py [-v] - Run only one test:
python3 test/test_storageiface.py [-v] TestStorage.<the test you would like to run>
The test/test_metrics.py tests cover the metrics exposed on /metrics, using the local storage.
The CS3 storage interface uses the cs3 python client, please also refer to its test suite and documentation.
- Clone reva (https://github.com/cs3org/reva)
- Run Reva according to https://reva.link/docs/tutorials/share-tutorial/ (ie up until step 4 in the instructions)
- For a production deployment, configure your
wopiserver.conffollowing the example above, and make sure theiopsecretfile contains the same secret as configured in the Reva appprovider - Configure
test/wopiserver-test.confsuch that the wopiserver can talk to your Reva instance: use this example for a skeleton configuration - Run the tests:
WOPI_STORAGE=cs3 python3 test/test_storageiface.py
- Make sure your Eos instance is configured to accept connections from WOPI as a privileged gateway
- Configure
test/wopiserver-test.confaccording to your Eos setup (the provided defaults are valid at CERN) - Run the tests:
WOPI_STORAGE=xroot python3 test/test_storageiface.py - For a production deployment (CERN only), configure your
wopiserver.confaccording to the Puppet infrastructure
Refer to these notes. Microsoft also provides a graphical version of the test suite as part of their Office 365 offer, which is also supported via the Reva open-in-app workflow.
- Install all requirements:
pip install -r requirements.txt - Add log file directory:
sudo mkdir /var/log/wopi/ && sudo chmod a+rwx /var/log/wopi - Create the folder for the wopi config:
sudo mkdir /etc/wopi/ && sudo chmod a+rwx /etc/wopi - Create recoveryfolder:
sudo mkdir /var/spool/wopirecovery && sudo chmod a+rwx /var/spool/wopirecovery - Create the files
iopsecretandwopisecretin the folder/etc/wopi/, create random strings for the secrets - Copy the provided wopiserver.conf to
/etc/wopi/wopiserver.defaults.conf - Create a config file
/etc/wopi/wopiserver.conf: start fromdocker/etc/wopiserver.conffor a minimal configuration and add from the defaults file as needed - From the WOPI server folder run:
python3 src/wopiserver.py
Once the WOPI server runs on top of local storage, the tools/wopiopen.py script can be used
to test the open-in-app workflow.
For that, assuming you have e.g. CodiMD deployed in your cluster:
- Create a
test.mdfile in your local storage folder, e.g./var/wopi_local_storage - From the WOPI server folder, execute
tools/wopiopen.py -a CodiMD -i "internal_CodiMD_URL" -u "user_visible_CodiMD_URL" -k CodiMD_API_Key test.md - If everything was setup correctly, you'll get a JSON response including an
app-url. Open it in a browser to access the file. Otherwise, the tool prints the response from the WOPI server and the logs should help troubleshooting the problem.
