summaryrefslogtreecommitdiffstats
path: root/lib/private/Lockdown
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-08-01 19:06:54 +0200
committerRobin Appelman <robin@icewind.nl>2016-11-16 15:24:27 +0100
commit2389e0f25065ca9c7afbc70cc13d555524e363a8 (patch)
tree0bd2e8196922e5d62231a67d37a1c07ad876bca9 /lib/private/Lockdown
parentb56f2c9ed01332bbeaee73599a0ea166c62d01e8 (diff)
downloadnextcloud-server-2389e0f25065ca9c7afbc70cc13d555524e363a8.tar.gz
nextcloud-server-2389e0f25065ca9c7afbc70cc13d555524e363a8.zip
read lockdown scope from token
Signed-off-by: Robin Appelman <icewind@owncloud.com>
Diffstat (limited to 'lib/private/Lockdown')
-rw-r--r--lib/private/Lockdown/LockdownManager.php24
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/private/Lockdown/LockdownManager.php b/lib/private/Lockdown/LockdownManager.php
index 9f10646a9dd..150b54bdba2 100644
--- a/lib/private/Lockdown/LockdownManager.php
+++ b/lib/private/Lockdown/LockdownManager.php
@@ -23,24 +23,36 @@ use OC\Authentication\Token\IToken;
use OCP\Lockdown\ILockdownManager;
class LockdownManager implements ILockdownManager {
- /** @var IToken|null */
- private $token;
-
private $enabled = false;
+ /** @var array|null */
+ private $scope;
+
public function enable() {
$this->enabled = true;
}
public function setToken(IToken $token) {
- $this->token = $token;
+ $this->scope = $token->getScope();
+ $this->enable();
}
public function canAccessFilesystem() {
- return true;
+ if (!$this->enabled) {
+ return true;
+ }
+ return !$this->scope || $this->scope['filesystem'];
}
public function canAccessApp($app) {
- return $app === 'logreader' || $app === 'files' || $app === 'dav';
+ if (!$this->enabled) {
+ return true;
+ }
+ if ($this->scope && $this->scope['apps']) {
+ return in_array($app, $this->scope['apps']);
+ } else {
+ // no limit
+ return true;
+ }
}
}