aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2021-01-07 21:29:13 +0100
committerGitHub <noreply@github.com>2021-01-07 21:29:13 +0100
commit275f15c1fb38175468cb06ecaeedeb402b64c8d2 (patch)
tree7a4ed88593aa28c243d09ec5c56fbdb6a1e251b1 /apps
parent171373a9442ee5af5b42b3989afbe2fa7ad99fbd (diff)
parent35e5cc88f0e77738bbe47a01d4f95bc9ad40f2f0 (diff)
downloadnextcloud-server-275f15c1fb38175468cb06ecaeedeb402b64c8d2.tar.gz
nextcloud-server-275f15c1fb38175468cb06ecaeedeb402b64c8d2.zip
Merge pull request #23261 from nextcloud/enh/external-storage-session-type
Expose session based authentication through mount point type
Diffstat (limited to 'apps')
-rw-r--r--apps/files_external/lib/Config/ConfigAdapter.php2
-rw-r--r--apps/files_external/lib/Config/ExternalMountPoint.php13
-rw-r--r--apps/files_external/lib/Lib/PersonalMount.php6
-rw-r--r--apps/files_external/tests/PersonalMountTest.php4
4 files changed, 21 insertions, 4 deletions
diff --git a/apps/files_external/lib/Config/ConfigAdapter.php b/apps/files_external/lib/Config/ConfigAdapter.php
index 816b4374629..2528c090d66 100644
--- a/apps/files_external/lib/Config/ConfigAdapter.php
+++ b/apps/files_external/lib/Config/ConfigAdapter.php
@@ -161,6 +161,7 @@ class ConfigAdapter implements IMountProvider {
if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
return new PersonalMount(
$this->userStoragesService,
+ $storageConfig,
$storageConfig->getId(),
$storage,
'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
@@ -171,6 +172,7 @@ class ConfigAdapter implements IMountProvider {
);
} else {
return new ExternalMountPoint(
+ $storageConfig,
$storage,
'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
null,
diff --git a/apps/files_external/lib/Config/ExternalMountPoint.php b/apps/files_external/lib/Config/ExternalMountPoint.php
index 5c9bbc71e36..1eac000a97f 100644
--- a/apps/files_external/lib/Config/ExternalMountPoint.php
+++ b/apps/files_external/lib/Config/ExternalMountPoint.php
@@ -24,9 +24,20 @@
namespace OCA\Files_External\Config;
use OC\Files\Mount\MountPoint;
+use OCA\Files_External\Lib\StorageConfig;
+use OCA\Files_External\Lib\Auth\Password\SessionCredentials;
class ExternalMountPoint extends MountPoint {
+
+ /** @var StorageConfig */
+ protected $storageConfig;
+
+ public function __construct(StorageConfig $storageConfig, $storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
+ $this->storageConfig = $storageConfig;
+ parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
+ }
+
public function getMountType() {
- return 'external';
+ return ($this->storageConfig->getAuthMechanism() instanceof SessionCredentials) ? 'external-session' : 'external';
}
}
diff --git a/apps/files_external/lib/Lib/PersonalMount.php b/apps/files_external/lib/Lib/PersonalMount.php
index 8f3a127632e..d8f2aeea56e 100644
--- a/apps/files_external/lib/Lib/PersonalMount.php
+++ b/apps/files_external/lib/Lib/PersonalMount.php
@@ -28,6 +28,7 @@ namespace OCA\Files_External\Lib;
use OC\Files\Mount\MoveableMount;
use OCA\Files_External\Config\ExternalMountPoint;
use OCA\Files_External\Service\UserStoragesService;
+use OCP\Files\Storage\IStorage;
/**
* Person mount points can be moved by the user
@@ -42,7 +43,7 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount {
/**
* @param UserStoragesService $storagesService
* @param int $storageId
- * @param \OCP\Files\Storage $storage
+ * @param IStorage $storage
* @param string $mountpoint
* @param array $arguments (optional) configuration for the storage backend
* @param \OCP\Files\Storage\IStorageFactory $loader
@@ -50,6 +51,7 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount {
*/
public function __construct(
UserStoragesService $storagesService,
+ StorageConfig $storageConfig,
$storageId,
$storage,
$mountpoint,
@@ -58,7 +60,7 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount {
$mountOptions = null,
$mountId = null
) {
- parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
+ parent::__construct($storageConfig, $storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
$this->storagesService = $storagesService;
$this->numericStorageId = $storageId;
}
diff --git a/apps/files_external/tests/PersonalMountTest.php b/apps/files_external/tests/PersonalMountTest.php
index 092379cf064..7d5179104bb 100644
--- a/apps/files_external/tests/PersonalMountTest.php
+++ b/apps/files_external/tests/PersonalMountTest.php
@@ -26,10 +26,12 @@ namespace OCA\Files_External\Tests;
use OC\Files\Mount\Manager;
use OCA\Files_External\Lib\PersonalMount;
+use OCA\Files_External\Lib\StorageConfig;
use Test\TestCase;
class PersonalMountTest extends TestCase {
public function testFindByStorageId() {
+ $storageConfig = $this->createMock(StorageConfig::class);
/** @var \OCA\Files_External\Service\UserStoragesService $storageService */
$storageService = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService')
->disableOriginalConstructor()
@@ -43,7 +45,7 @@ class PersonalMountTest extends TestCase {
->method('getId')
->willReturn('dummy');
- $mount = new PersonalMount($storageService, 10, $storage, '/foo');
+ $mount = new PersonalMount($storageService, $storageConfig, 10, $storage, '/foo');
$mountManager = new Manager();
$mountManager->addMount($mount);