Skip to content

Commit

Permalink
Merge pull request #3111 from nextcloud/backport/3107/stable26
Browse files Browse the repository at this point in the history
[stable26] fix: Log invalid wopi tokens at info level instead of error
  • Loading branch information
max-nextcloud authored Aug 16, 2023
2 parents 5760c30 + 252903c commit b5a09b7
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 b5a09b7

Please sign in to comment.