#captcha #protection #security #backend

hcaptcha

hCaptcha client response verification. Validate the hCaptcha response submitted from to your server from the client.

14 releases (stable)

2.3.1 Jan 27, 2024
2.2.2 Apr 9, 2023
2.2.1 Jan 25, 2023
2.2.0 Nov 17, 2022
0.4.0 Nov 23, 2020

#190 in Web programming

Download history 309/week @ 2023-11-20 526/week @ 2023-11-27 548/week @ 2023-12-04 350/week @ 2023-12-11 322/week @ 2023-12-18 159/week @ 2023-12-25 321/week @ 2024-01-01 789/week @ 2024-01-08 600/week @ 2024-01-15 634/week @ 2024-01-22 282/week @ 2024-01-29 428/week @ 2024-02-05 385/week @ 2024-02-12 547/week @ 2024-02-19 223/week @ 2024-02-26 175/week @ 2024-03-04

1,340 downloads per month

MIT/Apache

110KB
1.5K SLoC

Rust library hcaptcha

Crates.io MIT licensed Build Status Rust 1.71+ FOSSA Status Docs BuyMeaCoffee GitHubSponsors

The rust library hcaptcha is used with your backend service to verify the hcaptcha response provided from the client.

Installation

To use hcaptcha-rs in your project you can add the following to your Cargo.toml:

[dependencies]
hcaptcha = "2.3.1"

Usage

Derive a validation method on the data structure representing your data, marking the captcha components in the data structure.

# use hcaptcha::Hcaptcha;

#[derive(Debug, Deserialize, Hcaptcha)]
pub struct ContactForm {
    name: String,
    phone: String,
    email: String,
    message: String,
    #[captcha]
    token: String,
}

Validate the captcha data.

    # #[tokio::main]
    # async main() -> Result<(), Box<dyn std::error::Error>> {
    let contact_form: ContactForm = serde_json::from_str(e.body_string())?;
    contact_form.valid_response(&secret, None).await?;
    # }
    # fn get_your_secret() -> String {
    #   "0x123456789abcde0f123456789abcdef012345678".to_string()
    # }

See the examples folder for an AWS Lambda contact form example.

License

Licensed under either of

Third Party Licenses

A summary of third party licenses can be found here

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Credits

Initial version based on recaptcha-rs by panicbit.

Dependencies

~4–18MB
~258K SLoC