Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/dav/appinfo/v1/publicwebdav.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -124,6 +125,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);
Expand Down
20 changes: 20 additions & 0 deletions build/integration/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,26 @@ public function downloadingPublicFile(string $filename) {
}
}

#[When('Downloading public file :filename from legacy public webdav')]
public function downloadingPublicFileFromLegacyWebdav(string $filename) {
$token = $this->lastShareData->data->token;
$fullUrl = substr($this->baseUrl, 0, -4) . "public.php/webdav/$filename";

$client = new GClient();
$options = [
'auth' => [$token, ''],
'headers' => [
'X-Requested-With' => 'XMLHttpRequest',
]
];

try {
$this->response = $client->request('GET', $fullUrl, $options);
} catch (\GuzzleHttp\Exception\ClientException $e) {
$this->response = $e->getResponse();
}
}

#[When('Downloading public file :filename without ajax header')]
public function downloadingPublicFileWithoutHeader(string $filename) {
$token = $this->lastShareData->data->token;
Expand Down
23 changes: 23 additions & 0 deletions build/integration/sharing_features/sharing-v1-part2.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading