Skip to content

Commit

Permalink
fix(Authorizer): Don't give WRITE permissions by default
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Dec 18, 2023
1 parent a01fa21 commit 6428928
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/Controller/FoldersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ public function addToFolder($folderId, $bookmarkId): JSONResponse {
* @PublicPage
*/
public function removeFromFolder($folderId, $bookmarkId): JSONResponse {
if (!Authorizer::hasPermission(Authorizer::PERM_WRITE, $this->authorizer->getPermissionsForFolder($folderId, $this->request)) &&
!Authorizer::hasPermission(Authorizer::PERM_EDIT, $this->authorizer->getPermissionsForFolder($bookmarkId, $this->request))) {
if (!Authorizer::hasPermission(Authorizer::PERM_WRITE, $this->authorizer->getPermissionsForFolder($folderId, $this->request)) ||
!Authorizer::hasPermission(Authorizer::PERM_EDIT, $this->authorizer->getPermissionsForBookmark($bookmarkId, $this->request))) {
return new JSONResponse(['status' => 'error', 'data' => 'Unauthorized'], Http::STATUS_FORBIDDEN);
}
try {
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/Authorizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ private function findPermissionsByUserAndItem(string $userId, string $type, int
if ($share->getFolderId() === $itemId && $type === TreeMapper::TYPE_FOLDER) {
// If the sought folder is the root folder of the share, we give EDIT permissions + optionally RESHARE
// because the user can edit the shared folder
$perms = $this->getMaskFromFlags(true, $share->getCanShare()) | self::PERM_EDIT;
$perms = $this->getMaskFromFlags(false, $share->getCanShare()) | self::PERM_EDIT;
} elseif ($this->treeMapper->hasDescendant($share->getFolderId(), $type, $itemId)) {
$perms = $this->getMaskFromFlags($share->getCanWrite(), $share->getCanShare());
} else {
Expand Down

0 comments on commit 6428928

Please sign in to comment.