Skip to content

Commit

Permalink
fix: Log invalid wopi tokens at info level instead of error
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliushaertl authored and backportbot-nextcloud[bot] committed Aug 16, 2023
1 parent 31bf46e commit 6c60ddc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Middleware/WOPIMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -77,6 +79,13 @@ public function beforeController($controller, $methodName) {
if ((int)$fileId !== $wopi->getFileid() && (int)$fileId !== $wopi->getTemplateId()) {
throw new NotPermittedException();
}
} catch (UnknownTokenException|ExpiredTokenException $e) {
if ($this->request->getMethod() === 'POST') {
$this->logger->error('Failed to validate WOPI access during save', [ 'exception' => $e ]);
} else {
$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();
Expand Down

0 comments on commit 6c60ddc

Please sign in to comment.