Skip to content

Commit

Permalink
Merge pull request #3110 from nextcloud/backport/3107/stable27
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl committed Aug 17, 2023
2 parents 31bf46e + 6c60ddc commit c70c521
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 c70c521

Please sign in to comment.