Require read permissions for federated shares

Else they end up as weird shares that can't be properly utilized by
other parties anyway.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2021-04-19 12:53:49 +02:00 committed by backportbot[bot]
parent 19fb6d7651
commit 46823e8f68
1 changed files with 8 additions and 0 deletions

View File

@ -35,6 +35,7 @@ namespace OCA\FederatedFileSharing;
use OC\Share20\Exception\InvalidShare; use OC\Share20\Exception\InvalidShare;
use OC\Share20\Share; use OC\Share20\Share;
use OCP\Constants;
use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Federation\ICloudFederationProviderManager; use OCP\Federation\ICloudFederationProviderManager;
use OCP\Federation\ICloudIdManager; use OCP\Federation\ICloudIdManager;
@ -204,6 +205,13 @@ class FederatedShareProvider implements IShareProvider {
throw new \Exception($message_t); throw new \Exception($message_t);
} }
// Federated shares always have read permissions
if (($share->getPermissions() & Constants::PERMISSION_READ) === 0) {
$message = 'Federated shares require read permissions';
$message_t = $this->l->t('Federated shares require read permissions');
$this->logger->debug($message, ['app' => 'Federated File Sharing']);
throw new \Exception($message_t);
}
$share->setSharedWith($cloudId->getId()); $share->setSharedWith($cloudId->getId());