pub struct SecurityState {
pub captcha_issuance: RateLimiter,
pub captcha_validation_ip: RateLimiter,
pub captcha_validation_account: RateLimiter,
/* private fields */
}Expand description
Authentication limiters shared through app state.
Fields§
§captcha_issuance: RateLimiterCAPTCHA issue budget.
captcha_validation_ip: RateLimiterCAPTCHA validation budget by client.
captcha_validation_account: RateLimiterCAPTCHA validation budget by account identifier.
Implementations§
Source§impl SecurityState
impl SecurityState
Sourcepub fn new(captcha_budget_per_minute: NonZeroU32) -> Self
pub fn new(captcha_budget_per_minute: NonZeroU32) -> Self
Creates the default authentication policy.
Sourcepub fn with_auth_policy(
captcha_budget_per_minute: NonZeroU32,
auth_policy: AuthRateLimitPolicy,
) -> Self
pub fn with_auth_policy( captcha_budget_per_minute: NonZeroU32, auth_policy: AuthRateLimitPolicy, ) -> Self
Creates custom authentication budgets.
Sourcepub fn client_key(&self, peer_ip: IpAddr) -> String
pub fn client_key(&self, peer_ip: IpAddr) -> String
Derives a stable client key from the connection’s TCP peer address.
Sourcepub fn check_login(
&self,
client_key: &str,
account_identifier: &str,
) -> Result<(), AuthRateLimitRejection>
pub fn check_login( &self, client_key: &str, account_identifier: &str, ) -> Result<(), AuthRateLimitRejection>
Checks both client and normalized account login budgets.
Sourcepub fn reset_login(&self, client_key: &str, account_identifier: &str)
pub fn reset_login(&self, client_key: &str, account_identifier: &str)
Clears login budgets after credentials have been accepted.
Invalid attempts remain rate limited, while successful sign-ins do not accumulate into a lockout for the same client or account.
Sourcepub fn check_two_factor(
&self,
client_key: &str,
) -> Result<(), AuthRateLimitRejection>
pub fn check_two_factor( &self, client_key: &str, ) -> Result<(), AuthRateLimitRejection>
Checks the two-factor budget.
Sourcepub fn check_two_factor_account(
&self,
account_id: &str,
) -> Result<(), AuthRateLimitRejection>
pub fn check_two_factor_account( &self, account_id: &str, ) -> Result<(), AuthRateLimitRejection>
Checks the account budget after validating a server-issued challenge. The account key is shared across login and settings verification.
Sourcepub fn check_registration(
&self,
client_key: &str,
) -> Result<(), AuthRateLimitRejection>
pub fn check_registration( &self, client_key: &str, ) -> Result<(), AuthRateLimitRejection>
Checks the registration budget.
Sourcepub fn check_password_reset(
&self,
client_key: &str,
) -> Result<(), AuthRateLimitRejection>
pub fn check_password_reset( &self, client_key: &str, ) -> Result<(), AuthRateLimitRejection>
Checks the password-reset budget before request parsing or password hashing.