From a05aaa02b1a92d0b76aa08dce26d9710a07d961b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 14 Aug 2023 11:57:29 +0200 Subject: [PATCH] fix: Log invalid wopi tokens at info level instead of error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Middleware/WOPIMiddleware.php | 5 +++++ 1 file changed, 5 insertions(+) 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();