Skip to content

Commit

Permalink
✨ Add exemple and start of mcaptcha provider
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuHa committed May 3, 2024
1 parent e6b10b8 commit 93e48f9
Show file tree
Hide file tree
Showing 8 changed files with 497 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ run_appsec:
run_captcha:
docker compose -f examples/captcha/docker-compose.yml up -d

run_mcaptchaselfhosted:
docker compose -f examples/mcaptcha-selfhosted/docker-compose.yml up -d

run_custom_ban_page:
docker compose -f examples/custom-ban-page/docker-compose.yml up -d

Expand Down Expand Up @@ -79,6 +82,9 @@ restart_appsec:
restart_captcha:
docker compose -f examples/captcha/docker-compose.yml

restart_mcaptchaselfhosted:
docker compose -f examples/mcaptcha-selfhosted/docker-compose.yml

restart_custombanpage:
docker compose -f examples/custom-ban-page/docker-compose.yml

Expand All @@ -98,6 +104,7 @@ clean_all_docker:
docker compose -f examples/tls-auth/docker-compose.yml down --remove-orphans
docker compose -f examples/appsec-enabled/docker-compose.yml down --remove-orphans
docker compose -f examples/captcha/docker-compose.yml down --remove-orphans
docker compose -f examples/mcaptcha-selfhosted/docker-compose.yml down --remove-orphans
docker compose -f examples/custom-ban-page/docker-compose.yml down --remove-orphans
docker compose -f docker-compose.local.yml down --remove-orphans
docker compose -f docker-compose.yml down --remove-orphans
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The following captcha providers are supported now:
- [hcaptcha](https://www.hcaptcha.com/)
- [recaptcha](https://www.google.com/recaptcha/about/)
- [turnstile](https://www.cloudflare.com/fr-fr/products/turnstile/)
- [mcaptcha](https://github.com/mCaptcha/mCaptcha) (self-hosted)


There are 5 operating modes (CrowdsecMode) for this plugin:
Expand Down Expand Up @@ -415,7 +416,7 @@ Only one instance of the plugin is *possible*.
- Used only in `alone` mode, scenarios for Crowdsec CAPI
- CaptchaProvider
- string
- Provider to validate the captcha, expected values are: `hcaptcha`, `recaptcha`, `turnstile`
- Provider to validate the captcha, expected values are: `hcaptcha`, `recaptcha`, `turnstile`, `mcaptcha`
- CaptchaSiteKey
- string
- Site key for the captcha provider
Expand Down
43 changes: 43 additions & 0 deletions examples/mcaptcha-selfhosted/.env.mcaptcha
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
MCAPTCHA_debug=false
MCAPTCHA_commercial=false
MCAPTCHA_source_code=https://github.com/mCaptcha/mCaptcha
MCAPTCHA_allow_registration=false
MCAPTCHA_allow_demo=false

# database
DATABASE_URL=postgres://postgres:password@mcaptcha_postgres:5432/postgres
MCAPTCHA_database_POOL=4

# redis
MCAPTCHA_redis_URL=redis://mcaptcha_redis
MCAPTCHA_redis_POOL=4

# server
PORT=7000
MCAPTCHA_server_DOMAIN=localhost
MCAPTCHA__server_COOKIE_SECRET=pleasereplacethiswithrandomstring # PLEASE SET RANDOM STRING. MIN LENGTH=32
MCAPTCHA__server_IP= 0.0.0.0


# captcha
MCAPTCHA_captcha_SALT=pleasereplacethiswithrandomstring # PLEASE SET RANDOM STRING. MIN LENGTH=32
MCAPTCHA_captcha_GC=30
MCAPTCHA_captcha_RUNNERS=4
MCAPTCHA_captcha_QUEUE_LENGTH=2000
MCAPTCHA_captcha_ENABLE_STATS=true
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_avg_traffic_difficulty=50000 # almost instant solution
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_peak_sustainable_traffic_difficulty=3000000 # greater than 3.5s
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_broke_my_site_traffic_difficulty=5000000 # roughly 1.5s
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_duration=30 # cooldown period in seconds
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_avg_traffic_time=1 # almost instant solution
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_peak_sustainable_traffic_time=3
MCAPTCHA_captcha_DEFAULT_DIFFICULTY_STRATEGY_broke_my_site_traffic_time=5


# SMTP
#MCAPTCHA_smtp_FROM=
#MCAPTCHA_smtp_REPLY=
#MCAPTCHA_smtp_URL=
#MCAPTCHA_smtp_USERNAME=
#MCAPTCHA_smtp_PASSWORD=
#MCAPTCHA_smtp_PORT=
9 changes: 9 additions & 0 deletions examples/mcaptcha-selfhosted/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Example
## With Mcaptcha self hosted solution

Customize `.env.mcaptcha`

To play the demo environment run:
```bash
make run_mcaptchaselfhosted
```
4 changes: 4 additions & 0 deletions examples/mcaptcha-selfhosted/acquis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
filenames:
- /var/log/traefik/access.log
labels:
type: traefik
Loading

0 comments on commit 93e48f9

Please sign in to comment.