summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2016-04-01 17:02:59 +0200
committerRoeland Jago Douma <rullzer@owncloud.com>2016-04-08 14:17:05 +0200
commitbd3bde2f3bccb8550f1dbe3c8b254052e8b38865 (patch)
treef447d2e8aeda717e389a1e9f9c92ce82d4da01f5 /lib/private
parent6eefea1bb65897b0a1cf8668b15998a12ae197b9 (diff)
downloadnextcloud-server-bd3bde2f3bccb8550f1dbe3c8b254052e8b38865.tar.gz
nextcloud-server-bd3bde2f3bccb8550f1dbe3c8b254052e8b38865.zip
Set proper permissions on link share
If we do not allow public upload we should limit the permissions on links shares upon retrieval. * Added unit test * Allow fetching federated shares by token as well
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Share20/Manager.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 6c665f7e133..be7257de36d 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -976,7 +976,17 @@ class Manager implements IManager {
public function getShareByToken($token) {
$provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK);
- $share = $provider->getShareByToken($token);
+ try {
+ $share = $provider->getShareByToken($token);
+ } catch (ShareNotFound $e) {
+ //Ignore
+ }
+
+ // If it is not a link share try to fetch a federated share by token
+ if ($share === null) {
+ $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_REMOTE);
+ $share = $provider->getShareByToken($token);
+ }
if ($share->getExpirationDate() !== null &&
$share->getExpirationDate() <= new \DateTime()) {
@@ -984,6 +994,14 @@ class Manager implements IManager {
throw new ShareNotFound();
}
+ /*
+ * Reduce the permissions for link shares if public upload is not enabled
+ */
+ if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
+ !$this->shareApiLinkAllowPublicUpload()) {
+ $share->setPermissions($share->getPermissions() & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE));
+ }
+
return $share;
}