Skip to content

Commit

Permalink
fix: Let wopi middleware also handle asset fetching
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Jan 11, 2024
1 parent 7e16ad4 commit 7edf59f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Middleware/WOPIMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
namespace OCA\Richdocuments\Middleware;

use OCA\Richdocuments\AppInfo\Application;
use OCA\Richdocuments\Controller\AssetsController;
use OCA\Richdocuments\Controller\WopiController;
use OCA\Richdocuments\Db\WopiMapper;
use OCA\Richdocuments\Exceptions\ExpiredTokenException;
Expand Down Expand Up @@ -63,7 +64,11 @@ public function __construct(IConfig $config, IRequest $request, WopiMapper $wopi
public function beforeController($controller, $methodName) {
parent::beforeController($controller, $methodName);

if ($controller instanceof WopiController && !$this->isWOPIAllowed()) {
// Check controllers that are only supposed to be called by Collabora directly
// FIXME: This can be moved to a PHP attribute in the future
$isRestrictedController = $controller instanceof WopiController
|| ($controller instanceof AssetsController && $methodName === 'get');
if ($isRestrictedController && !$this->isWOPIAllowed()) {
throw new NotPermittedException();
}

Expand Down

0 comments on commit 7edf59f

Please sign in to comment.