Skip to content

Commit

Permalink
Merge pull request #79 from CollaboraOnline/issue-75-wopi-proof
Browse files Browse the repository at this point in the history
Issue #75: WOPI proof
  • Loading branch information
donquixote authored Jan 8, 2025
2 parents 0869615 + 2d0896c commit 2dc47be
Show file tree
Hide file tree
Showing 23 changed files with 1,268 additions and 323 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ jobs:
run: |
docker-compose exec -T web ./vendor/bin/phpcs -s
- name: Generate proof key
run: |
set -x
docker-compose exec -T collabora coolconfig generate-proof-key
# Collabora becomes unavailable after the above command.
docker-compose restart collabora
- name: Drupal site install
run: |
docker-compose exec -T web ./vendor/bin/run drupal:site-install
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ For a local demo or test installation, [see below](#development--demo-installati
- (optional) For the 'Collabora Online Group' sub-module, you also need the
[Group](https://drupa.org/project/group) and [Group Media](https://drupa.org/project/groupmedia) modules.

### Installation steps
### Collabora Online server preparation

It is recommended to generate a proof key as documented here:\
https://sdk.collaboraonline.com/docs/advanced_integration.html#wopi-proof

If not, the proof mechanism needs to be disabled in the module settings.

### Module installation steps

See the [Drupal guide to install
modules](https://www.drupal.org/docs/extending-drupal/installing-modules).
Expand All @@ -39,7 +46,7 @@ field in the `composer.json` of your project.
Then you can go into Drupal logged as an admin and go to _Extend_. In
the list you should be able to find _Collabora Online_ and enable it.

From there you can access the module specific configuration.
From there you can access the module-specific configuration.

Please check the "Configuration" section below!

Expand Down Expand Up @@ -69,6 +76,9 @@ docker-compose up -d

docker-compose exec web composer install
docker-compose exec web ./vendor/bin/run drupal:site-install

docker-compose exec collabora coolconfig generate-proof-key
docker-compose restart collabora
```

Optionally, generate an admin login link.
Expand Down
24 changes: 24 additions & 0 deletions collabora_online.post_update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/*
* Copyright the Collabora Online contributors.
*
* SPDX-License-Identifier: MPL-2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

declare(strict_types=1);

/**
* Sets an initial value for the new 'wopi_proof' setting.
*/
function collabora_online_post_update_add_wopi_proof_setting(): void {
$config = \Drupal::configFactory()->getEditable('collabora_online.settings');
$cool_settings = $config->get('cool') ?? [];
$cool_settings['wopi_proof'] ??= TRUE;
$config->set('cool', $cool_settings);
$config->save();
}
9 changes: 6 additions & 3 deletions collabora_online.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ collabora-online.wopi.info:
action: 'info'
methods: [ GET ]
requirements:
_permission: 'access content'
_collabora_online_wopi_access: 'TRUE'
_format: 'collabora_online_wopi'
options:
parameters:
action:
Expand All @@ -62,7 +63,8 @@ collabora-online.wopi.contents:
action: 'content'
methods: [ GET ]
requirements:
_permission: 'access content'
_collabora_online_wopi_access: 'TRUE'
_format: 'collabora_online_wopi'
options:
parameters:
action:
Expand All @@ -77,7 +79,8 @@ collabora-online.wopi.save:
action: 'save'
methods: [ POST ]
requirements:
_permission: 'access content'
_collabora_online_wopi_access: 'TRUE'
_format: 'collabora_online_wopi'
options:
parameters:
action:
Expand Down
4 changes: 4 additions & 0 deletions collabora_online.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ services:
class: Drupal\collabora_online\Jwt\JwtTranscoder
Drupal\collabora_online\MediaHelperInterface:
class: Drupal\collabora_online\MediaHelper
Drupal\collabora_online\EventSubscriber\ExceptionWopiSubscriber: { }
Drupal\collabora_online\Access\WopiProofAccessCheck:
tags:
- { name: access_check, applies_to: _collabora_online_wopi_access }
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"require": {
"php": ">=8.1",
"drupal/key": "^1.19",
"firebase/php-jwt": "^6.10"
"firebase/php-jwt": "^6.10",
"phpseclib/phpseclib": "^3.0",
"symfony/error-handler": "^6.4|^7.1"
},
"require-dev": {
"composer/installers": "^2",
Expand Down
1 change: 1 addition & 0 deletions config/install/collabora_online.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ cool:
access_token_ttl: 86400
# Disable cert checks.
disable_cert_check: false
wopi_proof: true
# Allow fullscreen - Enabled by default for functionality.
allowfullscreen: true
3 changes: 3 additions & 0 deletions config/schema/collabora_online.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ collabora_online.settings:
disable_cert_check:
type: boolean
label: 'Disable cert checks.'
wopi_proof:
type: boolean
label: 'Verify WOPI proof header and timestamp.'
allowfullscreen:
type: boolean
label: 'Allow full-screen.'
Expand Down
Loading

0 comments on commit 2dc47be

Please sign in to comment.