Skip to content

Commit

Permalink
Merge pull request #9707 from nextcloud/bugfix-stable13/noid/override…
Browse files Browse the repository at this point in the history
…_freebusy_sharing_rules

[stable13] allow admins to override FreeBusy capabilities without modifying ShareAPI capabilities
  • Loading branch information
MorrisJobke authored Jun 1, 2018
2 parents 3595aa6 + 08ad45e commit 5c92da2
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 87 deletions.
1 change: 1 addition & 0 deletions apps/dav/appinfo/v1/caldav.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
\OC::$server->getGroupManager(),
\OC::$server->getShareManager(),
\OC::$server->getUserSession(),
\OC::$server->getConfig(),
'principals/'
);
$db = \OC::$server->getDatabaseConnection();
Expand Down
1 change: 1 addition & 0 deletions apps/dav/appinfo/v1/carddav.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
\OC::$server->getGroupManager(),
\OC::$server->getShareManager(),
\OC::$server->getUserSession(),
\OC::$server->getConfig(),
'principals/'
);
$db = \OC::$server->getDatabaseConnection();
Expand Down
3 changes: 2 additions & 1 deletion apps/dav/lib/Command/CreateCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$this->userManager,
$this->groupManager,
\OC::$server->getShareManager(),
\OC::$server->getUserSession()
\OC::$server->getUserSession(),
\OC::$server->getConfig()
);
$random = \OC::$server->getSecureRandom();
$logger = \OC::$server->getLogger();
Expand Down
19 changes: 15 additions & 4 deletions apps/dav/lib/Connector/Sabre/Principal.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

namespace OCA\DAV\Connector\Sabre;

use OCP\IConfig;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
Expand All @@ -55,6 +56,9 @@ class Principal implements BackendInterface {
/** @var IUserSession */
private $userSession;

/** @var IConfig */
private $config;

/** @var string */
private $principalPrefix;

Expand All @@ -66,17 +70,20 @@ class Principal implements BackendInterface {
* @param IGroupManager $groupManager
* @param IShareManager $shareManager
* @param IUserSession $userSession
* @param IConfig $config
* @param string $principalPrefix
*/
public function __construct(IUserManager $userManager,
IGroupManager $groupManager,
IShareManager $shareManager,
IUserSession $userSession,
IConfig $config,
$principalPrefix = 'principals/users/') {
$this->userManager = $userManager;
$this->groupManager = $groupManager;
$this->shareManager = $shareManager;
$this->userSession = $userSession;
$this->config = $config;
$this->principalPrefix = trim($principalPrefix, '/');
$this->hasGroups = ($principalPrefix === 'principals/users/');
}
Expand Down Expand Up @@ -206,8 +213,10 @@ function updatePrincipal($path, PropPatch $propPatch) {
protected function searchUserPrincipals(array $searchProperties, $test = 'allof') {
$results = [];

// If sharing is disabled, return the empty array
if (!$this->shareManager->shareApiEnabled()) {
// If sharing is disabled (or FreeBusy was disabled on purpose), return the empty array
$shareAPIEnabled = $this->shareManager->shareApiEnabled();
$disableFreeBusy = $this->config->getAppValue('dav', 'disableFreeBusy', $shareAPIEnabled ? 'no' : 'yes');
if ($disableFreeBusy === 'yes') {
return [];
}

Expand Down Expand Up @@ -290,8 +299,10 @@ function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof')
* @return string
*/
function findByUri($uri, $principalPrefix) {
// If sharing is disabled, return null as in user not found
if (!$this->shareManager->shareApiEnabled()) {
// If sharing is disabled (or FreeBusy was disabled on purpose), return the empty array
$shareAPIEnabled = $this->shareManager->shareApiEnabled();
$disableFreeBusy = $this->config->getAppValue('dav', 'disableFreeBusy', $shareAPIEnabled ? 'no' : 'yes');
if ($disableFreeBusy === 'yes') {
return null;
}

Expand Down
3 changes: 2 additions & 1 deletion apps/dav/lib/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function __construct() {
$userManager,
$groupManager,
$shareManager,
\OC::$server->getUserSession()
\OC::$server->getUserSession(),
$config
);
$groupPrincipalBackend = new GroupPrincipalBackend($groupManager);
// as soon as debug mode is enabled we allow listing of principals
Expand Down
Loading

0 comments on commit 5c92da2

Please sign in to comment.