Skip to content

Commit 5b217e2

Browse files
committed
📝 Fix example and makefile and doc for wicketkeeper
1 parent 00b3e3e commit 5b217e2

File tree

6 files changed

+73
-59
lines changed

6 files changed

+73
-59
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ run_appsec:
4444
docker compose -f examples/appsec-enabled/docker-compose.yml up -d --remove-orphans
4545

4646
run_custom_captcha:
47-
docker compose -f examples/custo-captcha/docker-compose.yml up -d --remove-orphans
47+
docker compose -f examples/custom-captcha/docker-compose.yml up -d --remove-orphans
4848

4949
run_captcha:
5050
docker compose -f examples/captcha/docker-compose.yml up -d --remove-orphans
@@ -99,8 +99,9 @@ clean_all_docker:
9999
docker compose -f examples/redis-cache/docker-compose.yml down --remove-orphans
100100
docker compose -f examples/trusted-ips/docker-compose.yml down --remove-orphans
101101
docker compose -f examples/tls-auth/docker-compose.yml down --remove-orphans
102-
docker compose -f examples/appsec-enabled/docker-compose.yml down --remove-orphans
102+
docker compose -f examples/appsec-enabled/docker-compose.appsec-enabled.yml down --remove-orphans
103103
docker compose -f examples/captcha/docker-compose.yml down --remove-orphans
104+
docker compose -f examples/custom-captcha/docker-compose.yml down --remove-orphans
104105
docker compose -f examples/custom-ban-page/docker-compose.yml down --remove-orphans
105106
docker compose -f docker-compose.local.yml down --remove-orphans
106107
docker compose -f docker-compose.yml down --remove-orphans

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ The following captcha providers are supported now:
3939
- [hcaptcha](https://www.hcaptcha.com/)
4040
- [recaptcha](https://www.google.com/recaptcha/about/)
4141
- [turnstile](https://www.cloudflare.com/products/turnstile/)
42+
- [custom/wicketkeeper](https://github.com/a-ve/wicketkeeper)
4243

4344
There are 5 operating modes (CrowdsecMode) for this plugin:
4445

@@ -702,6 +703,8 @@ docker exec crowdsec cscli decisions remove --ip 10.0.0.10 -t captcha
702703

703704
#### 10. Using Traefik with Custom Ban HTML Page [examples/custom-ban-page/README.md](https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin/blob/main/examples/custom-ban-page/README.md)
704705

706+
#### 11. Using Traefik with Custom Captcha Whiketkeeper[examples/custom-captcha/README.md](https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin/blob/main/examples/custom-captcha/README.md)
707+
705708
### Local Mode
706709

707710
Traefik also offers a developer mode that can be used for temporary testing of plugins not hosted on GitHub.

bouncer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ func New(_ context.Context, next http.Handler, config *configuration.Config, nam
252252
config.CaptchaGracePeriodSeconds,
253253
)
254254
if err != nil {
255+
log.Error("CaptchaClient not valid " + err.Error())
255256
return nil, err
256257
}
257258

examples/appsec-enabled/docker-compose.appsec-enabled.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: "3.8"
2-
31
services:
42
traefik:
53
image: "traefik:v3.0.0"
@@ -36,7 +34,7 @@ services:
3634
# Definition of the router
3735
- "traefik.http.routers.router-foo.rule=PathPrefix(`/foo`)"
3836
- "traefik.http.routers.router-foo.entrypoints=web"
39-
- "traefik.http.routers.router-foo.middlewares=crowdsec@docker"
37+
- "traefik.http.routers.router-foo.middlewares=crowdsec@docker"
4038
# Definition of the service
4139
- "traefik.http.services.service-foo.loadbalancer.server.port=80"
4240
# Definition of the middleware
@@ -48,8 +46,6 @@ services:
4846
# Define AppSec host and port informations
4947
- "traefik.http.middlewares.crowdsec.plugin.bouncer.crowdsecappsechost=crowdsec:7422"
5048

51-
52-
5349
crowdsec:
5450
image: crowdsecurity/crowdsec:v1.6.1-2
5551
container_name: "crowdsec"
@@ -65,7 +61,7 @@ services:
6561
- crowdsec-config-appsec-enabled:/etc/crowdsec/
6662
labels:
6763
- "traefik.enable=false"
68-
64+
6965
volumes:
7066
logs-appsec-enabled:
7167
crowdsec-db-appsec-enabled:

examples/custom-captcha/README.md

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ Read the example captcha before this, to better understand what is done here.
55
### Traefik configuration
66

77
The minimal configuration is defined below to implement custom captcha.
8-
This documentation use https://github.com/a-ve/wicketpeeker, a self-hosted captcha provider that have a similar API than big providers.
8+
This documentation use https://github.com/a-ve/wicketpeeker, a self-hosted captcha provider that have a similar API than big providers.
99

1010
Minimal API requirement:
11+
1112
- the JS file URL to load the captcha on the served `captcha.html`
1213
- the HTML className to tell to the JS where to display the challenge
1314
- the verify URL endpoint to send the response from the captcha
@@ -21,41 +22,45 @@ Minimal API requirement:
2122
labels:
2223
# Choose captcha provider
2324
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaProvider=custom"
24-
# Define captcha grade period seconds
25+
# Define captcha grace period seconds
2526
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaGracePeriodSeconds=1800"
27+
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaCustomJsURL=http://captcha.localhost:8000/fast.js"
28+
# Inside Traefik container the plugin must be able to reach wicketkeeper service so we can go through a Traefik localhost
29+
# domain which would resolve traefik itself and the port for the dashboard
30+
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomValidateURL=http://wicketkeeper:8080/v0/siteverify"
31+
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomKey=wicketkeeper"
32+
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomResponse=wicketkeeper_solution"
2633
# Define captcha HTML file path
2734
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaHTMLFilePath=/captcha.html"
28-
#
29-
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaCustomJsURL=http://localhost:8080/fast.js"
30-
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomValidateURL=http://localhost:8080/v0/siteverify"
31-
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomKey=wicketpeeker"
32-
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomResponse=response"
3335
```
3436
35-
```yaml
36-
wicketkeeper:
37-
image: ghcr.io/a-ve/wicketkeeper:latest
38-
ports:
39-
- "8080:8080"
40-
environment:
41-
- ROOT_URL=http://localhost:8080
42-
- LISTEN_PORT=8080
43-
- REDIS_ADDR=redis:6379
44-
- DIFFICULTY=4
45-
- ALLOWED_ORIGINS=*
46-
- PRIVATE_KEY_PATH=/data/wicketkeeper.key
47-
volumes:
48-
- ./data:/data
49-
depends_on:
50-
- redis
51-
redis:
52-
image: redis/redis-stack-server:latest
37+
```yaml
38+
wicketkeeper:
39+
image: ghcr.io/a-ve/wicketkeeper:latest
40+
user: root
41+
ports:
42+
- "8080:8080"
43+
environment:
44+
- ROOT_URL=http://localhost:8080
45+
- LISTEN_PORT=8080
46+
- REDIS_ADDR=redis:6379
47+
- DIFFICULTY=4
48+
- ALLOWED_ORIGINS=*
49+
- PRIVATE_KEY_PATH=/data/wicketkeeper.key
50+
volumes:
51+
- ./data:/data
52+
depends_on:
53+
- redis
54+
redis:
55+
image: redis/redis-stack-server:latest
5356
```
5457
5558
## Exemple navigation
59+
5660
We can try to query normally the whoami server:
61+
5762
```bash
58-
curl http://localhost:8000
63+
curl http://localhost:8000/foo
5964
```
6065

6166
We can try to ban ourself and retry.
@@ -65,6 +70,7 @@ docker exec crowdsec cscli decisions add --ip 10.0.0.20 -d 10m --type captcha
6570
```
6671

6772
To play the demo environment run:
73+
6874
```bash
6975
make run_custom_captcha
70-
```
76+
```
Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
traefik:
3-
image: "traefik:v3.0.0"
3+
image: "traefik:v3.5.0"
44
container_name: "traefik"
55
restart: unless-stopped
66
command:
@@ -11,29 +11,30 @@ services:
1111
- "--providers.docker=true"
1212
- "--providers.docker.exposedbydefault=false"
1313
- "--entrypoints.web.address=:80"
14+
- "--entrypoints.web.forwardedheaders.trustedips=172.18.0.0/24"
1415

1516
- "--experimental.plugins.bouncer.modulename=github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin"
1617
- "--experimental.plugins.bouncer.version=v1.4.5"
1718
# - "--experimental.localplugins.bouncer.modulename=github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin"
1819
volumes:
1920
- /var/run/docker.sock:/var/run/docker.sock:ro
20-
- logs-captcha-enabled:/var/log/traefik
21-
- './captcha.html:/captcha.html'
21+
- logs-custom-captcha-enabled:/var/log/traefik
22+
- "./captcha.html:/captcha.html"
2223
# - ./../../:/plugins-local/src/github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin
2324
ports:
2425
- 8000:80
2526
- 8080:8080
2627
depends_on:
2728
- crowdsec
2829

29-
whoami:
30+
whoami-foo:
3031
image: traefik/whoami
31-
container_name: "whoaami"
32+
container_name: "simple-service-custom-captcha-foo"
3233
restart: unless-stopped
3334
labels:
3435
- "traefik.enable=true"
3536
# Definition of the router
36-
- "traefik.http.routers.router-foo.rule=Host(`localhost`)"
37+
- "traefik.http.routers.router-foo.rule=PathPrefix(`/foo`)"
3738
- "traefik.http.routers.router-foo.entrypoints=web"
3839
- "traefik.http.routers.router-foo.middlewares=crowdsec@docker"
3940
# Definition of the service
@@ -42,19 +43,20 @@ services:
4243
- "traefik.http.middlewares.crowdsec.plugin.bouncer.enabled=true"
4344
- "traefik.http.middlewares.crowdsec.plugin.bouncer.crowdseclapikey=40796d93c2958f9e58345514e67740e5"
4445
- "traefik.http.middlewares.crowdsec.plugin.bouncer.loglevel=DEBUG"
45-
46+
4647
# Choose captcha provider
4748
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaProvider=custom"
48-
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaCustomJsURL=http://captcha.localhost:8080/fast.js"
49-
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomValidateURL=http://captcha.localhost:8080/v0/siteverify"
50-
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomKey=wicketpeeker"
51-
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomResponse=response"
49+
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaCustomJsURL=http://captcha.localhost:8000/fast.js"
50+
# Inside Traefik container the plugin must be able to reach wicketkeeper service so we can go through a Traefik localhost
51+
# domain which would resolve traefik itself and the port for the dashboard
52+
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomValidateURL=http://wicketkeeper:8080/v0/siteverify"
53+
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomKey=wicketkeeper"
54+
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomResponse=wicketkeeper_solution"
5255
# Define captcha grade period seconds
5356
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaGracePeriodSeconds=20"
5457
# Define captcha HTML file path
5558
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaHTMLFilePath=/captcha.html"
5659

57-
5860
crowdsec:
5961
image: crowdsecurity/crowdsec:v1.6.1-2
6062
container_name: "crowdsec"
@@ -65,39 +67,44 @@ services:
6567
BOUNCER_KEY_TRAEFIK_DEV: 40796d93c2958f9e58345514e67740e5
6668
volumes:
6769
# For captcha and ban mixed decision
68-
- './profiles.yaml:/etc/crowdsec/profiles.yaml:ro'
70+
- "./profiles.yaml:/etc/crowdsec/profiles.yaml:ro"
6971
# For captcha only remediation
7072
# - './profiles_captcha_only.yaml:/etc/crowdsec/profiles.yaml:ro'
71-
- './acquis.yaml:/etc/crowdsec/acquis.yaml:ro'
72-
- logs-captcha-enabled:/var/log/traefik:ro
73-
- crowdsec-db-captcha-enabled:/var/lib/crowdsec/data/
74-
- crowdsec-config-captcha-enabled:/etc/crowdsec/
73+
- "./acquis.yaml:/etc/crowdsec/acquis.yaml:ro"
74+
- logs-custom-captcha-enabled:/var/log/traefik:ro
75+
- crowdsec-db-custom-captcha-enabled:/var/lib/crowdsec/data/
76+
- crowdsec-config-custom-captcha-enabled:/etc/crowdsec/
7577
labels:
7678
- "traefik.enable=false"
7779

7880
wicketkeeper:
79-
image: ghcr.io/a-ve/wicketkeeper:latest
81+
image: ghcr.io/maxlerebourg/wicketkeeper:latest
8082
container_name: "wicketkeeper"
8183
environment:
82-
- ROOT_URL=http://localhost:8080
84+
- ROOT_URL=http://captcha.localhost:8000
8385
- LISTEN_PORT=8080
8486
- REDIS_ADDR=redis:6379
8587
- DIFFICULTY=4
8688
- ALLOWED_ORIGINS=*
89+
- PRIVATE_KEY_PATH=/data/wicketkeeper.key
90+
volumes:
91+
- wicketkeeper-custom-captcha-enabled:/data
92+
user: root
8793
labels:
8894
- "traefik.enable=true"
8995
# Definition of the router
9096
- "traefik.http.routers.router-wicketpeeker.rule=Host(`captcha.localhost`)"
9197
- "traefik.http.routers.router-wicketpeeker.entrypoints=web"
9298
# Definition of the service
93-
- "traefik.http.services.service-foo.loadbalancer.server.port=8080"
99+
- "traefik.http.services.service-whitekeeper.loadbalancer.server.port=8080"
94100
depends_on:
95101
- redis
96102

97103
redis:
98104
image: redis/redis-stack-server:latest
99-
105+
100106
volumes:
101-
logs-captcha-enabled:
102-
crowdsec-db-captcha-enabled:
103-
crowdsec-config-captcha-enabled:
107+
logs-custom-captcha-enabled:
108+
wicketkeeper-custom-captcha-enabled:
109+
crowdsec-db-custom-captcha-enabled:
110+
crowdsec-config-custom-captcha-enabled:

0 commit comments

Comments
 (0)