2022-08-19 02:26:03 +04:00
|
|
|
justcaptcha ver. 1.1.2
|
2022-08-17 21:49:57 +04:00
|
|
|
======================
|
2022-06-24 23:09:46 +04:00
|
|
|
|
|
|
|
A simple CAPTCHA service implementation.
|
|
|
|
|
2022-06-26 21:01:47 +04:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
justcaptchad -expiry 5m -listen /var/run/justcaptchad/j.sock
|
|
|
|
|
2022-08-19 21:37:51 +04:00
|
|
|
`-expiry` takes time for CAPTCHA to be valid for in format X{s,m,h}.
|
2022-06-26 21:01:47 +04:00
|
|
|
|
|
|
|
`-listen` is `ip:port` or `/path/to/unix.sock` to listen on.
|
|
|
|
|
2022-06-24 23:09:46 +04:00
|
|
|
## API
|
|
|
|
|
2022-08-28 23:33:59 +04:00
|
|
|
### Get a new CAPTCHA
|
2022-06-24 23:09:46 +04:00
|
|
|
|
|
|
|
GET /
|
|
|
|
|
2022-08-28 23:33:59 +04:00
|
|
|
It will return an ID of a new CAPTCHA in plain text.
|
2022-06-24 23:09:46 +04:00
|
|
|
|
|
|
|
#### HTTP codes
|
2022-08-28 23:33:59 +04:00
|
|
|
- `200` if created (and it always being created)
|
2022-06-24 23:09:46 +04:00
|
|
|
|
2022-08-28 23:33:59 +04:00
|
|
|
### Get an image for a CAPTCHA
|
2022-06-24 23:09:46 +04:00
|
|
|
|
2022-06-27 01:21:16 +04:00
|
|
|
GET /:captcha_id/image?style=
|
2022-06-24 23:09:46 +04:00
|
|
|
|
2022-08-28 23:33:59 +04:00
|
|
|
Responds with an image in JPEG format.
|
2022-06-24 23:09:46 +04:00
|
|
|
|
2022-08-28 23:33:59 +04:00
|
|
|
An optional URL query parameter `style=` set a name of a CAPTCHA style if
|
|
|
|
implemented by used CAPTCHA implementation.
|
2022-06-27 01:21:16 +04:00
|
|
|
|
2022-06-24 23:09:46 +04:00
|
|
|
#### HTTP codes
|
2022-06-26 21:03:11 +04:00
|
|
|
- `200` if exists
|
|
|
|
- `404` if doesn't exist
|
2022-08-28 23:33:59 +04:00
|
|
|
- `500` if for some reason an image wasn't created
|
2022-06-24 23:09:46 +04:00
|
|
|
|
|
|
|
### Submit an answer
|
|
|
|
|
|
|
|
POST /:captcha_id
|
|
|
|
|
2022-08-28 23:33:59 +04:00
|
|
|
Accepts `application/x-www-form-urlencoded` content type.
|
2022-06-24 23:09:46 +04:00
|
|
|
|
2022-08-28 23:33:59 +04:00
|
|
|
It takes one parameter `answer=123456`.
|
|
|
|
|
|
|
|
Responds with an empty body and one of the HTTP codes.
|
2022-06-24 23:09:46 +04:00
|
|
|
|
|
|
|
#### HTTP codes
|
2022-06-26 21:03:11 +04:00
|
|
|
- `200` if solved
|
|
|
|
- `403` if not solved
|
|
|
|
- `404` if doesn't exist
|
2022-06-24 23:09:46 +04:00
|
|
|
|
|
|
|
### Check if captcha is solved
|
|
|
|
|
2022-08-28 23:33:59 +04:00
|
|
|
GET /:captcha_id?remove
|
|
|
|
|
|
|
|
Responds with an empty body and one of the HTTP codes.
|
|
|
|
|
|
|
|
If an optional `remove` URL query parameter without a value supplied. CAPTCHA
|
|
|
|
will be removed without check if it is solved and a HTTP code `200` will be sent.
|
|
|
|
Otherwise, a `403` HTTP code will be sent, and, e.g. browser will print an error
|
|
|
|
message to console. So, in this case it helps to keep a browser's console cleaner.
|
|
|
|
If CAPTCHA doesn't exist a `404` HTTP code still will be returned.
|
2022-06-24 23:09:46 +04:00
|
|
|
|
2022-08-28 23:33:59 +04:00
|
|
|
This can be useful to remove an unused CAPTCHA from a DB without waiting for it
|
|
|
|
to be expired. E.g. when a visitor requests for a new CAPTCHA because he struggle
|
|
|
|
to solve it.
|
2022-06-24 23:09:46 +04:00
|
|
|
|
|
|
|
#### HTTP codes
|
2022-06-26 21:03:11 +04:00
|
|
|
- `200` if solved
|
|
|
|
- `403` if not solved
|
|
|
|
- `404` if doesn't exist
|