Skip to content

Commit

Permalink
Expose session based authentication through mount point type
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Oct 7, 2020
1 parent 678ef84 commit 8fb946d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions apps/files_external/lib/Config/ConfigAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
null,
$loader,
$storageConfig->getMountOptions()
array_merge($storageConfig->getMountOptions(), ['storageConfig' => $storageConfig])
);
} else {
return new ExternalMountPoint(
$storage,
'/' . $user->getUID() . '/files' . $storageConfig->getMountPoint(),
null,
$loader,
$storageConfig->getMountOptions(),
array_merge($storageConfig->getMountOptions(), ['storageConfig' => $storageConfig]),
$storageConfig->getId()
);
}
Expand Down
16 changes: 15 additions & 1 deletion apps/files_external/lib/Config/ExternalMountPoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,23 @@
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 */
private $storageConfig;

public function __construct($storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
if (isset($mountOptions['storageConfig'])) {
$this->storageConfig = $mountOptions['storageConfig'];
unset($mountOptions['storageConfig']);
}
parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
}

public function getMountType() {
return 'external';
return ($this->storageConfig->getAuthMechanism() instanceof SessionCredentials) ? 'external-session' : 'external';
}
}

0 comments on commit 8fb946d

Please sign in to comment.