From f5fcfb4670f31571e0f0e63f106bb4a57bd489c6 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 c499f806ebaa9..336930cf17d99 100644 --- a/apps/dav/lib/Connector/Sabre/DavAclPlugin.php +++ b/apps/dav/lib/Connector/Sabre/DavAclPlugin.php @@ -11,6 +11,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; @@ -49,13 +50,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;