diff --git a/apps/dav/appinfo/v1/publicwebdav.php b/apps/dav/appinfo/v1/publicwebdav.php index 4dbf058bf239f..3bfc90c05e390 100644 --- a/apps/dav/appinfo/v1/publicwebdav.php +++ b/apps/dav/appinfo/v1/publicwebdav.php @@ -16,6 +16,7 @@ use OCA\DAV\Files\Sharing\FilesDropPlugin; use OCA\DAV\Files\Sharing\PublicLinkCheckPlugin; use OCA\DAV\Storage\PublicOwnerWrapper; +use OCA\DAV\Storage\PublicShareWrapper; use OCA\FederatedFileSharing\FederatedShareProvider; use OCP\App\IAppManager; use OCP\BeforeSabrePubliclyLoadedEvent; @@ -130,6 +131,10 @@ function (\Sabre\DAV\Server $server) use ( Filesystem::addStorageWrapper('shareOwner', function (string $mountPoint, IStorage $storage) use ($share) { return new PublicOwnerWrapper(['storage' => $storage, 'owner' => $share->getShareOwner()]); }); + // Ensure that also private shares have the `getShare` method + Filesystem::addStorageWrapper('getShare', function (string $mountPoint, IStorage $storage) use ($share) { + return new PublicShareWrapper(['storage' => $storage, 'share' => $share]); + }, 0); Filesystem::logWarningWhenAddingStorageWrapper($previousLog); $rootFolder = Server::get(IRootFolder::class); diff --git a/build/integration/sharing_features/sharing-v1-part2.feature b/build/integration/sharing_features/sharing-v1-part2.feature index aa9a2390b6e39..20469d7b2ff49 100644 --- a/build/integration/sharing_features/sharing-v1-part2.feature +++ b/build/integration/sharing_features/sharing-v1-part2.feature @@ -1373,6 +1373,29 @@ Scenario: getting all shares of a file with a received share after revoking the And Downloading file "/sharedviewonly/document.odt" Then the HTTP status code should be "200" + Scenario: Cannot download a file from a view-only link share without shareapi_allow_view_without_download + Given As an "admin" + And parameter "shareapi_allow_view_without_download" of app "core" is set to "no" + Given user "user0" exists + And User "user0" created a folder "/sharedviewonly" + And User "user0" moves file "/textfile0.txt" to "/sharedviewonly/document.odt" + And As an "user0" + And creating a share with + | path | /sharedviewonly | + | shareType | 3 | + | permissions | 1 | + | attributes | [{"scope":"permissions","key":"download","value":false}] | + When Downloading public file "document.odt" + Then the HTTP status code should be "403" + When Downloading public file "document.odt" from legacy public webdav + Then the HTTP status code should be "403" + Then As an "admin" + And parameter "shareapi_allow_view_without_download" of app "core" is set to "yes" + When Downloading public file "document.odt" + Then the HTTP status code should be "200" + When Downloading public file "document.odt" from legacy public webdav + Then the HTTP status code should be "200" + Scenario: Cannot copy a file when it's shared view-only even with shareapi_allow_view_without_download enabled Given As an "admin" And parameter "shareapi_allow_view_without_download" of app "core" is set to "no"