-
Notifications
You must be signed in to change notification settings - Fork 21
✨ add custom selfhosted captcha #154 #259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maxlerebourg
wants to merge
21
commits into
main
Choose a base branch
from
feat/Add-wicketkeeper-captcha
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
da09739
✨ Add wicketkeeper captcha
maxlerebourg 3dc154f
Merge remote-tracking branch 'origin' into feat/Add-wicketkeeper-captcha
maxlerebourg 7adc579
:sparkles: Anom config
maxlerebourg 854dbc8
:bento: fix readme
maxlerebourg 16a5ea0
:bento: fix lint
maxlerebourg cca600d
:bento: fix lint
maxlerebourg 5299641
:bento: normalize
maxlerebourg f886720
:bento: fix lint
maxlerebourg 1d1d88d
:bento: fix lint
maxlerebourg 75ec932
✨ Add env for RemediationStatusCode (#250)
maxlerebourg 3b0f123
📈 Report traffic dropped metrics to LAPI (#223)
david-garcia-garcia 007f868
:sparkles: Anom config
maxlerebourg 61c9468
:bento: fix readme
maxlerebourg 43c7d3d
:bento: fix lint
maxlerebourg 083d299
:bento: normalize
maxlerebourg 416c395
:bento: fix lint
maxlerebourg 00b3e3e
:memo: Add documentation
5b217e2
📝 Fix example and makefile and doc for wicketkeeper
mathieuHa b313dfe
:bento: fix last things
61b6453
Merge remote-tracking branch 'origin' into feat/Add-wicketkeeper-captcha
56c76ab
Merge branch 'feat/Add-wicketkeeper-captcha' of https://github.com/ma…
maxlerebourg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Example | ||
|
||
Read the example captcha before this, to better understand what is done here. | ||
|
||
### Traefik configuration | ||
|
||
The minimal configuration is defined below to implement custom captcha. | ||
This documentation use https://github.com/a-ve/wicketpeeker, a self-hosted captcha provider that have a similar API than big providers. | ||
|
||
Minimal API requirement: | ||
|
||
- the JS file URL to load the captcha on the served `captcha.html` | ||
- the HTML className to tell to the JS where to display the challenge | ||
- the verify URL endpoint to send the field `response` from the captcha with `content-type: application/x-www-form-urlencoded` | ||
- the name of the field when you POST the resolved captcha to Traefik | ||
|
||
- the JS file need to respect the `data-callback` on the div that contains the captcha if you use our template, but you can customize it by your side | ||
|
||
```yaml | ||
traefik: | ||
... | ||
labels: | ||
# Choose captcha provider | ||
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaProvider=custom" | ||
# Define captcha grace period seconds | ||
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaGracePeriodSeconds=1800" | ||
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaCustomJsURL=http://captcha.localhost:8000/fast.js" | ||
# Inside Traefik container the plugin must be able to reach wicketkeeper service so we can go through a Traefik localhost | ||
# domain which would resolve traefik itself and the port for the dashboard | ||
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomValidateURL=http://wicketkeeper:8080/v0/siteverify" | ||
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomKey=wicketkeeper" | ||
- "traefik.http.middlewares.crowdsec.plugin.bouncer.CaptchaCustomResponse=wicketkeeper_solution" | ||
# Define captcha HTML file path | ||
- "traefik.http.middlewares.crowdsec.plugin.bouncer.captchaHTMLFilePath=/captcha.html" | ||
``` | ||
|
||
```yaml | ||
wicketkeeper: | ||
image: ghcr.io/a-ve/wicketkeeper:latest | ||
user: root | ||
ports: | ||
- "8080:8080" | ||
environment: | ||
- ROOT_URL=http://localhost:8080 | ||
- LISTEN_PORT=8080 | ||
- REDIS_ADDR=redis:6379 | ||
- DIFFICULTY=4 | ||
- ALLOWED_ORIGINS=* | ||
- PRIVATE_KEY_PATH=/data/wicketkeeper.key | ||
volumes: | ||
- ./data:/data | ||
depends_on: | ||
- redis | ||
redis: | ||
image: redis/redis-stack-server:latest | ||
``` | ||
|
||
## Exemple navigation | ||
|
||
We can try to query normally the whoami server: | ||
|
||
```bash | ||
curl http://localhost:8000/foo | ||
``` | ||
|
||
We can try to ban ourself and retry. | ||
|
||
```bash | ||
docker exec crowdsec cscli decisions add --ip 10.0.0.20 -d 10m --type captcha | ||
``` | ||
|
||
To play the demo environment run: | ||
|
||
```bash | ||
make run_custom_captcha | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
filenames: | ||
- /var/log/traefik/access.log | ||
labels: | ||
type: traefik |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use an exemple with whicketkeeper maybe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm waiting for @a-ve to release a new version to use the "official" image instead of the image from my fork of wicketkeeper....