Update README.md

main
acetone 2022-08-14 08:33:29 +03:00 committed by GitHub
parent 27b7131450
commit ff9a07ed6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 13 deletions

View File

@ -2,60 +2,65 @@
Zero Storage Captcha selfhosted REST API service
## Compile
Qt5 and OpenSSL are required
```
sudo apt install git qt5-default libssl-dev
sudo apt install git qtdeclarative5-dev
git clone --recursive https://github.com/ZeroStorageCaptcha/api-daemon.git zero-captcha-daemon
cd zero-captcha-daemon
qmake && make
```
## Run
```
-a --address Address to bind
-a --address Address to bind (127.0.0.1 by default)
-p --port Port to bind (7697 by default)
-t --threads Working threads (hardware value by default)
```
For Linux systems with systemd check `systemd` folder which contains service file example.
## API
GET request, JSON response
**Each response contains a boolean "status" that indicates the logic success of the operation. If !status, read "message" field.**
1. Generate captcha
```
-> /generate?length= [>0] &difficulty= [0-5] &output= [base64|file] IF output=file: &filepath= [file system path]
<- "token", IF output=base64: "png" (base64 encoded picture)
-> /generate?length=CAPTCHA_TEXT_LENGTH&difficulty=0|1|2"
<- { "token": "CAPTCHA_TOKEN", "png": "BASE64_ENCODED_PICTURE" }
```
2. Validate captcha
```
-> /validate?answer= [user's answer] &token = [user's token]
<- boolean "valid"
-> /validate?answer=CAPTCHA_ANSWER&token=CAPTCHA_TOKEN
<- { "valid": true|false }
```
3. Settings
3.1 Tokens case sensitive to captcha answer:
```
-> /settings?case_sensitive= [enable|disable]
-> /settings?case_sensitive=enable|disable
```
3.2 Only numbers mode:
3.2 Numbers only mode:
```
-> /settings?number_mode= [enable|disable]
-> /settings?number_mode=enable|disable
```
## Example
1. Generate
```
Client: /generate?length=4&difficulty=3&output=base64
Client: /generate?length=4&difficulty=1
Server:
{
"png": "iVBORw0KGgoAAAANSU <...> AAAAAElFTkSuQmCC",
"status": true,
"token":" i2oefBw6mswaORIphgDcY7GwnS"
"token":" i2oefBw6mswaORIphgDcY7GwnS_532"
}
```
2. Validate
```
Client: /validate?answer=iuda1&token=i2oefBw6mswaORIphgDcY7GwnS
Client: /validate?answer=iuda1&token=i2oefBw6mswaORIphgDcY7GwnS_532
Server:
{
"status": true,