diff options
author | Joas Schilling <coding@schilljs.com> | 2022-03-10 15:25:22 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2022-03-11 11:19:17 +0000 |
commit | 7bd273f7502c04ec517da531debab04fb204e0a9 (patch) | |
tree | b201a425e0c4193d2fad70ee8b427722715f52ec /core/Command | |
parent | 0d3c19c6aa76c7479fbb4b3784ae20b5b7b7ed89 (diff) | |
download | nextcloud-server-7bd273f7502c04ec517da531debab04fb204e0a9.tar.gz nextcloud-server-7bd273f7502c04ec517da531debab04fb204e0a9.zip |
Trigger an event to log an activity when an administrator generates an app password
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Command')
-rw-r--r-- | core/Command/User/AddAppPassword.php | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/core/Command/User/AddAppPassword.php b/core/Command/User/AddAppPassword.php index a29692df045..34c8dc67ccc 100644 --- a/core/Command/User/AddAppPassword.php +++ b/core/Command/User/AddAppPassword.php @@ -23,10 +23,11 @@ */ namespace OC\Core\Command\User; +use OC\Authentication\Events\AppPasswordCreatedEvent; use OC\Authentication\Token\IProvider; use OC\Authentication\Token\IToken; +use OCP\EventDispatcher\IEventDispatcher; use OCP\IUserManager; -use OCP\Security\ICrypto; use OCP\Security\ISecureRandom; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\QuestionHelper; @@ -44,17 +45,17 @@ class AddAppPassword extends Command { protected $tokenProvider; /** @var ISecureRandom */ private $random; - /** @var ICrypto */ - private $crypto; + /** @var IEventDispatcher */ + private $eventDispatcher; public function __construct(IUserManager $userManager, IProvider $tokenProvider, ISecureRandom $random, - ICrypto $crypto) { + IEventDispatcher $eventDispatcher) { $this->tokenProvider = $tokenProvider; $this->userManager = $userManager; $this->random = $random; - $this->crypto = $crypto; + $this->eventDispatcher = $eventDispatcher; parent::__construct(); } @@ -112,7 +113,7 @@ class AddAppPassword extends Command { $token = $this->random->generate(72, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS); - $this->tokenProvider->generateToken( + $generatedToken = $this->tokenProvider->generateToken( $token, $user->getUID(), $user->getUID(), @@ -122,6 +123,10 @@ class AddAppPassword extends Command { IToken::DO_NOT_REMEMBER ); + $this->eventDispatcher->dispatchTyped( + new AppPasswordCreatedEvent($generatedToken) + ); + $output->writeln('app password:'); $output->writeln($token); |