https://github.com/theawiteb/salvo-captcha
[Mirror] A captcha middleware for Salvo framework.
https://github.com/theawiteb/salvo-captcha
Last synced: about 1 year ago
JSON representation
[Mirror] A captcha middleware for Salvo framework.
- Host: GitHub
- URL: https://github.com/theawiteb/salvo-captcha
- Owner: TheAwiteb
- License: mit
- Created: 2024-01-29T20:26:28.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-01-13T18:43:57.000Z (over 1 year ago)
- Last Synced: 2025-02-13T07:15:49.823Z (over 1 year ago)
- Language: Rust
- Homepage: https://git.4rs.nl/awiteb/salvo-captcha
- Size: 93.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# salvo-captcha
A captcha middleware for [salvo](salvo.rs) framework. With fully customizable captchas generator, storage, and finders
[](https://ibb.co/XVRVMZj)
## Add to your project
First, add the following to your `Cargo.toml`:
```toml
[dependencies]
salvo-captcha = "0.4"
```
Or use [`cargo add`] to add the dependency to your `Cargo.toml`:
```sh
$ cargo add salvo-captcha
```
## Usage
See the [examples] directory for a complete example. You can also see the implemented generators, storages, and finders in the source code.
## Storage
There is a default storage, which is [`MemoryStorage`] it's a simple in-memory storage. You can implement your own storage by implementing the [`CaptchaStorage`] trait.
### Cacache Storage
A high-performance, concurrent, content-addressable disk cache. The storage is based on [`cacache-rs`] crate. to use it, you need to enable the `cacache-storage` feature.
```toml
[dependencies]
salvo-captcha = { version = "0.3", features = ["cacache-storage"] }
```
## Captcha Finder
We provide fully customizable query parameters, form fields, and headers to find the captcha token and the captcha answer. You can implement your own finder by implementing the [`CaptchaFinder`] trait.
## Captcha Generator
We provide [`SimpleCaptchaGenerator`] which is a simple captcha generator based on the [`captcha`] crate, you can enable it by enabling the `simple-generator` feature.
```toml
[dependencies]
salvo-captcha = { version = "0.3", features = ["simple-generator"] }
```
You can implement your own generator by implementing the [`CaptchaGenerator`] trait.
### Captcha name and difficulty
In this table, you can see the difference between the difficulties and the name of the captcha.
| Name | Easy | Medium | Hard |
| :-------------: | :----------------------------------: | :----------------------------------: | :----------------------------------: |
| Normal |  |  |  |
| SlightlyTwisted |  |  |  |
| VeryTwisted |  |  |  |
## Mirrors
- Github ()
- Codeberg ()
### Main Repository
- My Git ()
## License
This project is licensed under the MIT license for more details see [LICENSE] or .
[`MemoryStorage`]: https://docs.rs/salvo-captcha/latest/salvo_captcha/struct.MemoryStorage.html
[`CaptchaStorage`]: https://docs.rs/salvo-captcha/latest/salvo_captcha/trait.CaptchaStorage.html
[`cacache-rs`]: https://github.com/zkat/cacache-rs
[`SimpleCaptchaGenerator`]: https://docs.rs/salvo-captcha/latest/salvo_captcha/struct.SimpleCaptchaGenerator.html
[`CaptchaGenerator`]: https://docs.rs/salvo-captcha/latest/salvo_captcha/trait.CaptchaGenerator.html
[`CaptchaFinder`]: https://docs.rs/salvo-captcha/latest/salvo_captcha/trait.CaptchaFinder.html
[examples]: https://git.4rs.nl/awiteb/salvo-captcha/src/branch/master/examples
[`captcha`]: https://github.com/daniel-e/captcha
[LICENSE]: https://git.4rs.nl/awiteb/salvo-captcha/src/branch/master/LICENSE
[`cargo add`]: https://doc.rust-lang.org/cargo/commands/cargo-add.html