Successful authentication requests should not count when rate limiting

This commit is contained in:
mdecimus
2023-08-07 16:41:52 +02:00
parent 5346beb975
commit 39cbb946f7
10 changed files with 119 additions and 49 deletions

View File

@@ -79,6 +79,10 @@ impl RateLimiter {
}
}
pub fn is_allowed_soft(&self) -> bool {
self.tokens >= 1 || self.last_refill.elapsed() >= self.max_interval
}
pub fn retry_at(&self) -> Instant {
Instant::now()
+ (self