diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2021-09-06 17:31:36 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2021-09-06 17:31:36 +0200 |
commit | 378cc922c429524b872e83c7b3842eb86bc4b770 (patch) | |
tree | dbb0e7ef8ab4d859f8f8d7c71155c5a50bd660b3 /lib/private/Security/RateLimiting/Limiter.php | |
parent | d4f97affc1a0ecfaacfbdc26aab820cad1650a06 (diff) | |
download | nextcloud-server-378cc922c429524b872e83c7b3842eb86bc4b770.tar.gz nextcloud-server-378cc922c429524b872e83c7b3842eb86bc4b770.zip |
Adjust logic to store period instead of current timestamp
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'lib/private/Security/RateLimiting/Limiter.php')
-rw-r--r-- | lib/private/Security/RateLimiting/Limiter.php | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/private/Security/RateLimiting/Limiter.php b/lib/private/Security/RateLimiting/Limiter.php index ede72e887fc..1c14fce2a55 100644 --- a/lib/private/Security/RateLimiting/Limiter.php +++ b/lib/private/Security/RateLimiting/Limiter.php @@ -35,17 +35,12 @@ use OCP\IUser; class Limiter { /** @var IBackend */ private $backend; - /** @var ITimeFactory */ - private $timeFactory; /** - * @param ITimeFactory $timeFactory * @param IBackend $backend */ - public function __construct(ITimeFactory $timeFactory, - IBackend $backend) { + public function __construct(IBackend $backend) { $this->backend = $backend; - $this->timeFactory = $timeFactory; } /** @@ -59,12 +54,12 @@ class Limiter { string $userIdentifier, int $period, int $limit): void { - $existingAttempts = $this->backend->getAttempts($methodIdentifier, $userIdentifier, $period); + $existingAttempts = $this->backend->getAttempts($methodIdentifier, $userIdentifier); if ($existingAttempts >= $limit) { throw new RateLimitExceededException(); } - $this->backend->registerAttempt($methodIdentifier, $userIdentifier, $this->timeFactory->getTime()); + $this->backend->registerAttempt($methodIdentifier, $userIdentifier, $period); } /** |