2019-06-08 02:17:37 -04:00
# LibreCaptcha
LibreCaptcha is a framework that allows developers to create their own [CAPTCHA ](https://en.wikipedia.org/wiki/CAPTCHA )s.
2021-04-01 10:40:09 -04:00
The framework defines the API for a CAPTCHA generator and takes care of mundane details
such as:
* An HTTP interface for serving CAPTCHAs
* Background workers to pre-compute CAPTCHAs and to store them in a database
2019-08-06 12:55:05 -04:00
* Managing secrets for the CAPTCHAs (tokens, expected answers, etc)
2019-06-08 02:17:37 -04:00
* Safe re-impressions of CAPTCHA images (by creating unique tokens for every impression)
2021-04-01 10:40:09 -04:00
* Garbage collection of stale CAPTCHAs
* Sandboxed plugin architecture (TBD)
2018-01-06 23:34:19 -05:00
2021-04-01 10:40:09 -04:00
Some sample CAPTCHA generators are included in the distribution (see below). We will continue adding more samples to the list. For quick
deployments the samples themselves might be sufficient. Projects with more resources might want create their own CAPTCHAs
and use the samples as inspiration. See the [CAPTCHA creation guide ](https://github.com/librecaptcha/lc-core/wiki/Creating-your-own-CAPTCHA-provider ).
2018-01-06 23:34:19 -05:00
2021-04-01 04:12:11 -04:00
## Quick start with Docker
Using `docker-compose` :
```
git clone https://github.com/librecaptcha/lc-core.git
docker-compose up
```
Using `docker` :
```
docker run -v lcdata:/lc-core/data librecaptcha/lc-core:latest
```
A default `config.json` is automatically created in the mounted volume.
2021-04-01 07:32:59 -04:00
To test the installation, try:
```
curl -d '{"media":"image/png","level":"easy","input_type":"text"}' localhost:8888/v1/captcha
```
2021-04-01 10:40:09 -04:00
This should return an id that can be used in further API calls. The API endpoints are described below.
2021-04-01 07:32:59 -04:00
2021-04-01 04:12:11 -04:00
## Configuration
If a `config.json` file is not present in the `data/` folder, the app creates one, and this can be modified
to customize the app features, such as which CAPTCHAs are enabled and their difficulty settings.
2021-04-01 04:13:14 -04:00
More details can be found [in the wiki ](https://github.com/librecaptcha/lc-core/wiki/Configuration )
2019-06-08 02:17:37 -04:00
## Why LibreCaptcha?
### Eliminate dependency on a third-party
An open-source CAPTCHA framework will allow anyone to host their own CAPTCHA service and thus avoid dependencies on
third-parties.
### Respecting user privacy
A self-hosted service prevents user information from leaking to other parties.
### More variety of CAPTCHAs
Ain't it boring to identify photos of buses, store-fronts and traffic signals? With LibreCaptcha, developers can
create CAPTCHAs that suit their application and audience, with matching themes and looks.
And, the more the variety of CAPTCHAS, the harder it is for bots to crack CAPTCHAs.
## Sample CAPTCHAs
### FilterCaptcha
![FilterCaptcha Sample ](./samples/FilterChallenge.png )
2021-04-01 10:40:09 -04:00
An image of a random string of alphabets is created. Then a series of image filters that add effects such as Smear, Diffuse, and Ripple are applied to the image to make it less readable.
2019-06-08 02:17:37 -04:00
### RainDropsCaptcha
![RaindDrops Sample ](./samples/RainDropsCaptcha.gif )
### BlurCaptcha
2018-01-06 23:34:19 -05:00
An image of a word is blurred before being shown to the user.
2019-06-08 02:17:37 -04:00
### LabelCaptcha
2018-01-06 23:34:19 -05:00
An image that has a pair of words is created. The answer to one of the words is known and to that of the other is unknown. The user is tested on the known word, and their answer to the unknown word is recorded. If a sufficient number of users agree on their answer to the unknown word, it is transferred to the list of known words.
2020-09-23 13:28:42 -04:00
***
## HTTP API
2021-04-01 04:12:11 -04:00
### - `/v1/captcha`: `POST`
2020-09-23 13:28:42 -04:00
- Parameters:
- `level` : `String` -
The difficulty level of a captcha
- easy
- medium
- hard
- `input_type` : `String` -
The type of input option for a captcha
- text
2021-04-01 07:10:07 -04:00
- (More to come)
2020-09-23 13:28:42 -04:00
- `media` : `String` -
The type of media of a captcha
2021-04-01 07:10:07 -04:00
- image/png
- image/gif
- (More to come)
- `size` : `Map` -
2020-09-23 13:28:42 -04:00
The dimensions of a captcha (Optional). It needs two more fields nested in this parameter
- `height` : `Int`
- `width` : `Int`
- Return type:
- `id` : `String` - The uuid of the captcha generated
2021-04-01 07:10:07 -04:00
### - `/v1/media`: `GET`
2020-09-23 13:28:42 -04:00
- Parameters:
- `id` : `String` - The uuid of the captcha
- Return type:
- `image` : `Array[Byte]` - The requested media as bytes
2021-04-01 04:12:11 -04:00
### - `/v1/answer`: `POST`
2020-09-23 13:28:42 -04:00
- Parameter:
- `id` : `String` - The uuid of the captcha that needs to be solved
- `answer` : `String` - The answer to the captcha that needs to be validated
- Return Type:
- `result` : `String` - The result after validation/checking of the answer
- True - If the answer is correct
- False - If the answer is incorrect
- Expired - If the time limit to solve the captcha exceeds
***
2019-06-08 02:17:37 -04:00
## Roadmap
Things to do in the future:
* Sandboxed plugin architecture
* Audio CAPTCHA samples
* Interactive CAPTCHA samples