diff --git a/apps/files_external/lib/Command/Create.php b/apps/files_external/lib/Command/Create.php
index c5ee68039e2b7..4d4d97a9e52c3 100644
--- a/apps/files_external/lib/Command/Create.php
+++ b/apps/files_external/lib/Command/Create.php
@@ -19,6 +19,7 @@
use OCA\Files_External\Service\StoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\AppFramework\Http;
+use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\User\Exceptions\UserNotFoundException;
@@ -35,6 +36,7 @@ public function __construct(
private IUserManager $userManager,
private IUserSession $userSession,
private BackendService $backendService,
+ private IGroupManager $groupManager,
) {
parent::__construct();
}
@@ -76,6 +78,18 @@ protected function configure(): void {
'',
InputOption::VALUE_NONE,
'Don\'t save the created mount, only list the new mount'
+ )
+ ->addOption(
+ 'applicable-user',
+ '',
+ InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
+ 'Add a user as applicable to the newly created mount'
+ )
+ ->addOption(
+ 'applicable-group',
+ '',
+ InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED,
+ 'Add a group as applicable to the newly created mount'
);
parent::configure();
}
@@ -87,6 +101,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$storageIdentifier = $input->getArgument('storage_backend');
$authIdentifier = $input->getArgument('authentication_backend');
$configInput = $input->getOption('config');
+ $applicableUsers = $input->getOption('applicable-user');
+ $applicableGroups = $input->getOption('applicable-group');
$storageBackend = $this->backendService->getBackend($storageIdentifier);
$authBackend = $this->backendService->getAuthMechanism($authIdentifier);
@@ -129,6 +145,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$mount->setAuthMechanism($authBackend);
$mount->setBackendOptions($config);
+ foreach ($applicableUsers as $applicableUser) {
+ if (!$this->userManager->userExists($applicableUser)) {
+ $output->writeln('Unknown user "' . $applicableUser . '"');
+ }
+ }
+ foreach ($applicableGroups as $applicableGroup) {
+ if (!$this->groupManager->groupExists($applicableGroup)) {
+ $output->writeln('Unknown group "' . $applicableGroup . '"');
+ }
+ }
+ $mount->setApplicableUsers($applicableUsers);
+ $mount->setApplicableGroups($applicableGroups);
+
if ($user) {
if (!$this->userManager->userExists($user)) {
$output->writeln('User "' . $user . '" not found');