🐛 fix bug with recaptcha (#141) and add doc for recaptcha

* 🐛 fix bug with recaptcha

* 📝 Add documentation for recpatcha

---------

Co-authored-by: max.lerebourg <max.lerebourg@monisnap.com>
Co-authored-by: mhx <mathieu@hanotaux.fr>
This commit is contained in:
maxlerebourg
2024-04-01 20:47:54 +02:00
committed by GitHub
parent 497d1a2928
commit 6059f23dc3
5 changed files with 21 additions and 4 deletions

View File

@@ -335,4 +335,4 @@
}
</script>
</body>
</html>
</html>

View File

@@ -143,4 +143,19 @@ sequenceDiagram
Destroy PluginCache
PluginCache-->>TraefikPlugin: Yes a ban Decision
TraefikPlugin->>User: No, HTTP 403
```
```
## Captcha Configuration:
- Recaptcha
Choose v2 (challenge) and configure the domain to protect:
![Recaptcha image](image_recaptcha.png)
- Turnstile
TODO
- Hcatpcha
TODO

View File

@@ -335,4 +335,4 @@
}
</script>
</body>
</html>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

View File

@@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"os"
"strings"
cache "github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin/pkg/cache"
configuration "github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin/pkg/configuration"
@@ -152,7 +153,8 @@ func (c *Client) Validate(r *http.Request) (bool, error) {
c.log.Error(fmt.Sprintf("captcha:Validate %s", err.Error()))
}
}()
if res.Header.Get("content-type") != "application/json" {
if !strings.Contains(res.Header.Get("content-type"), "application/json") {
c.log.Debug("captcha:Validate responseType:noJson")
return false, nil
}
var captchaResponse responseProvider