blob: 7118123cbb53c57c2f313d6f5402de3d90103a14 (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Security\Bruteforce\Backend;
/**
* Interface IBackend defines a storage backend for the bruteforce data. It
* should be noted that writing and reading brute force data is an expensive
* operation and one should thus make sure to only use sufficient fast backends.
*/
interface IBackend {
/**
* Gets the number of attempts for the specified subnet (and further filters)
*
* @param string $ipSubnet
* @param int $maxAgeTimestamp
* @param ?string $action Optional action to further limit attempts
* @param ?array $metadata Optional metadata stored to further limit attempts (Only considered when $action is set)
* @return int
* @since 28.0.0
*/
public function getAttempts(
string $ipSubnet,
int $maxAgeTimestamp,
?string $action = null,
?array $metadata = null,
): int;
/**
* Reset the attempts for the specified subnet (and further filters)
*
* @param string $ipSubnet
* @param ?string $action Optional action to further limit attempts
* @param ?array $metadata Optional metadata stored to further limit attempts(Only considered when $action is set)
* @since 28.0.0
*/
public function resetAttempts(
string $ipSubnet,
?string $action = null,
?array $metadata = null,
): void;
/**
* Register a failed attempt to bruteforce a security control
*
* @param string $ip
* @param string $ipSubnet
* @param int $timestamp
* @param string $action
* @param array $metadata Optional metadata stored to further limit attempts when getting
* @since 28.0.0
*/
public function registerAttempt(
string $ip,
string $ipSubnet,
int $timestamp,
string $action,
array $metadata = [],
): void;
}
|