Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2015-08-04 19:33:19 +0300
committerBjoern Schiessle <schiessle@owncloud.com>2015-08-04 19:33:19 +0300
commitdc5e89e624ca7bcc5ff4f9ce5068ccbc75cda7f6 (patch)
treead7dc793c875af12fb232bb0ef9e291e9de12ea3 /settings/controller
parent573177d1768dd69dde94106919a61344f4146794 (diff)
also block certificate management in the back-end if external storages are disabled for the user
Diffstat (limited to 'settings/controller')
-rw-r--r--settings/controller/certificatecontroller.php34
1 files changed, 33 insertions, 1 deletions
diff --git a/settings/controller/certificatecontroller.php b/settings/controller/certificatecontroller.php
index ea20b7c587f..92d0961efb7 100644
--- a/settings/controller/certificatecontroller.php
+++ b/settings/controller/certificatecontroller.php
@@ -21,6 +21,7 @@
namespace OC\Settings\Controller;
+use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -36,20 +37,25 @@ class CertificateController extends Controller {
private $certificateManager;
/** @var IL10N */
private $l10n;
+ /** @var IAppManager */
+ private $appManager;
/**
* @param string $appName
* @param IRequest $request
* @param ICertificateManager $certificateManager
* @param IL10N $l10n
+ * @param IAppManager $appManager
*/
public function __construct($appName,
IRequest $request,
ICertificateManager $certificateManager,
- IL10N $l10n) {
+ IL10N $l10n,
+ IAppManager $appManager) {
parent::__construct($appName, $request);
$this->certificateManager = $certificateManager;
$this->l10n = $l10n;
+ $this->appManager = $appManager;
}
/**
@@ -60,6 +66,11 @@ class CertificateController extends Controller {
* @return array
*/
public function addPersonalRootCertificate() {
+
+ if ($this->isCertificateImportAllowed() === false) {
+ return new DataResponse('Individual certificate management disabled', Http::STATUS_FORBIDDEN);
+ }
+
$file = $this->request->getUploadedFile('rootcert_import');
if(empty($file)) {
return new DataResponse(['message' => 'No file uploaded'], Http::STATUS_UNPROCESSABLE_ENTITY);
@@ -92,8 +103,29 @@ class CertificateController extends Controller {
* @return DataResponse
*/
public function removePersonalRootCertificate($certificateIdentifier) {
+
+ if ($this->isCertificateImportAllowed() === false) {
+ return new DataResponse('Individual certificate management disabled', Http::STATUS_FORBIDDEN);
+ }
+
$this->certificateManager->removeCertificate($certificateIdentifier);
return new DataResponse();
}
+ /**
+ * check if certificate import is allowed
+ *
+ * @return bool
+ */
+ protected function isCertificateImportAllowed() {
+ $externalStorageEnabled = $this->appManager->isEnabledForUser('files_external');
+ if ($externalStorageEnabled) {
+ $backends = \OC_Mount_Config::getPersonalBackends();
+ if (!empty($backends)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
}