diff options
author | Julien Veyssier <eneiluj@posteo.net> | 2021-07-30 10:26:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-30 10:26:56 +0200 |
commit | 7170c03f0e11a2f7385d909cd0b98f90e0ce984c (patch) | |
tree | 1b6a16ca246bb85548d7530b0cd57231bed963d1 /apps/provisioning_api/lib/Controller | |
parent | a9b38d824573051cc0d2cfbe981636ba65f5b635 (diff) | |
parent | 416d10f76c9b05a5a1e51058486f6e5cffd6c498 (diff) | |
download | nextcloud-server-7170c03f0e11a2f7385d909cd0b98f90e0ce984c.tar.gz nextcloud-server-7170c03f0e11a2f7385d909cd0b98f90e0ce984c.zip |
Merge pull request #28009 from nextcloud/enh/21045/quota-restrictions
Add quota restrictions options
Diffstat (limited to 'apps/provisioning_api/lib/Controller')
-rw-r--r-- | apps/provisioning_api/lib/Controller/AppConfigController.php | 7 | ||||
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/apps/provisioning_api/lib/Controller/AppConfigController.php b/apps/provisioning_api/lib/Controller/AppConfigController.php index b6e43cac1df..cd8dba9e5b8 100644 --- a/apps/provisioning_api/lib/Controller/AppConfigController.php +++ b/apps/provisioning_api/lib/Controller/AppConfigController.php @@ -162,5 +162,12 @@ class AppConfigController extends OCSController { if ($app === 'core' && (strpos($key, 'public_') === 0 || strpos($key, 'remote_') === 0)) { throw new \InvalidArgumentException('The given key can not be set'); } + + if ($app === 'files' + && $key === 'default_quota' + && $value === 'none' + && $this->config->getAppValue('files', 'allow_unlimited_quota', '1') === '0') { + throw new \InvalidArgumentException('The given key can not be set, unlimited quota is forbidden on this instance'); + } } } diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 01e4bac9c2b..a0eda5848ec 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -798,9 +798,20 @@ class UsersController extends AUserData { if ($quota === -1) { $quota = 'none'; } else { + $maxQuota = (int) $this->config->getAppValue('files', 'max_quota', '-1'); + if ($maxQuota !== -1 && $quota > $maxQuota) { + throw new OCSException('Invalid quota value. ' . $value . ' is exceeding the maximum quota', 102); + } $quota = \OCP\Util::humanFileSize($quota); } } + // no else block because quota can be set to 'none' in previous if + if ($quota === 'none') { + $allowUnlimitedQuota = $this->config->getAppValue('files', 'allow_unlimited_quota', '1') === '1'; + if (!$allowUnlimitedQuota) { + throw new OCSException('Unlimited quota is forbidden on this instance', 102); + } + } $targetUser->setQuota($quota); break; case 'password': |