pub struct CaptchaPolicy { /* private fields */ }Expand description
Validated CAPTCHA policy and its isolated one-time challenge store.
Implementations§
Source§impl CaptchaPolicy
impl CaptchaPolicy
Sourcepub fn from_config(config: &CaptchaConfig) -> Result<Self, CaptchaConfigError>
pub fn from_config(config: &CaptchaConfig) -> Result<Self, CaptchaConfigError>
Validates application-provided CAPTCHA configuration.
§Errors
Returns an error unless the character set contains at least two unique symbols, noise is in the closed unit interval, expiry is positive and supported, and bypass is disabled in release builds.
Sourcepub fn parse_token(&self, raw: String) -> ParseResult<CaptchaToken>
pub fn parse_token(&self, raw: String) -> ParseResult<CaptchaToken>
Parses an opaque token according to this policy.
Sourcepub fn parse_response(&self, raw: String) -> ParseResult<CaptchaResponse>
pub fn parse_response(&self, raw: String) -> ParseResult<CaptchaResponse>
Parses a candidate solution according to this policy.
Sourcepub fn consume(
&self,
token: &CaptchaToken,
response: CaptchaResponse,
now: OffsetDateTime,
) -> ParseResult<()>
pub fn consume( &self, token: &CaptchaToken, response: CaptchaResponse, now: OffsetDateTime, ) -> ParseResult<()>
Consumes and verifies a one-time challenge.
A token is removed on its first verification attempt, including an incorrect response, so it cannot be replayed or brute-forced.
Trait Implementations§
Source§impl Clone for CaptchaPolicy
impl Clone for CaptchaPolicy
Auto Trait Implementations§
impl !RefUnwindSafe for CaptchaPolicy
impl !UnwindSafe for CaptchaPolicy
impl Freeze for CaptchaPolicy
impl Send for CaptchaPolicy
impl Sync for CaptchaPolicy
impl Unpin for CaptchaPolicy
impl UnsafeUnpin for CaptchaPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more