Skip to main content

Module login_ratelimit

Module login_ratelimit 

Source
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_after a 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. None when it cannot be stated, which the error then simply omits.
warn_table_full πŸ”’
Warn that the table for axis cannot admit another account.

Type AliasesΒ§

AccountKey πŸ”’
Buckets πŸ”’
FailedKey πŸ”’
Pruned πŸ”’
Ratelimiter πŸ”’