From de69824a592b233d5d35f107cf4a1f896522c77a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 6 Oct 2025 18:37:03 +0200 Subject: [PATCH] feat: allow setting custom name for occ generated app password Signed-off-by: Robin Appelman --- core/Command/User/AuthTokens/Add.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/Command/User/AuthTokens/Add.php b/core/Command/User/AuthTokens/Add.php index 89b20535c63..e7bf9a59a2a 100644 --- a/core/Command/User/AuthTokens/Add.php +++ b/core/Command/User/AuthTokens/Add.php @@ -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('No password provided. The generated app password will therefore have limited capabilities. Any operation that requires the login password will fail.'); } + $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 );