Skip to content

Commit 5ed3db9

Browse files
committed
fix(share_api): Respect requested permissions or error out
The share API currently always adds read permissions sent in share request with the argument that all shares must have read permissions. That this not true as link and email shares allowed not to. In addition to the above, there is a check that ensures any share which is not a link or email share must have read permissions. There is also protection for legacy integrations where if no permissions are sent at all default permissions are set. So it does not make sense to make any sort of additions to the permissions that a client has sent, as the response would be different from what the client expects. Signed-off-by: nfebe <fenn25.fn@gmail.com>
1 parent fbfe307 commit 5ed3db9

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,6 @@ public function createShare(
645645
throw new OCSNotFoundException($this->l->t('Invalid permissions'));
646646
}
647647

648-
// Shares always require read permissions
649-
$permissions |= Constants::PERMISSION_READ;
650-
651648
if ($node instanceof \OCP\Files\File) {
652649
// Single file shares should never have delete or create permissions
653650
$permissions &= ~Constants::PERMISSION_DELETE;
@@ -729,11 +726,6 @@ public function createShare(
729726
Constants::PERMISSION_DELETE;
730727
}
731728

732-
// TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones
733-
if ($this->shareManager->outgoingServer2ServerSharesAllowed()) {
734-
$permissions |= Constants::PERMISSION_SHARE;
735-
}
736-
737729
$share->setPermissions($permissions);
738730

739731
// Set password

build/integration/sharing_features/sharing-v1.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Feature: sharing
216216
| share_type | 3 |
217217
| file_source | A_NUMBER |
218218
| file_target | /FOLDER |
219-
| permissions | 17 |
219+
| permissions | 1 |
220220
| stime | A_NUMBER |
221221
| expiration | +3 days |
222222
| token | A_TOKEN |
@@ -267,7 +267,7 @@ Feature: sharing
267267
| share_type | 3 |
268268
| file_source | A_NUMBER |
269269
| file_target | /FOLDER |
270-
| permissions | 17 |
270+
| permissions | 1 |
271271
| stime | A_NUMBER |
272272
| token | A_TOKEN |
273273
| storage | A_NUMBER |

0 commit comments

Comments
 (0)