Expand description
Password throttles by account and client address.
Each attempt spends an address token and reserves an account/address failure token before verification; only a wrong password keeps the reservation. Verified sign-ins also spend an account token, while UIAA uses separate attempt tables so public login traffic cannot exhaust its allowance. When the client address is the TCP peer, a loopback peer stands for everyone behind a local proxy and is not limited by address.
Re-exportsΒ§
use std::borrow::Borrow;πuse std::collections::BTreeMap;πuse std::net::IpAddr;πuse std::net::Ipv6Addr;πuse std::ops::Bound::Excluded;πuse std::ops::Bound::Included;πuse std::ops::Bound::Unbounded;πuse std::sync::Arc;πuse std::sync::Mutex;πuse std::time::Duration;πuse std::time::Instant;πuse http::StatusCode;πuse ruma::UserId;πuse ruma::api::error::ErrorKind;πuse ruma::api::error::LimitExceededErrorData;πuse ruma::api::error::RetryAfter;πuse tuwunel_core::Error;πuse tuwunel_core::Result;πuse tuwunel_core::Server;πuse tuwunel_core::implement;πuse tuwunel_core::smallstr::SmallString;πuse tuwunel_core::smallvec::SmallVec;πuse tuwunel_core::warn;π
StructsΒ§
- Attempts π
- Limit π
- One bucketβs configuration: refill rate per second and burst depth.
- Reservation
- A failed-attempt token reserved for one password attempt.
- Service
- Password login and reauthentication throttles.
- Table π
EnumsΒ§
- Axis π
- Which bucket table a debit addresses, deciding its full-table policy.
- Hold π
- Whether a reservation actually took a token.
- Scope π
ConstantsΒ§
- FULL_
WARNING_ πINTERVAL - How often each tableβs full-table warning may repeat while it stays full.
- MAX_
RETRY_ πAFTER - The longest
retry_aftera refusal will state, whatever the rate. - PRUNE_
SAMPLE π - How many entries one admission inspects when the table is full.
- RATELIMIT_
MAP_ πCAP - Cap on the number of accounts each bucket table holds.
StaticsΒ§
- ACCOUNT_
FULL_ πWARNING - ADDRESS_
FULL_ πWARNING - FAILED_
FULL_ πWARNING
FunctionsΒ§
- account_
key π - address_
key π - debit_
at π - Take one token from an accountβs bucket, refusing when none is left.
- limit_
exceeded π - prune_
sample π - Remove, from the next bounded sample of the table, the buckets that have refilled completely.
- refill π
- refund_
at π - Give a held reservationβs token back, never past the burst.
- reserve_
at π - retry_
after π - Seconds until one token is back, rounded up and capped.
Nonewhen it cannot be stated, which the error then simply omits. - warn_
table_ πfull - Warn that the table for
axiscannot admit another account.
Type AliasesΒ§
- Account
Key π - Buckets π
- Failed
Key π - Pruned π
- Ratelimiter π