From ef34f72167b7992fc24974187a306c808dcbd7cf Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 6 May 2020 21:39:49 +0200 Subject: [PATCH 1/3] Have share permissions on link shares if it is enabled Signed-off-by: Roeland Jago Douma --- .../lib/Controller/ShareAPIController.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 49320d57f16f5..0fbd57b471334 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -216,15 +216,6 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array $result['expiration'] = $expiration->format('Y-m-d 00:00:00'); } - // TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones - // For link shares, we need to have the PERMISSION_SHARE if federated is enabled - if ($this->shareManager->outgoingServer2ServerSharesAllowed()) { - if ($share->getShareType() === IShare::TYPE_LINK - || $share->getShareType() === IShare::TYPE_EMAIL) { - $result['permissions'] |= Constants::PERMISSION_SHARE; - } - } - if ($share->getShareType() === IShare::TYPE_USER) { $sharedWith = $this->userManager->get($share->getSharedWith()); $result['share_with'] = $share->getSharedWith(); @@ -511,6 +502,11 @@ public function createShare( $permissions = Constants::PERMISSION_READ; } + // TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones + if (($permissions & Constants::PERMISSION_READ) && $this->shareManager->outgoingServer2ServerSharesAllowed()) { + $permissions |= Constants::PERMISSION_SHARE; + } + $share->setPermissions($permissions); // Set password @@ -1055,6 +1051,11 @@ public function updateShare( } if ($newPermissions !== null) { + // TODO: It might make sense to have a dedicated setting to allow/deny converting link shares into federated ones + if (($newPermissions & Constants::PERMISSION_READ) && $this->shareManager->outgoingServer2ServerSharesAllowed()) { + $newPermissions |= Constants::PERMISSION_SHARE; + } + $share->setPermissions($newPermissions); $permissions = $newPermissions; } From 108faf25c0bb4de14c7084620975f6ea52ca514b Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 6 May 2020 21:49:26 +0200 Subject: [PATCH 2/3] Update public link share permission code Signed-off-by: Roeland Jago Douma --- build/integration/sharing_features/sharing-v1.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/integration/sharing_features/sharing-v1.feature b/build/integration/sharing_features/sharing-v1.feature index eb8006e565b31..51a627dc6dec9 100644 --- a/build/integration/sharing_features/sharing-v1.feature +++ b/build/integration/sharing_features/sharing-v1.feature @@ -195,7 +195,7 @@ Feature: sharing | share_type | 3 | | file_source | A_NUMBER | | file_target | /FOLDER | - | permissions | 15 | + | permissions | 31 | | stime | A_NUMBER | | token | A_TOKEN | | storage | A_NUMBER | @@ -259,7 +259,7 @@ Feature: sharing | share_type | 3 | | file_source | A_NUMBER | | file_target | /FOLDER | - | permissions | 15 | + | permissions | 31 | | stime | A_NUMBER | | token | A_TOKEN | | storage | A_NUMBER | From 8289565bc7d19f571899263fd76d2c3cc7484e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 15 May 2020 08:19:31 +0200 Subject: [PATCH 3/3] Fix share update test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/files_sharing/tests/ApiTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 365ea8dcb8e59..9e7d8e5c693c6 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -999,7 +999,8 @@ public function testUpdateShareUpload() { \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | - \OCP\Constants::PERMISSION_DELETE, + \OCP\Constants::PERMISSION_DELETE | + \OCP\Constants::PERMISSION_SHARE, $share1->getPermissions() );