diff --git a/apps/files_external/lib/Command/Create.php b/apps/files_external/lib/Command/Create.php
index 60a2df28dc8dd..97baf0fd906c0 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 Symfony\Component\Console\Input\ArrayInput;
@@ -34,6 +35,7 @@ public function __construct(
private IUserManager $userManager,
private IUserSession $userSession,
private BackendService $backendService,
+ private IGroupManager $groupManager,
) {
parent::__construct();
}
@@ -75,6 +77,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();
}
@@ -86,6 +100,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);
@@ -128,6 +144,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');