pub enum RateLimitKey {
ApiKey(Uuid),
User(Uuid),
Ip(IpAddr),
Account {
route: String,
email: String,
},
KeyCheck {
ip: Option<IpAddr>,
api_key: Uuid,
},
}Expand description
Rate limit key: identity-based when authenticated, IP-based otherwise.
§Examples
use std::net::{IpAddr, Ipv4Addr};
use uuid::Uuid;
use ironflow_api::rate_limit::RateLimitKey;
let ip_key = RateLimitKey::Ip(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
let user_key = RateLimitKey::User(Uuid::nil());
let api_key = RateLimitKey::ApiKey(Uuid::nil());
let account_key = RateLimitKey::Account {
route: "/sign-in".to_string(),
email: "alice@ironflow.dev".to_string(),
};
let key_check = RateLimitKey::KeyCheck {
ip: Some(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))),
api_key: Uuid::nil(),
};Variants§
ApiKey(Uuid)
Authenticated via API key.
User(Uuid)
Authenticated via JWT.
Ip(IpAddr)
Unauthenticated, identified by client IP.
Account
The account a credential request targets on one route.
Fields
KeyCheck
Argon2 verifications of an API key secret not yet in the cache, by client IP, or by key alone when the server has no peer address.
Keyed on both so an attacker cannot exhaust the budget of a victim key from another address, and one NAT address using many keys is not throttled.
Trait Implementations§
Source§impl Clone for RateLimitKey
impl Clone for RateLimitKey
Source§impl Debug for RateLimitKey
impl Debug for RateLimitKey
impl Eq for RateLimitKey
Source§impl Hash for RateLimitKey
impl Hash for RateLimitKey
Source§impl PartialEq for RateLimitKey
impl PartialEq for RateLimitKey
impl StructuralPartialEq for RateLimitKey
Auto Trait Implementations§
impl Freeze for RateLimitKey
impl RefUnwindSafe for RateLimitKey
impl Send for RateLimitKey
impl Sync for RateLimitKey
impl Unpin for RateLimitKey
impl UnsafeUnpin for RateLimitKey
impl UnwindSafe for RateLimitKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.