From 4adda64d4ea2d27b4a626beeb9f6e4ef181aacf3 Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Mon, 19 Feb 2024 09:39:26 +0100 Subject: [PATCH] perf: skip request without read permission Signed-off-by: Richard Steinmetz --- apps/dav/lib/Connector/Sabre/DavAclPlugin.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/DavAclPlugin.php b/apps/dav/lib/Connector/Sabre/DavAclPlugin.php index f574cec00c6b6..236ca3da7fac7 100644 --- a/apps/dav/lib/Connector/Sabre/DavAclPlugin.php +++ b/apps/dav/lib/Connector/Sabre/DavAclPlugin.php @@ -8,6 +8,7 @@ * @author Robin Appelman * @author Roeland Jago Douma * @author Thomas Müller + * @author Richard Steinmetz * * @license AGPL-3.0 * @@ -105,11 +106,15 @@ public function beforeMethod(RequestInterface $request, ResponseInterface $respo parent::beforeMethod($request, $response); - $createAddressbookOrCalendarRequest = ($request->getMethod() === 'MKCALENDAR' || $request->getMethod() === 'MKCOL') - && (str_starts_with($path, 'addressbooks/') || str_starts_with($path, 'calendars/')); + if (!str_starts_with($path, 'addressbooks/') && !str_starts_with($path, 'calendars/')) { + return; + } - if ($createAddressbookOrCalendarRequest) { - [$parentName] = \Sabre\Uri\split($path); + [$parentName] = \Sabre\Uri\split($path); + if ($request->getMethod() === 'REPORT') { + // is calendars/users/bob or addressbooks/users/bob readable? + $this->checkPrivileges($parentName, '{DAV:}read'); + } elseif ($request->getMethod() === 'MKCALENDAR' || $request->getMethod() === 'MKCOL') { // is calendars/users/bob or addressbooks/users/bob writeable? $this->checkPrivileges($parentName, '{DAV:}write'); }