Skip to content

Commit ba9269c

Browse files
committed
Expose session based authentication through mount point type
Signed-off-by: Julius Härtl <[email protected]>
1 parent 2ec160a commit ba9269c

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

apps/files_external/lib/Config/ConfigAdapter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
161161
if ($storageConfig->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) {
162162
return new PersonalMount(
163163
$this->userStoragesService,
164+
$storageConfig,
164165
$storageConfig->getId(),
165166
$storage,
166167
'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
@@ -170,6 +171,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
170171
);
171172
} else {
172173
return new ExternalMountPoint(
174+
$storageConfig,
173175
$storage,
174176
'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
175177
null,

apps/files_external/lib/Config/ExternalMountPoint.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,20 @@
2424
namespace OCA\Files_External\Config;
2525

2626
use OC\Files\Mount\MountPoint;
27+
use OCA\Files_External\Lib\StorageConfig;
28+
use OCA\Files_External\Lib\Auth\Password\SessionCredentials;
2729

2830
class ExternalMountPoint extends MountPoint {
31+
32+
/** @var StorageConfig */
33+
protected $storageConfig;
34+
35+
public function __construct(StorageConfig $storageConfig, $storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
36+
$this->storageConfig = $storageConfig;
37+
parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
38+
}
39+
2940
public function getMountType() {
30-
return 'external';
41+
return ($this->storageConfig->getAuthMechanism() instanceof SessionCredentials) ? 'external-session' : 'external';
3142
}
3243
}

apps/files_external/lib/Lib/PersonalMount.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use OC\Files\Mount\MoveableMount;
2929
use OCA\Files_External\Config\ExternalMountPoint;
3030
use OCA\Files_External\Service\UserStoragesService;
31+
use OCP\Files\Storage\IStorage;
3132

3233
/**
3334
* Person mount points can be moved by the user
@@ -42,22 +43,23 @@ class PersonalMount extends ExternalMountPoint implements MoveableMount {
4243
/**
4344
* @param UserStoragesService $storagesService
4445
* @param int $storageId
45-
* @param \OCP\Files\Storage $storage
46+
* @param IStorage $storage
4647
* @param string $mountpoint
4748
* @param array $arguments (optional) configuration for the storage backend
4849
* @param \OCP\Files\Storage\IStorageFactory $loader
4950
* @param array $mountOptions mount specific options
5051
*/
5152
public function __construct(
5253
UserStoragesService $storagesService,
54+
StorageConfig $storageConfig,
5355
$storageId,
5456
$storage,
5557
$mountpoint,
5658
$arguments = null,
5759
$loader = null,
5860
$mountOptions = null
5961
) {
60-
parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions);
62+
parent::__construct($storageConfig, $storage, $mountpoint, $arguments, $loader, $mountOptions);
6163
$this->storagesService = $storagesService;
6264
$this->numericStorageId = $storageId;
6365
}

0 commit comments

Comments
 (0)