diff --git a/lib/Middleware/WOPIMiddleware.php b/lib/Middleware/WOPIMiddleware.php index b63e222225..95b2327b5b 100644 --- a/lib/Middleware/WOPIMiddleware.php +++ b/lib/Middleware/WOPIMiddleware.php @@ -30,6 +30,8 @@ use OCA\Richdocuments\AppInfo\Application; use OCA\Richdocuments\Controller\WopiController; use OCA\Richdocuments\Db\WopiMapper; +use OCA\Richdocuments\Exceptions\ExpiredTokenException; +use OCA\Richdocuments\Exceptions\UnknownTokenException; use OCA\Richdocuments\Helper; use OCP\AppFramework\Http; use OCP\AppFramework\Http\JSONResponse; @@ -77,6 +79,9 @@ public function beforeController($controller, $methodName) { if ((int)$fileId !== $wopi->getFileid() && (int)$fileId !== $wopi->getTemplateId()) { throw new NotPermittedException(); } + } catch (UnknownTokenException|ExpiredTokenException $e) { + $this->logger->info('Invalid token for WOPI access', [ 'exception' => $e ]); + throw new NotPermittedException(); } catch (\Exception $e) { $this->logger->error('Failed to validate WOPI access', [ 'exception' => $e ]); throw new NotPermittedException();