소스 검색

Merge pull request #44376 from nextcloud/fix/dav/acls-shared-addressbook

fix(dav): ACLs for shared addressbooks
Hamza 2 달 전
부모
커밋
007b54afed
3개의 변경된 파일8개의 추가작업 그리고 3개의 파일을 삭제
  1. 6 1
      apps/dav/lib/CardDAV/AddressBook.php
  2. 1 1
      apps/dav/lib/DAV/Sharing/Backend.php
  3. 1 1
      apps/dav/tests/unit/CardDAV/AddressBookTest.php

+ 6 - 1
apps/dav/lib/CardDAV/AddressBook.php

@@ -118,7 +118,7 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable, IMov
 			],
 			[
 				'privilege' => '{DAV:}write-properties',
-				'principal' => '{DAV:}authenticated',
+				'principal' => $this->getOwner(),
 				'protected' => true,
 			],
 		];
@@ -129,6 +129,11 @@ class AddressBook extends \Sabre\CardDAV\AddressBook implements IShareable, IMov
 				'principal' => '{DAV:}authenticated',
 				'protected' => true,
 			];
+			$acl[] = [
+				'privilege' => '{DAV:}write-properties',
+				'principal' => '{DAV:}authenticated',
+				'protected' => true,
+			];
 		}
 
 		if (!$this->isShared()) {

+ 1 - 1
apps/dav/lib/DAV/Sharing/Backend.php

@@ -214,7 +214,7 @@ abstract class Backend {
 					'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'],
 					'protected' => true,
 				];
-			} elseif ($this->service->getResourceType() === 'calendar') {
+			} elseif (in_array($this->service->getResourceType(), ['calendar','addressbook'])) {
 				// Allow changing the properties of read only calendars,
 				// so users can change the visibility.
 				$acl[] = [

+ 1 - 1
apps/dav/tests/unit/CardDAV/AddressBookTest.php

@@ -169,7 +169,7 @@ class AddressBookTest extends TestCase {
 			'protected' => true
 		], [
 			'privilege' => '{DAV:}write-properties',
-			'principal' => '{DAV:}authenticated',
+			'principal' => $hasOwnerSet ? 'user1' : 'user2',
 			'protected' => true
 		]];
 		if ($hasOwnerSet) {