From 3c8106d511ac9865ba17caadd24324ce7f2fca04 Mon Sep 17 00:00:00 2001 From: SebastianKrupinski Date: Mon, 1 Jul 2024 11:48:02 -0400 Subject: [PATCH] fix(dav): Thrown forbidden error for authenticated user instead of not found Signed-off-by: SebastianKrupinski --- apps/dav/lib/Connector/Sabre/DavAclPlugin.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/dav/lib/Connector/Sabre/DavAclPlugin.php b/apps/dav/lib/Connector/Sabre/DavAclPlugin.php index 8e5000fa9fb87..9891a8cab0d9f 100644 --- a/apps/dav/lib/Connector/Sabre/DavAclPlugin.php +++ b/apps/dav/lib/Connector/Sabre/DavAclPlugin.php @@ -31,6 +31,7 @@ use OCA\DAV\CalDAV\Calendar; use OCA\DAV\CardDAV\AddressBook; use Sabre\CalDAV\Principal\User; +use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\NotFound; use Sabre\DAV\INode; use Sabre\DAV\PropFind; @@ -69,13 +70,19 @@ public function checkPrivileges($uri, $privileges, $recursion = self::R_PARENT, $type = 'Node'; break; } - throw new NotFound( - sprintf( - "%s with name '%s' could not be found", - $type, - $node->getName() - ) - ); + + if ($this->getCurrentUserPrincipal() === $node->getOwner()) { + throw new Forbidden("Access denied"); + } else { + throw new NotFound( + sprintf( + "%s with name '%s' could not be found", + $type, + $node->getName() + ) + ); + } + } return $access;