Skip to content

Commit 278357a

Browse files
committed
fix: Replace the deprecated direct download link with the public DAV endpoint
This currently prevent directly accessing a resource when clicking on a link on a third party site. Example, clicking on `https://example.com/public.php/dav/files/pqLWcA269zfzXez/?accept=zip` in a GitHub comment. Skipping the check is an issue with password protected shares, as it allows third party sites to request the resource when the user already entered the password, aka CSRF. So after removing the check from `base.php`, we need to add it again in the `PublicAuth` plugin. We also add a redirect to be helpful to the user. **Warning**: this adds the limitation that clicking on a direct download link for password protected shares will redirect you to the password form, and then to the main share view. Another solution would be to do the redirect from the front-end. - Fix #52482 - Improved version of original closed PR: #52657 Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent e84cefd commit 278357a

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

3rdparty

Submodule 3rdparty updated 101 files

apps/dav/lib/Connector/Sabre/PublicAuth.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function check(RequestInterface $request, ResponseInterface $response): a
8181
return $this->checkToken();
8282
} catch (NotAuthenticated|MaxDelayReached $e) {
8383
$this->throttler->registerAttempt(self::BRUTEFORCE_ACTION, $this->request->getRemoteAddress());
84+
throw $e;
8485
} catch (NotAuthenticated $e) {
8586
$response->setHeader(
8687
'Location',

apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public function renderPage(IShare $share, string $token, string $path): Template
153153
'token' => $token,
154154
'filename' => ($shareNode instanceof File) ? $shareNode->getName() : null,
155155
]);
156+
// $downloadUrl = $this->urlGenerator->getAbsoluteURL('/public.php/dav/files/' . $token . '/?accept=zip');
156157

157158
// If not a file drop, then add the download header action
158159
$headerActions[] = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $downloadUrl, 0, (string)$shareNode->getSize());

0 commit comments

Comments
 (0)