diff options
Diffstat (limited to 'lib/private/Security/RateLimiting/Backend/IBackend.php')
-rw-r--r-- | lib/private/Security/RateLimiting/Backend/IBackend.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/private/Security/RateLimiting/Backend/IBackend.php b/lib/private/Security/RateLimiting/Backend/IBackend.php new file mode 100644 index 00000000000..43eff5dcf02 --- /dev/null +++ b/lib/private/Security/RateLimiting/Backend/IBackend.php @@ -0,0 +1,42 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OC\Security\RateLimiting\Backend; + +/** + * Interface IBackend defines a storage backend for the rate limiting data. It + * should be noted that writing and reading rate limiting data is an expensive + * operation and one should thus make sure to only use sufficient fast backends. + * + * @package OC\Security\RateLimiting\Backend + */ +interface IBackend { + /** + * Gets the number of attempts for the specified method + * + * @param string $methodIdentifier Identifier for the method + * @param string $userIdentifier Identifier for the user + */ + public function getAttempts( + string $methodIdentifier, + string $userIdentifier, + ): int; + + /** + * Registers an attempt + * + * @param string $methodIdentifier Identifier for the method + * @param string $userIdentifier Identifier for the user + * @param int $period Period in seconds how long this attempt should be stored + */ + public function registerAttempt( + string $methodIdentifier, + string $userIdentifier, + int $period, + ); +} |