summaryrefslogtreecommitdiffstats
path: root/apps/files_external/service/storagesservice.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/service/storagesservice.php')
-rw-r--r--apps/files_external/service/storagesservice.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/apps/files_external/service/storagesservice.php b/apps/files_external/service/storagesservice.php
index d3bde0ae96c..b8a1824ba23 100644
--- a/apps/files_external/service/storagesservice.php
+++ b/apps/files_external/service/storagesservice.php
@@ -82,8 +82,22 @@ abstract class StoragesService {
$storageOptions
) {
$backend = $this->backendService->getBackend($storageOptions['class']);
+ if (!$backend) {
+ throw new \UnexpectedValueException('Invalid backend class');
+ }
$storageConfig->setBackend($backend);
+ if (isset($storageOptions['authMechanism'])) {
+ $authMechanism = $this->backendService->getAuthMechanism($storageOptions['authMechanism']);
+ } else {
+ $authMechanism = $backend->getLegacyAuthMechanism($storageOptions);
+ $storageOptions['authMechanism'] = 'null'; // to make error handling easier
+ }
+ if (!$authMechanism) {
+ throw new \UnexpectedValueException('Invalid authentication mechanism class');
+ }
+ $storageConfig->setAuthMechanism($authMechanism);
+
$storageConfig->setBackendOptions($storageOptions['options']);
if (isset($storageOptions['mountOptions'])) {
$storageConfig->setMountOptions($storageOptions['mountOptions']);
@@ -128,6 +142,7 @@ abstract class StoragesService {
* - "priority": storage priority
* - "backend": backend class name
* - "options": backend-specific options
+ * - "authMechanism": authentication mechanism class name
* - "mountOptions": mount-specific options (ex: disable previews, scanner, etc)
*/
@@ -257,6 +272,7 @@ abstract class StoragesService {
$options = [
'id' => $storageConfig->getId(),
'class' => $storageConfig->getBackend()->getClass(),
+ 'authMechanism' => $storageConfig->getAuthMechanism()->getClass(),
'options' => $storageConfig->getBackendOptions(),
];
@@ -335,6 +351,7 @@ abstract class StoragesService {
*
* @param string $mountPoint storage mount point
* @param string $backendClass backend class name
+ * @param string $authMechanismClass authentication mechanism class
* @param array $backendOptions backend-specific options
* @param array|null $mountOptions mount-specific options
* @param array|null $applicableUsers users for which to mount the storage
@@ -346,6 +363,7 @@ abstract class StoragesService {
public function createStorage(
$mountPoint,
$backendClass,
+ $authMechanismClass,
$backendOptions,
$mountOptions = null,
$applicableUsers = null,
@@ -356,9 +374,14 @@ abstract class StoragesService {
if (!$backend) {
throw new \InvalidArgumentException('Unable to get backend for backend class '.$backendClass);
}
+ $authMechanism = $this->backendService->getAuthMechanism($authMechanismClass);
+ if (!$authMechanism) {
+ throw new \InvalidArgumentException('Unable to get authentication mechanism for class '.$authMechanismClass);
+ }
$newStorage = new StorageConfig();
$newStorage->setMountPoint($mountPoint);
$newStorage->setBackend($backend);
+ $newStorage->setAuthMechanism($authMechanism);
$newStorage->setBackendOptions($backendOptions);
if (isset($mountOptions)) {
$newStorage->setMountOptions($mountOptions);