Skip to content

Commit

Permalink
Disable sharing calendars via link adjusted
Browse files Browse the repository at this point in the history
Fixes: 45eefc2
Related: #34372
Author-Change-Id: IB#1126264
Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
  • Loading branch information
pboguslawski authored and tcitworld committed Jan 20, 2023
1 parent f931259 commit bbaf2af
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
9 changes: 0 additions & 9 deletions apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @copyright Copyright (c) 2016, ownCloud, Inc.
* @copyright Copyright (c) 2018 Georg Ehrke
* @copyright Copyright (c) 2020, leith abdulla (<online-nextcloud@eleith.com>)
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* @author Chih-Hsuan Yen <yan12125@gmail.com>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
Expand Down Expand Up @@ -498,10 +497,6 @@ public function getUsersOwnCalendars($principalUri) {
* @return array
*/
public function getPublicCalendars() {
// Sharing via link must be enabled.
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) {
return array_values([]);
}
$fields = array_column($this->propertyMap, 0);
$fields[] = 'a.id';
$fields[] = 'a.uri';
Expand Down Expand Up @@ -560,10 +555,6 @@ public function getPublicCalendars() {
* @throws NotFound
*/
public function getPublicCalendar($uri) {
// Sharing via link must be enabled.
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) {
throw new NotFound('Node with name \'' . $uri . '\' could not be found');
}
$fields = array_column($this->propertyMap, 0);
$fields[] = 'a.id';
$fields[] = 'a.uri';
Expand Down
6 changes: 6 additions & 0 deletions apps/dav/lib/CalDAV/PublicCalendarRoot.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
Expand Down Expand Up @@ -29,6 +30,7 @@
use OCP\IL10N;
use Psr\Log\LoggerInterface;
use Sabre\DAV\Collection;
use Sabre\DAV\Exception\Forbidden;

class PublicCalendarRoot extends Collection {

Expand Down Expand Up @@ -70,6 +72,10 @@ public function getName() {
* @inheritdoc
*/
public function getChild($name) {
// Sharing via link is allowed by default, but if the option is set it should be checked.
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no' ) {
throw new \Sabre\DAV\Exception\Forbidden();
}
$calendar = $this->caldavBackend->getPublicCalendar($name);
return new PublicCalendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
}
Expand Down
6 changes: 0 additions & 6 deletions apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
/**
* @copyright Copyright (c) 2016 Thomas Citharel <tcit@tcit.fr>
* @copyright Copyright (c) 2022 Informatyka Boguslawski sp. z o.o. sp.k., http://www.ib.pl/
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Georg Ehrke <oc.list@georgehrke.com>
Expand Down Expand Up @@ -206,11 +205,6 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
}
}

// Sharing via link must be enabled.
if ($this->config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'no') {
return;
}

$node->setPublishStatus(true);

// iCloud sends back the 202, so we will too.
Expand Down
10 changes: 6 additions & 4 deletions apps/dav/lib/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,12 @@ public function __construct(IRequest $request, string $baseUri) {

$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest(), \OC::$server->getConfig()));
$this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
\OC::$server->getConfig(),
\OC::$server->getURLGenerator()
));
if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
$this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
\OC::$server->getConfig(),
\OC::$server->getURLGenerator()
));
}
}

// addressbook plugins
Expand Down

0 comments on commit bbaf2af

Please sign in to comment.