Skip to content
Snippets Groups Projects
Unverified Commit 275f15c1 authored by Morris Jobke's avatar Morris Jobke Committed by GitHub
Browse files

Merge pull request #23261 from nextcloud/enh/external-storage-session-type

Expose session based authentication through mount point type
parents 171373a9 35e5cc88
No related branches found
No related tags found
No related merge requests found
...@@ -161,6 +161,7 @@ class ConfigAdapter implements IMountProvider { ...@@ -161,6 +161,7 @@ class ConfigAdapter implements IMountProvider {
if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) { if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
return new PersonalMount( return new PersonalMount(
$this->userStoragesService, $this->userStoragesService,
$storageConfig,
$storageConfig->getId(), $storageConfig->getId(),
$storage, $storage,
'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(), '/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
...@@ -171,6 +172,7 @@ class ConfigAdapter implements IMountProvider { ...@@ -171,6 +172,7 @@ class ConfigAdapter implements IMountProvider {
); );
} else { } else {
return new ExternalMountPoint( return new ExternalMountPoint(
$storageConfig,
$storage, $storage,
'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(), '/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
null, null,
......
...@@ -24,9 +24,20 @@ ...@@ -24,9 +24,20 @@
namespace OCA\Files_External\Config; namespace OCA\Files_External\Config;
use OC\Files\Mount\MountPoint; use OC\Files\Mount\MountPoint;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\Lib\Auth\Password\SessionCredentials;
class ExternalMountPoint extends MountPoint { 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() { public function getMountType() {
return 'external'; return ($this->storageConfig->getAuthMechanism() instanceof SessionCredentials) ? 'external-session' : 'external';
} }
} }
...@@ -28,6 +28,7 @@ namespace OCA\Files_External\Lib; ...@@ -28,6 +28,7 @@ namespace OCA\Files_External\Lib;
use OC\Files\Mount\MoveableMount; use OC\Files\Mount\MoveableMount;
use OCA\Files_External\Config\ExternalMountPoint; use OCA\Files_External\Config\ExternalMountPoint;
use OCA\Files_External\Service\UserStoragesService; use OCA\Files_External\Service\UserStoragesService;
use OCP\Files\Storage\IStorage;
/** /**
* Person mount points can be moved by the user * Person mount points can be moved by the user
...@@ -42,7 +43,7 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount { ...@@ -42,7 +43,7 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount {
/** /**
* @param UserStoragesService $storagesService * @param UserStoragesService $storagesService
* @param int $storageId * @param int $storageId
* @param \OCP\Files\Storage $storage * @param IStorage $storage
* @param string $mountpoint * @param string $mountpoint
* @param array $arguments (optional) configuration for the storage backend * @param array $arguments (optional) configuration for the storage backend
* @param \OCP\Files\Storage\IStorageFactory $loader * @param \OCP\Files\Storage\IStorageFactory $loader
...@@ -50,6 +51,7 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount { ...@@ -50,6 +51,7 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount {
*/ */
public function __construct( public function __construct(
UserStoragesService $storagesService, UserStoragesService $storagesService,
StorageConfig $storageConfig,
$storageId, $storageId,
$storage, $storage,
$mountpoint, $mountpoint,
...@@ -58,7 +60,7 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount { ...@@ -58,7 +60,7 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount {
$mountOptions = null, $mountOptions = null,
$mountId = null $mountId = null
) { ) {
parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId); parent::__construct($storageConfig, $storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
$this->storagesService = $storagesService; $this->storagesService = $storagesService;
$this->numericStorageId = $storageId; $this->numericStorageId = $storageId;
} }
......
...@@ -26,10 +26,12 @@ namespace OCA\Files_External\Tests; ...@@ -26,10 +26,12 @@ namespace OCA\Files_External\Tests;
use OC\Files\Mount\Manager; use OC\Files\Mount\Manager;
use OCA\Files_External\Lib\PersonalMount; use OCA\Files_External\Lib\PersonalMount;
use OCA\Files_External\Lib\StorageConfig;
use Test\TestCase; use Test\TestCase;
class PersonalMountTest extends TestCase { class PersonalMountTest extends TestCase {
public function testFindByStorageId() { public function testFindByStorageId() {
$storageConfig = $this->createMock(StorageConfig::class);
/** @var \OCA\Files_External\Service\UserStoragesService $storageService */ /** @var \OCA\Files_External\Service\UserStoragesService $storageService */
$storageService = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService') $storageService = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService')
->disableOriginalConstructor() ->disableOriginalConstructor()
...@@ -43,7 +45,7 @@ class PersonalMountTest extends TestCase { ...@@ -43,7 +45,7 @@ class PersonalMountTest extends TestCase {
->method('getId') ->method('getId')
->willReturn('dummy'); ->willReturn('dummy');
$mount = new PersonalMount($storageService, 10, $storage, '/foo'); $mount = new PersonalMount($storageService, $storageConfig, 10, $storage, '/foo');
$mountManager = new Manager(); $mountManager = new Manager();
$mountManager->addMount($mount); $mountManager->addMount($mount);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment