First, server reads all dataset. Dataset is a directory with subdirectories, where each subdirectory contains images of one element.
First, server reads all dataset. Dataset is a directory with subdirectories, where each subdirectory contains images of one element.
For example:
For example:
@ -104,7 +110,7 @@ imgs/
Then, stores all the filenames corresponding to each subdirectory. So, we have each image and to which element category is (the name of subdirectory).
Then, stores all the filenames corresponding to each subdirectory. So, we have each image and to which element category is (the name of subdirectory).
###### Server generates captcha
### 3.2 - Server generates captcha
When server recieves a GET /captcha, generates a captcha, getting random images from the dataset.
When server recieves a GET /captcha, generates a captcha, getting random images from the dataset.
For each captcha generated, generates two mongodb models:
For each captcha generated, generates two mongodb models:
@ -144,7 +150,8 @@ CaptchaSolution Model
"leopard",
"leopard",
"leopard"
"leopard"
],
],
"question" : "leopard"
"question" : "leopard",
"date": "1502274893"
}
}
```
```
Both models are stored in the MongoDB.
Both models are stored in the MongoDB.
@ -165,7 +172,14 @@ When the server recieves a petition to get an image, recieves the petition with
Captcha Model contains the captcha that server returns to the petition. And CaptchaSolution contains the solution of the captcha. Both have the same Id.
Captcha Model contains the captcha that server returns to the petition. And CaptchaSolution contains the solution of the captcha. Both have the same Id.
###### Server validates captcha
### 3.3 - Server validates captcha
When server recieves POST /answer, gets the answer, search for the CaptchaSolution based on the CaptchaId in the MongoDB, and then compares the answer 'selection' parameter with the CaptchaSolution.
When server recieves POST /answer, gets the answer, search for the CaptchaSolution based on the CaptchaId in the MongoDB, and then compares the answer 'selection' parameter with the CaptchaSolution.
If the selection is correct, returns 'true', if the selection is not correct, returns 'false'.
If the selection is correct, returns 'true', if the selection is not correct, returns 'false'.
## 4 - Security
- If the captcha is resolved in less than 1 second, it's not valid.
- If the captcha is resolved in more than 1 minute, it's not valid.
- The images url, are UUIDs generated each time, in order to give different names for the images each time.