Skip to content

Commit 60a1e72

Browse files
authored
Merge pull request #59962 from nextcloud/fix/delegation/add-acls
fix: add ACLs for calender delegation
2 parents 0f762a0 + d9426a2 commit 60a1e72

7 files changed

Lines changed: 116 additions & 15 deletions

File tree

apps/dav/composer/composer/autoload_classmap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@
9696
'OCA\\DAV\\CalDAV\\Outbox' => $baseDir . '/../lib/CalDAV/Outbox.php',
9797
'OCA\\DAV\\CalDAV\\Plugin' => $baseDir . '/../lib/CalDAV/Plugin.php',
9898
'OCA\\DAV\\CalDAV\\Principal\\Collection' => $baseDir . '/../lib/CalDAV/Principal/Collection.php',
99+
'OCA\\DAV\\CalDAV\\Principal\\ProxyRead' => $baseDir . '/../lib/CalDAV/Principal/ProxyRead.php',
100+
'OCA\\DAV\\CalDAV\\Principal\\ProxyWrite' => $baseDir . '/../lib/CalDAV/Principal/ProxyWrite.php',
99101
'OCA\\DAV\\CalDAV\\Principal\\User' => $baseDir . '/../lib/CalDAV/Principal/User.php',
100102
'OCA\\DAV\\CalDAV\\Proxy\\Proxy' => $baseDir . '/../lib/CalDAV/Proxy/Proxy.php',
101103
'OCA\\DAV\\CalDAV\\Proxy\\ProxyMapper' => $baseDir . '/../lib/CalDAV/Proxy/ProxyMapper.php',

apps/dav/composer/composer/autoload_static.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ class ComposerStaticInitDAV
111111
'OCA\\DAV\\CalDAV\\Outbox' => __DIR__ . '/..' . '/../lib/CalDAV/Outbox.php',
112112
'OCA\\DAV\\CalDAV\\Plugin' => __DIR__ . '/..' . '/../lib/CalDAV/Plugin.php',
113113
'OCA\\DAV\\CalDAV\\Principal\\Collection' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/Collection.php',
114+
'OCA\\DAV\\CalDAV\\Principal\\ProxyRead' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/ProxyRead.php',
115+
'OCA\\DAV\\CalDAV\\Principal\\ProxyWrite' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/ProxyWrite.php',
114116
'OCA\\DAV\\CalDAV\\Principal\\User' => __DIR__ . '/..' . '/../lib/CalDAV/Principal/User.php',
115117
'OCA\\DAV\\CalDAV\\Proxy\\Proxy' => __DIR__ . '/..' . '/../lib/CalDAV/Proxy/Proxy.php',
116118
'OCA\\DAV\\CalDAV\\Proxy\\ProxyMapper' => __DIR__ . '/..' . '/../lib/CalDAV/Proxy/ProxyMapper.php',
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\DAV\CalDAV\Principal;
11+
12+
use Sabre\DAVACL;
13+
14+
class ProxyRead extends \Sabre\CalDAV\Principal\ProxyRead implements DAVACL\IACL {
15+
use DAVACL\ACLTrait;
16+
17+
/**
18+
* @inheritDoc
19+
*/
20+
public function getOwner() {
21+
return $this->principalInfo['uri'];
22+
}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
10+
namespace OCA\DAV\CalDAV\Principal;
11+
12+
use Sabre\DAVACL;
13+
14+
class ProxyWrite extends \Sabre\CalDAV\Principal\ProxyWrite implements DAVACL\IACL {
15+
use DAVACL\ACLTrait;
16+
17+
/**
18+
* @inheritDoc
19+
*/
20+
public function getOwner() {
21+
return $this->principalInfo['uri'];
22+
}
23+
}

apps/dav/lib/CalDAV/Principal/User.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,44 @@ public function getACL() {
3636
];
3737
return $acl;
3838
}
39+
40+
/**
41+
* Returns a specific child node, referenced by its name.
42+
*
43+
* @param string $name
44+
*
45+
* @return \Sabre\DAV\INode
46+
*/
47+
public function getChild($name) {
48+
$principal = $this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/' . $name);
49+
if (!$principal) {
50+
throw new \Sabre\DAV\Exception\NotFound("Node with name $name was not found");
51+
}
52+
if ($name === 'calendar-proxy-read') {
53+
return new ProxyRead($this->principalBackend, $this->principalProperties);
54+
}
55+
56+
if ($name === 'calendar-proxy-write') {
57+
return new ProxyWrite($this->principalBackend, $this->principalProperties);
58+
}
59+
60+
throw new \Sabre\DAV\Exception\NotFound("Node with name $name was not found");
61+
}
62+
63+
/**
64+
* Returns an array with all the child nodes.
65+
*
66+
* @return \Sabre\DAV\INode[]
67+
*/
68+
public function getChildren() {
69+
$r = [];
70+
if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-read')) {
71+
$r[] = new ProxyRead($this->principalBackend, $this->principalProperties);
72+
}
73+
if ($this->principalBackend->getPrincipalByPath($this->getPrincipalURL() . '/calendar-proxy-write')) {
74+
$r[] = new ProxyWrite($this->principalBackend, $this->principalProperties);
75+
}
76+
77+
return $r;
78+
}
3979
}

build/integration/dav_features/caldav-delegation.feature

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,11 @@ Feature: calendar delegation
2020
When "admin" updates property "{DAV:}group-member-set" to href "/remote.php/dav/principals/users/user0" of principal "users/admin/calendar-proxy-write" on the endpoint "/remote.php/dav/principals/"
2121
Then The CalDAV response should be multi status
2222
And The CalDAV response should contain an href "/remote.php/dav/principals/users/admin/calendar-proxy-write"
23-
And The CalDAV response should contain a property "{DAV:}group-member-set"
23+
And The CalDAV response should contain a property "{DAV:}group-member-set"
24+
25+
Scenario: Admin cannot grant User1 access to User0's calendar account
26+
Given user "admin" exists
27+
And user "user0" exists
28+
And user "user1" exists
29+
When "admin" updates property "{DAV:}group-member-set" to href "/remote.php/dav/principals/users/user1" of principal "users/user0/calendar-proxy-write" on the endpoint "/remote.php/dav/principals/"
30+
Then The CalDAV HTTP status code should be "404"

build/integration/features/bootstrap/CalDavContext.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -408,19 +408,23 @@ public function updatesHrefPropertyOfPrincipal(
408408
$xml = new \Sabre\Xml\Service();
409409
$body = $xml->write('{DAV:}propertyupdate', $propPatch, '/');
410410

411-
$this->response = $this->client->request(
412-
'PROPPATCH',
413-
$davUrl,
414-
[
415-
'headers' => [
416-
'Content-Type' => 'application/xml; charset=UTF-8',
417-
],
418-
'body' => $body,
419-
'auth' => [
420-
$user,
421-
$password,
422-
],
423-
]
424-
);
411+
try {
412+
$this->response = $this->client->request(
413+
'PROPPATCH',
414+
$davUrl,
415+
[
416+
'headers' => [
417+
'Content-Type' => 'application/xml; charset=UTF-8',
418+
],
419+
'body' => $body,
420+
'auth' => [
421+
$user,
422+
$password,
423+
],
424+
]
425+
);
426+
} catch (\GuzzleHttp\Exception\ClientException $e) {
427+
$this->response = $e->getResponse();
428+
}
425429
}
426430
}

0 commit comments

Comments
 (0)