Relaxed login throttler: now have 5 attempts before being throttled. fixes #302

This commit is contained in:
emeric
2023-01-20 21:26:19 +01:00
parent 69f7b89d33
commit 97c083523f
2 changed files with 32 additions and 8 deletions
@@ -19,8 +19,7 @@
#pragma once
#include <shared_mutex>
#include <string>
#include <chrono>
#include <unordered_map>
#include <Wt/WDateTime.h>
@@ -44,8 +43,15 @@ namespace Auth
void removeOutdatedEntries();
const std::size_t _maxEntries;
static constexpr std::size_t _maxBadConsecutiveAttemptCount {5};
static constexpr std::chrono::seconds _throttlingDuration {3};
std::unordered_map<boost::asio::ip::address, Wt::WDateTime> _attemptsInfo;
struct AttemptInfo
{
Wt::WDateTime nextAttempt;
std::size_t badConsecutiveAttemptCount{};
};
std::unordered_map<boost::asio::ip::address, AttemptInfo> _attemptsInfo;
};
} // Auth