diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-12-15 16:59:46 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-01-02 15:02:18 +0100 |
commit | db3c918adb1aab5e493e2574505b4d87a112081c (patch) | |
tree | beeae15a559f90c5d93c5d57fbe0eed69590e4ad /apps | |
parent | 3c34b8577c7f773bd697512b734062913940a3fd (diff) | |
download | nextcloud-server-db3c918adb1aab5e493e2574505b4d87a112081c.tar.gz nextcloud-server-db3c918adb1aab5e493e2574505b4d87a112081c.zip |
Fix legacy caldav endpoints
* CaldavBackend is now endpoint aware (use old style principals on old
endpoint and new onces on new).
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/appinfo/v1/caldav.php | 2 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Activity/Backend.php | 4 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 30 | ||||
-rw-r--r-- | apps/dav/lib/Connector/LegacyDAVACL.php | 19 |
4 files changed, 23 insertions, 32 deletions
diff --git a/apps/dav/appinfo/v1/caldav.php b/apps/dav/appinfo/v1/caldav.php index 2708f6f39aa..f524c47a821 100644 --- a/apps/dav/appinfo/v1/caldav.php +++ b/apps/dav/appinfo/v1/caldav.php @@ -49,7 +49,7 @@ $db = \OC::$server->getDatabaseConnection(); $userManager = \OC::$server->getUserManager(); $random = \OC::$server->getSecureRandom(); $dispatcher = \OC::$server->getEventDispatcher(); -$calDavBackend = new CalDavBackend($db, $principalBackend, $userManager, $random, $dispatcher); +$calDavBackend = new CalDavBackend($db, $principalBackend, $userManager, $random, $dispatcher, true); $debugging = \OC::$server->getConfig()->getSystemValue('debug', false); diff --git a/apps/dav/lib/CalDAV/Activity/Backend.php b/apps/dav/lib/CalDAV/Activity/Backend.php index 953fdcea832..f8cc82407fd 100644 --- a/apps/dav/lib/CalDAV/Activity/Backend.php +++ b/apps/dav/lib/CalDAV/Activity/Backend.php @@ -103,7 +103,7 @@ class Backend { } $principal = explode('/', $calendarData['principaluri']); - $owner = $principal[2]; + $owner = array_pop($principal); $currentUser = $this->userSession->getUser(); if ($currentUser instanceof IUser) { @@ -369,7 +369,7 @@ class Backend { } $principal = explode('/', $calendarData['principaluri']); - $owner = $principal[2]; + $owner = array_pop($principal); $currentUser = $this->userSession->getUser(); if ($currentUser instanceof IUser) { diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 7a51674d32a..dfef3111324 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -131,6 +131,9 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription /** @var EventDispatcherInterface */ private $dispatcher; + /** @var bool */ + private $legacyEndpoint; + /** * CalDavBackend constructor. * @@ -139,18 +142,21 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription * @param IUserManager $userManager * @param ISecureRandom $random * @param EventDispatcherInterface $dispatcher + * @param bool $legacyEndpoint */ public function __construct(IDBConnection $db, Principal $principalBackend, IUserManager $userManager, ISecureRandom $random, - EventDispatcherInterface $dispatcher) { + EventDispatcherInterface $dispatcher, + $legacyEndpoint = false) { $this->db = $db; $this->principalBackend = $principalBackend; $this->userManager = $userManager; $this->sharingBackend = new Backend($this->db, $principalBackend, 'calendar'); $this->random = $random; $this->dispatcher = $dispatcher; + $this->legacyEndpoint = $legacyEndpoint; } /** @@ -230,12 +236,12 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar = [ 'id' => $row['id'], 'uri' => $row['uri'], - 'principaluri' => $this->convertPrincipal($row['principaluri'], false), + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $principalUri, + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint), ]; foreach($this->propertyMap as $xmlName=>$dbName) { @@ -282,12 +288,12 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar = [ 'id' => $row['id'], 'uri' => $uri, - 'principaluri' => $principalUri, + 'principaluri' => $this->convertPrincipal($principalUri, !$this->legacyEndpoint), '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'], + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ, ]; @@ -328,7 +334,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar = [ 'id' => $row['id'], 'uri' => $row['uri'], - 'principaluri' => $this->convertPrincipal($row['principaluri'], false), + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), @@ -392,12 +398,12 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar = [ 'id' => $row['id'], 'uri' => $row['publicuri'], - 'principaluri' => $row['principaluri'], + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'], + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], $this->legacyEndpoint), '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ, '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC, ]; @@ -456,12 +462,12 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar = [ 'id' => $row['id'], 'uri' => $row['publicuri'], - 'principaluri' => $row['principaluri'], + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), '{' . Plugin::NS_CALDAV . '}schedule-calendar-transp' => new ScheduleCalendarTransp($row['transparent']?'transparent':'opaque'), - '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $row['principaluri'], + '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}owner-principal' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}read-only' => (int)$row['access'] === Backend::ACCESS_READ, '{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}public' => (int)$row['access'] === self::ACCESS_PUBLIC, ]; @@ -510,7 +516,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar = [ 'id' => $row['id'], 'uri' => $row['uri'], - 'principaluri' => $row['principaluri'], + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), @@ -554,7 +560,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription $calendar = [ 'id' => $row['id'], 'uri' => $row['uri'], - 'principaluri' => $row['principaluri'], + 'principaluri' => $this->convertPrincipal($row['principaluri'], !$this->legacyEndpoint), '{' . Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($row['synctoken']?$row['synctoken']:'0'), '{http://sabredav.org/ns}sync-token' => $row['synctoken']?$row['synctoken']:'0', '{' . Plugin::NS_CALDAV . '}supported-calendar-component-set' => new SupportedCalendarComponentSet($components), diff --git a/apps/dav/lib/Connector/LegacyDAVACL.php b/apps/dav/lib/Connector/LegacyDAVACL.php index 83b08ec44fb..d5185ecd03b 100644 --- a/apps/dav/lib/Connector/LegacyDAVACL.php +++ b/apps/dav/lib/Connector/LegacyDAVACL.php @@ -33,24 +33,9 @@ use Sabre\DAVACL\Xml\Property\Principal; class LegacyDAVACL extends DavAclPlugin { /** - * Converts the v1 principal `principal/<username>` to the new v2 - * `principal/users/<username>` which is required for permission checks - * * @inheritdoc */ - function getCurrentUserPrincipal() { - $principalV1 = parent::getCurrentUserPrincipal(); - if (is_null($principalV1)) { - return $principalV1; - } - return $this->convertPrincipal($principalV1, true); - } - - - /** - * @inheritdoc - */ - function getCurrentUserPrincipals() { + public function getCurrentUserPrincipals() { $principalV2 = $this->getCurrentUserPrincipal(); if (is_null($principalV2)) return []; @@ -73,7 +58,7 @@ class LegacyDAVACL extends DavAclPlugin { return "principals/$name"; } - function propFind(PropFind $propFind, INode $node) { + public function propFind(PropFind $propFind, INode $node) { /* Overload current-user-principal */ $propFind->handle('{DAV:}current-user-principal', function () { if ($url = parent::getCurrentUserPrincipal()) { |