pub struct LoginThrottle { /* private fields */ }Expand description
How many sign-in attempts one login may make from one client address in a window, as
Auth::throttle sets it.
Each attempt that reaches the authenticator counts against the login it names, trimmed and
lowercased, and the address client_ip answers, from
the first attempt of the window; a successful sign-in clears that count. Past the limit, the
login page refuses the attempt without asking the authenticator, with the same 403 and message
as a wrong password, until the window ends, and logs a warning.
Keying on the address keeps a guesser from locking the account’s owner out from elsewhere.
Behind a reverse proxy every request carries the proxy’s address unless the router trusts it
through TrustedProxies; until then the count is per login
alone, and a guesser can lock the owner out.
It does not limit one client across logins, nor one login across many addresses, nor a login spelled several ways that the authenticator’s lookup treats as one, as MySQL’s default collation does with accents: a per-IP limit at the proxy covers those. Counts live in the process and per panel, so each replica and each panel counts its own attempts, and a restart clears them.
use std::time::Duration;
use tablo_core::{Auth, LoginThrottle};
let auth = Auth::password().throttle(LoginThrottle::new(10, Duration::from_secs(300)));