wae_authentication/rate_limit/
config.rs1#[derive(Debug, Clone, PartialEq, Eq, Hash)]
5pub enum RateLimitKey {
6 Ip(String),
8 UserId(String),
10 Identifier(String),
12}
13
14#[derive(Debug, Clone)]
16pub struct RateLimitConfig {
17 pub max_requests: u32,
19 pub window_seconds: u64,
21}
22
23impl Default for RateLimitConfig {
24 fn default() -> Self {
25 Self { max_requests: 5, window_seconds: 60 }
26 }
27}
28
29impl RateLimitConfig {
30 pub fn new(max_requests: u32, window_seconds: u64) -> Self {
36 Self { max_requests, window_seconds }
37 }
38
39 pub fn with_max_requests(mut self, max: u32) -> Self {
44 self.max_requests = max;
45 self
46 }
47
48 pub fn with_window_seconds(mut self, seconds: u64) -> Self {
53 self.window_seconds = seconds;
54 self
55 }
56}