IBackend.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Security\RateLimiting\Backend;
  8. /**
  9. * Interface IBackend defines a storage backend for the rate limiting data. It
  10. * should be noted that writing and reading rate limiting data is an expensive
  11. * operation and one should thus make sure to only use sufficient fast backends.
  12. *
  13. * @package OC\Security\RateLimiting\Backend
  14. */
  15. interface IBackend {
  16. /**
  17. * Gets the number of attempts for the specified method
  18. *
  19. * @param string $methodIdentifier Identifier for the method
  20. * @param string $userIdentifier Identifier for the user
  21. */
  22. public function getAttempts(
  23. string $methodIdentifier,
  24. string $userIdentifier,
  25. ): int;
  26. /**
  27. * Registers an attempt
  28. *
  29. * @param string $methodIdentifier Identifier for the method
  30. * @param string $userIdentifier Identifier for the user
  31. * @param int $period Period in seconds how long this attempt should be stored
  32. */
  33. public function registerAttempt(
  34. string $methodIdentifier,
  35. string $userIdentifier,
  36. int $period,
  37. );
  38. }