Skip to content

Commit aca2a0e

Browse files
Update HAProxy SPOA documentation with new cookie management approach (#887)
* Update HAProxy SPOA documentation with new cookie management approach - Add new cookie management section explaining the improved approach - Update HAProxy configuration examples to include http-after-response directives - Add automatic cookie setting/clearing based on captcha_status - Improve documentation for CAPTCHA cookie handling * Remove dedicated Cookie Management section - Remove the standalone Cookie Management (New Approach) section - Keep cookie management configuration examples in HAProxy config sections
1 parent 5657896 commit aca2a0e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

crowdsec-docs/unversioned/bouncers/haproxy_spoa.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,13 @@ frontend http-in
170170
filter spoe engine crowdsec config /etc/haproxy/crowdsec.cfg
171171
http-request set-header X-CrowdSec-Remediation %[var(txn.crowdsec.remediation)]
172172
http-request lua.crowdsec_handle if { var(txn.crowdsec.remediation) -m found }
173+
174+
## Handle captcha cookie management via HAProxy (new approach)
175+
## Set captcha cookie when SPOA provides captcha_status (pending or valid)
176+
http-after-response set-header Set-Cookie %[var(txn.crowdsec.captcha_cookie)] if { var(txn.crowdsec.captcha_status) -m found } { var(txn.crowdsec.captcha_cookie) -m found }
177+
## Clear captcha cookie when cookie exists but no captcha_status (Allow decision)
178+
http-after-response set-header Set-Cookie %[var(txn.crowdsec.captcha_cookie)] if { var(txn.crowdsec.captcha_cookie) -m found } !{ var(txn.crowdsec.captcha_status) -m found }
179+
173180
use_backend <whatever>
174181
175182
backend crowdsec-spoa
@@ -212,6 +219,7 @@ recaptcha
212219
turnstile
213220
```
214221

222+
215223
### Prometheus Metrics
216224

217225
Enable and expose metrics:
@@ -393,6 +401,12 @@ frontend test
393401
http-request set-header X-CrowdSec-IsoCode %[var(txn.crowdsec.isocode)] if { var(txn.crowdsec.isocode) -m found }
394402
http-request lua.crowdsec_handle if { var(txn.crowdsec.remediation) -m found }
395403
404+
## Handle captcha cookie management via HAProxy (new approach)
405+
## Set captcha cookie when SPOA provides captcha_status (pending or valid)
406+
http-after-response set-header Set-Cookie %[var(txn.crowdsec.captcha_cookie)] if { var(txn.crowdsec.captcha_status) -m found } { var(txn.crowdsec.captcha_cookie) -m found }
407+
## Clear captcha cookie when cookie exists but no captcha_status (Allow decision)
408+
http-after-response set-header Set-Cookie %[var(txn.crowdsec.captcha_cookie)] if { var(txn.crowdsec.captcha_cookie) -m found } !{ var(txn.crowdsec.captcha_status) -m found }
409+
396410
use_backend test_backend
397411
```
398412

0 commit comments

Comments
 (0)