Skip to content

Commit 7f6e76a

Browse files
authored
Merge pull request #55585 from nextcloud/occ-auth-token-name
feat: allow setting custom name for occ generated app password
2 parents b6496c8 + de69824 commit 7f6e76a

File tree

1 file changed

+9
-1
lines changed
  • core/Command/User/AuthTokens

1 file changed

+9
-1
lines changed

core/Command/User/AuthTokens/Add.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ protected function configure() {
4848
InputOption::VALUE_NONE,
4949
'Read password from environment variable NC_PASS/OC_PASS. Alternatively it will be asked for interactively or an app password without the login password will be created.'
5050
)
51+
->addOption(
52+
'name',
53+
null,
54+
InputOption::VALUE_REQUIRED,
55+
'Name for the app password, defaults to "cli".'
56+
)
5157
;
5258
}
5359

@@ -81,13 +87,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8187
$output->writeln('<info>No password provided. The generated app password will therefore have limited capabilities. Any operation that requires the login password will fail.</info>');
8288
}
8389

90+
$tokenName = $input->getOption('name') ?: 'cli';
91+
8492
$token = $this->random->generate(72, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS);
8593
$generatedToken = $this->tokenProvider->generateToken(
8694
$token,
8795
$user->getUID(),
8896
$user->getUID(),
8997
$password,
90-
'cli',
98+
$tokenName,
9199
IToken::PERMANENT_TOKEN,
92100
IToken::DO_NOT_REMEMBER
93101
);

0 commit comments

Comments
 (0)