mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
feat: allow setting custom name for occ generated app password
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
ae89c60e9e
commit
de69824a59
1 changed files with 9 additions and 1 deletions
|
|
@ -48,6 +48,12 @@ class Add extends Command {
|
|||
InputOption::VALUE_NONE,
|
||||
'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.'
|
||||
)
|
||||
->addOption(
|
||||
'name',
|
||||
null,
|
||||
InputOption::VALUE_REQUIRED,
|
||||
'Name for the app password, defaults to "cli".'
|
||||
)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
@ -81,13 +87,15 @@ class Add extends Command {
|
|||
$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>');
|
||||
}
|
||||
|
||||
$tokenName = $input->getOption('name') ?: 'cli';
|
||||
|
||||
$token = $this->random->generate(72, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS);
|
||||
$generatedToken = $this->tokenProvider->generateToken(
|
||||
$token,
|
||||
$user->getUID(),
|
||||
$user->getUID(),
|
||||
$password,
|
||||
'cli',
|
||||
$tokenName,
|
||||
IToken::PERMANENT_TOKEN,
|
||||
IToken::DO_NOT_REMEMBER
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue