diff --git a/apps/files_external/controller/globalstoragescontroller.php b/apps/files_external/controller/globalstoragescontroller.php
index 7d97fdbb4f4..3686a6189b4 100644
--- a/apps/files_external/controller/globalstoragescontroller.php
+++ b/apps/files_external/controller/globalstoragescontroller.php
@@ -98,7 +98,7 @@ class GlobalStoragesController extends StoragesController {
return $newStorage;
}
- $response = $this->validate($newStorage, BackendService::PERMISSION_CREATE);
+ $response = $this->validate($newStorage);
if (!empty($response)) {
return $response;
}
@@ -154,7 +154,7 @@ class GlobalStoragesController extends StoragesController {
}
$storage->setId($id);
- $response = $this->validate($storage, BackendService::PERMISSION_MODIFY);
+ $response = $this->validate($storage);
if (!empty($response)) {
return $response;
}
@@ -180,12 +180,12 @@ class GlobalStoragesController extends StoragesController {
}
/**
- * Get the user type for this controller, used in validation
+ * Get the visibility type for this controller, used in validation
*
- * @return string BackendService::USER_* constants
+ * @return string BackendService::VISIBILITY_* constants
*/
- protected function getUserType() {
- return BackendService::USER_ADMIN;
+ protected function getVisibilityType() {
+ return BackendService::VISIBILITY_ADMIN;
}
diff --git a/apps/files_external/controller/storagescontroller.php b/apps/files_external/controller/storagescontroller.php
index 46202c8ba4a..71055fd1b9c 100644
--- a/apps/files_external/controller/storagescontroller.php
+++ b/apps/files_external/controller/storagescontroller.php
@@ -125,11 +125,10 @@ abstract class StoragesController extends Controller {
* Validate storage config
*
* @param StorageConfig $storage storage config
- * @param int $permissionCheck permission to check
*
* @return DataResponse|null returns response in case of validation error
*/
- protected function validate(StorageConfig $storage, $permissionCheck = BackendService::PERMISSION_CREATE) {
+ protected function validate(StorageConfig $storage) {
$mountPoint = $storage->getMountPoint();
if ($mountPoint === '' || $mountPoint === '/') {
return new DataResponse(
@@ -166,7 +165,7 @@ abstract class StoragesController extends Controller {
);
}
- if (!$backend->isPermitted($this->getUserType(), $permissionCheck)) {
+ if (!$backend->isVisibleFor($this->getVisibilityType())) {
// not permitted to use backend
return new DataResponse(
array(
@@ -177,7 +176,7 @@ abstract class StoragesController extends Controller {
Http::STATUS_UNPROCESSABLE_ENTITY
);
}
- if (!$authMechanism->isPermitted($this->getUserType(), $permissionCheck)) {
+ if (!$authMechanism->isVisibleFor($this->getVisibilityType())) {
// not permitted to use auth mechanism
return new DataResponse(
array(
@@ -212,11 +211,11 @@ abstract class StoragesController extends Controller {
}
/**
- * Get the user type for this controller, used in validation
+ * Get the visibility type for this controller, used in validation
*
- * @return string BackendService::USER_* constants
+ * @return string BackendService::VISIBILITY_* constants
*/
- abstract protected function getUserType();
+ abstract protected function getVisibilityType();
/**
* Check whether the given storage is available / valid.
diff --git a/apps/files_external/controller/userstoragescontroller.php b/apps/files_external/controller/userstoragescontroller.php
index 801c9ab0aae..fcbe692d79e 100644
--- a/apps/files_external/controller/userstoragescontroller.php
+++ b/apps/files_external/controller/userstoragescontroller.php
@@ -103,7 +103,7 @@ class UserStoragesController extends StoragesController {
return $newStorage;
}
- $response = $this->validate($newStorage, BackendService::PERMISSION_CREATE);
+ $response = $this->validate($newStorage);
if (!empty($response)) {
return $response;
}
@@ -151,7 +151,7 @@ class UserStoragesController extends StoragesController {
}
$storage->setId($id);
- $response = $this->validate($storage, BackendService::PERMISSION_MODIFY);
+ $response = $this->validate($storage);
if (!empty($response)) {
return $response;
}
@@ -188,12 +188,12 @@ class UserStoragesController extends StoragesController {
}
/**
- * Get the user type for this controller, used in validation
+ * Get the visibility type for this controller, used in validation
*
- * @return string BackendService::USER_* constants
+ * @return string BackendService::VISIBILITY_* constants
*/
- protected function getUserType() {
- return BackendService::USER_PERSONAL;
+ protected function getVisibilityType() {
+ return BackendService::VISIBILITY_PERSONAL;
}
}
diff --git a/apps/files_external/lib/auth/authmechanism.php b/apps/files_external/lib/auth/authmechanism.php
index ddc0c6a4dca..11d99bb330d 100644
--- a/apps/files_external/lib/auth/authmechanism.php
+++ b/apps/files_external/lib/auth/authmechanism.php
@@ -22,7 +22,7 @@
namespace OCA\Files_External\Lib\Auth;
use \OCA\Files_External\Lib\StorageConfig;
-use \OCA\Files_External\Lib\PermissionsTrait;
+use \OCA\Files_External\Lib\VisibilityTrait;
use \OCA\Files_External\Lib\IdentifierTrait;
use \OCA\Files_External\Lib\FrontendDefinitionTrait;
use \OCA\Files_External\Lib\StorageModifierTrait;
@@ -40,7 +40,7 @@ use \OCA\Files_External\Lib\StorageModifierTrait;
* scheme, which are provided from the authentication mechanism.
*
* This class uses the following traits:
- * - PermissionsTrait
+ * - VisibilityTrait
* Restrict usage to admin-only/none
* - FrontendDefinitionTrait
* Specify configuration parameters and other definitions
@@ -58,7 +58,7 @@ class AuthMechanism implements \JsonSerializable {
const SCHEME_PUBLICKEY = 'publickey';
const SCHEME_OPENSTACK = 'openstack';
- use PermissionsTrait;
+ use VisibilityTrait;
use FrontendDefinitionTrait;
use StorageModifierTrait;
use IdentifierTrait;
diff --git a/apps/files_external/lib/backend/backend.php b/apps/files_external/lib/backend/backend.php
index 2a2add3ac59..90d5d38ed94 100644
--- a/apps/files_external/lib/backend/backend.php
+++ b/apps/files_external/lib/backend/backend.php
@@ -22,7 +22,7 @@
namespace OCA\Files_External\Lib\Backend;
use \OCA\Files_External\Lib\StorageConfig;
-use \OCA\Files_External\Lib\PermissionsTrait;
+use \OCA\Files_External\Lib\VisibilityTrait;
use \OCA\Files_External\Lib\FrontendDefinitionTrait;
use \OCA\Files_External\Lib\PriorityTrait;
use \OCA\Files_External\Lib\DependencyTrait;
@@ -43,7 +43,7 @@ use \OCA\Files_External\Lib\Auth\AuthMechanism;
* scheme, which are provided from the authentication mechanism.
*
* This class uses the following traits:
- * - PermissionsTrait
+ * - VisibilityTrait
* Restrict usage to admin-only/none
* - FrontendDefinitionTrait
* Specify configuration parameters and other definitions
@@ -56,7 +56,7 @@ use \OCA\Files_External\Lib\Auth\AuthMechanism;
*/
class Backend implements \JsonSerializable {
- use PermissionsTrait;
+ use VisibilityTrait;
use FrontendDefinitionTrait;
use PriorityTrait;
use DependencyTrait;
diff --git a/apps/files_external/lib/backend/local.php b/apps/files_external/lib/backend/local.php
index a6635491b6e..a80b437fab7 100644
--- a/apps/files_external/lib/backend/local.php
+++ b/apps/files_external/lib/backend/local.php
@@ -39,7 +39,7 @@ class Local extends Backend {
->addParameters([
(new DefinitionParameter('datadir', $l->t('Location'))),
])
- ->setAllowedPermissions(BackendService::USER_PERSONAL, BackendService::PERMISSION_NONE)
+ ->setAllowedVisibility(BackendService::VISIBILITY_ADMIN)
->setPriority(BackendService::PRIORITY_DEFAULT + 50)
->addAuthScheme(AuthMechanism::SCHEME_NULL)
->setLegacyAuthMechanism($legacyAuth)
diff --git a/apps/files_external/lib/backend/sftp_key.php b/apps/files_external/lib/backend/sftp_key.php
index 6a75172026d..4a7f565eb19 100644
--- a/apps/files_external/lib/backend/sftp_key.php
+++ b/apps/files_external/lib/backend/sftp_key.php
@@ -40,8 +40,6 @@ class SFTP_Key extends Backend {
(new DefinitionParameter('root', $l->t('Remote subfolder')))
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
])
- ->removeAllowedPermission(BackendService::USER_PERSONAL, BackendService::PERMISSION_CREATE)
- ->removeAllowedPermission(BackendService::USER_ADMIN, BackendService::PERMISSION_CREATE)
->addAuthScheme(AuthMechanism::SCHEME_PUBLICKEY)
->setLegacyAuthMechanism($legacyAuth)
;
diff --git a/apps/files_external/lib/backend/smb_oc.php b/apps/files_external/lib/backend/smb_oc.php
index d21b0ddaf42..a3f3a824040 100644
--- a/apps/files_external/lib/backend/smb_oc.php
+++ b/apps/files_external/lib/backend/smb_oc.php
@@ -51,8 +51,6 @@ class SMB_OC extends Backend {
(new DefinitionParameter('root', $l->t('Remote subfolder')))
->setFlag(DefinitionParameter::FLAG_OPTIONAL),
])
- ->removeAllowedPermission(BackendService::USER_PERSONAL, BackendService::PERMISSION_CREATE)
- ->removeAllowedPermission(BackendService::USER_ADMIN, BackendService::PERMISSION_CREATE)
->setPriority(BackendService::PRIORITY_DEFAULT - 10)
->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
->setLegacyAuthMechanism($legacyAuth)
diff --git a/apps/files_external/lib/permissionstrait.php b/apps/files_external/lib/permissionstrait.php
deleted file mode 100644
index 8509a01e422..00000000000
--- a/apps/files_external/lib/permissionstrait.php
+++ /dev/null
@@ -1,164 +0,0 @@
-
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see
class="hidden">
t('Allow users to mount the following external storage')); ?>
- isPermitted(BackendService::USER_PERSONAL, BackendService::PERMISSION_MOUNT)) print_unescaped(' checked="checked"'); ?> />
+ isVisibleFor(BackendService::VISIBILITY_PERSONAL)) print_unescaped(' checked="checked"'); ?> />
diff --git a/apps/files_external/tests/controller/storagescontrollertest.php b/apps/files_external/tests/controller/storagescontrollertest.php
index c43761f3bcb..5e1deb821f4 100644
--- a/apps/files_external/tests/controller/storagescontrollertest.php
+++ b/apps/files_external/tests/controller/storagescontrollertest.php
@@ -75,12 +75,12 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
->willReturn(true);
- $authMech->method('isPermitted')
+ $authMech->method('isVisibleFor')
->willReturn(true);
$backend = $this->getBackendMock();
$backend->method('validateStorage')
->willReturn(true);
- $backend->method('isPermitted')
+ $backend->method('isVisibleFor')
->willReturn(true);
$storageConfig = new StorageConfig(1);
@@ -116,12 +116,12 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
->willReturn(true);
- $authMech->method('isPermitted')
+ $authMech->method('isVisibleFor')
->willReturn(true);
$backend = $this->getBackendMock();
$backend->method('validateStorage')
->willReturn(true);
- $backend->method('isPermitted')
+ $backend->method('isVisibleFor')
->willReturn(true);
$storageConfig = new StorageConfig(1);
@@ -249,12 +249,12 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
->willReturn(true);
- $authMech->method('isPermitted')
+ $authMech->method('isVisibleFor')
->willReturn(true);
$backend = $this->getBackendMock();
$backend->method('validateStorage')
->willReturn(true);
- $backend->method('isPermitted')
+ $backend->method('isVisibleFor')
->willReturn(true);
$storageConfig = new StorageConfig(255);
@@ -338,13 +338,13 @@ abstract class StoragesControllerTest extends \Test\TestCase {
$backend = $this->getBackendMock();
$backend->method('validateStorage')
->willReturn($backendValidate);
- $backend->method('isPermitted')
+ $backend->method('isVisibleFor')
->willReturn(true);
$authMech = $this->getAuthMechMock();
$authMech->method('validateStorage')
->will($this->returnValue($authMechValidate));
- $authMech->method('isPermitted')
+ $authMech->method('isVisibleFor')
->willReturn(true);
$storageConfig = new StorageConfig();
diff --git a/apps/files_external/tests/controller/userstoragescontrollertest.php b/apps/files_external/tests/controller/userstoragescontrollertest.php
index b61174b0797..9f1a8df8d2e 100644
--- a/apps/files_external/tests/controller/userstoragescontrollertest.php
+++ b/apps/files_external/tests/controller/userstoragescontrollertest.php
@@ -49,21 +49,15 @@ class UserStoragesControllerTest extends StoragesControllerTest {
}
public function testAddOrUpdateStorageDisallowedBackend() {
- $backend1 = $this->getBackendMock();
- $backend1->expects($this->once())
- ->method('isPermitted')
- ->with(BackendService::USER_PERSONAL, BackendService::PERMISSION_CREATE)
- ->willReturn(false);
- $backend2 = $this->getBackendMock();
- $backend2->expects($this->once())
- ->method('isPermitted')
- ->with(BackendService::USER_PERSONAL, BackendService::PERMISSION_MODIFY)
+ $backend = $this->getBackendMock();
+ $backend->method('isVisibleFor')
+ ->with(BackendService::VISIBILITY_PERSONAL)
->willReturn(false);
$authMech = $this->getAuthMechMock();
$storageConfig = new StorageConfig(1);
$storageConfig->setMountPoint('mount');
- $storageConfig->setBackend($backend1);
+ $storageConfig->setBackend($backend);
$storageConfig->setAuthMechanism($authMech);
$storageConfig->setBackendOptions([]);
@@ -88,8 +82,6 @@ class UserStoragesControllerTest extends StoragesControllerTest {
$this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
- $storageConfig->setBackend($backend2);
-
$response = $this->controller->update(
1,
'mount',
diff --git a/apps/files_external/tests/service/backendservicetest.php b/apps/files_external/tests/service/backendservicetest.php
index b37b5e9b466..414a9eee2ec 100644
--- a/apps/files_external/tests/service/backendservicetest.php
+++ b/apps/files_external/tests/service/backendservicetest.php
@@ -83,11 +83,11 @@ class BackendServiceTest extends \Test\TestCase {
$backendAllowed = $this->getBackendMock('\User\Mount\Allowed');
$backendAllowed->expects($this->never())
- ->method('removePermission');
+ ->method('removeVisibility');
$backendNotAllowed = $this->getBackendMock('\User\Mount\NotAllowed');
$backendNotAllowed->expects($this->once())
- ->method('removePermission')
- ->with(BackendService::USER_PERSONAL, BackendService::PERMISSION_CREATE | BackendService::PERMISSION_MOUNT);
+ ->method('removeVisibility')
+ ->with(BackendService::VISIBILITY_PERSONAL);
$backendAlias = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend')
->disableOriginalConstructor()