Security.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\AdminAudit\Actions;
  8. use OCP\Authentication\TwoFactorAuth\IProvider;
  9. use OCP\IUser;
  10. /**
  11. * Class Sharing logs the sharing actions
  12. *
  13. * @package OCA\AdminAudit\Actions
  14. */
  15. class Security extends Action {
  16. /**
  17. * Logs failed twofactor challenge
  18. */
  19. public function twofactorFailed(IUser $user, IProvider $provider): void {
  20. $params = [
  21. 'displayName' => $user->getDisplayName(),
  22. 'uid' => $user->getUID(),
  23. 'provider' => $provider->getDisplayName(),
  24. ];
  25. $this->log(
  26. 'Failed two factor attempt by user %s (%s) with provider %s',
  27. $params,
  28. [
  29. 'displayName',
  30. 'uid',
  31. 'provider',
  32. ]
  33. );
  34. }
  35. /**
  36. * Logs successful twofactor challenge
  37. */
  38. public function twofactorSuccess(IUser $user, IProvider $provider): void {
  39. $params = [
  40. 'displayName' => $user->getDisplayName(),
  41. 'uid' => $user->getUID(),
  42. 'provider' => $provider->getDisplayName(),
  43. ];
  44. $this->log(
  45. 'Successful two factor attempt by user %s (%s) with provider %s',
  46. $params,
  47. [
  48. 'displayName',
  49. 'uid',
  50. 'provider',
  51. ]
  52. );
  53. }
  54. }