Skip to content

Commit

Permalink
Merge pull request #1019 from nextcloud/backport/1016/stable17
Browse files Browse the repository at this point in the history
[stable17] Harden read only check on public endpoints
  • Loading branch information
juliusknorr authored Sep 7, 2020
2 parents a93e28e + 4b5ffa7 commit 4d49837
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCA\Text\DocumentHasUnsavedChangesException;
use OCA\Text\DocumentSaveConflictException;
use OCA\Text\VersionMismatchException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\NotFoundResponse;
Expand Down Expand Up @@ -64,6 +65,17 @@ public function create($fileId = null, $filePath = null, $token = null, $guestNa
$file = null;
if ($token) {
$file = $this->documentService->getFileByShareToken($token, $this->request->getParam('filePath'));

/*
* Check if we have proper read access (files drop)
* If not then well 404 it is.
*/
try {
$this->documentService->checkSharePermissions($token, Constants::PERMISSION_READ);
} catch (NotFoundException $e) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}

try {
$this->documentService->checkSharePermissions($token, Constants::PERMISSION_UPDATE);
$readOnly = false;
Expand Down

0 comments on commit 4d49837

Please sign in to comment.