2017-04-12 14:32:48 -04:00
|
|
|
<?php
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2018-01-14 05:47:00 -05:00
|
|
|
declare(strict_types=1);
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2017-04-12 14:32:48 -04:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2017-04-12 14:32:48 -04:00
|
|
|
*/
|
|
|
|
|
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 {
|
|
|
|
|
/**
|
2021-09-07 12:03:34 -04:00
|
|
|
* Gets the number of attempts for the specified method
|
2017-04-12 14:32:48 -04:00
|
|
|
*
|
2017-04-12 17:00:02 -04:00
|
|
|
* @param string $methodIdentifier Identifier for the method
|
|
|
|
|
* @param string $userIdentifier Identifier for the user
|
2017-04-12 14:32:48 -04:00
|
|
|
*/
|
2023-06-26 07:33:13 -04:00
|
|
|
public function getAttempts(
|
|
|
|
|
string $methodIdentifier,
|
|
|
|
|
string $userIdentifier,
|
|
|
|
|
): int;
|
2017-04-12 14:32:48 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Registers an attempt
|
|
|
|
|
*
|
2017-04-12 17:00:02 -04:00
|
|
|
* @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
|
2017-04-12 14:32:48 -04:00
|
|
|
*/
|
2023-06-26 07:33:13 -04:00
|
|
|
public function registerAttempt(
|
|
|
|
|
string $methodIdentifier,
|
|
|
|
|
string $userIdentifier,
|
|
|
|
|
int $period,
|
|
|
|
|
);
|
2017-04-12 14:32:48 -04:00
|
|
|
}
|