aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Security/RateLimiting/Backend/IBackend.php
blob: 43eff5dcf02ee9b1f383b3399c44e87ccfbbf106 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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,
	);
}