Skip to main content

Module login_ratelimit

Module login_ratelimit 

Source
Expand description

Per-account throttles on password authentication.

Every password attempt reserves a token from the accountโ€™s failed-attempt bucket before the password is checked, and only a wrong password keeps it, so concurrent guesses cannot share one token. Only a sign-in by a verified password debits the account bucket. Both are keyed on the account rather than the client address, mirroring Synapseโ€™s rc_login.failed_attempts and rc_login.account; the operator documentation for the [global.rate_limiting.login] options sets out their costs.

Structsยง

Limit ๐Ÿ”’
One bucketโ€™s configuration: refill rate per second and burst depth.
Reservation
A failed-attempt token reserved for one password attempt.
Service
Per-account login throttles.
Table ๐Ÿ”’
One axisโ€™s token buckets, and where the next prune of them resumes.

Enumsยง

Axis ๐Ÿ”’
Which bucket table a debit addresses, deciding its full-table policy.
Hold ๐Ÿ”’
Whether a reservation actually took a token.

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 ๐Ÿ”’
FAILED_FULL_WARNING ๐Ÿ”’

Functionsยง

account_key ๐Ÿ”’
One bucket per account regardless of the case it was typed in, matching the lowercase fallback the password check itself applies.
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ยง

Buckets ๐Ÿ”’
Ratelimiter ๐Ÿ”’