You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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
+
173
180
use_backend <whatever>
174
181
175
182
backend crowdsec-spoa
@@ -212,6 +219,23 @@ recaptcha
212
219
turnstile
213
220
```
214
221
222
+
#### Cookie Management (New Approach)
223
+
224
+
The HAProxy SPOA bouncer now supports improved cookie management for CAPTCHA handling. This new approach uses `http-after-response` directives to manage CAPTCHA cookies more efficiently:
225
+
226
+
```haproxy
227
+
## Handle captcha cookie management via HAProxy (new approach)
228
+
## Set captcha cookie when SPOA provides captcha_status (pending or valid)
229
+
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 }
230
+
## Clear captcha cookie when cookie exists but no captcha_status (Allow decision)
231
+
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 }
232
+
```
233
+
234
+
This approach provides:
235
+
- Automatic cookie setting when CAPTCHA status is pending or valid
236
+
- Automatic cookie clearing when the decision is to allow (no CAPTCHA status)
237
+
- More reliable cookie management compared to previous methods
238
+
215
239
### Prometheus Metrics
216
240
217
241
Enable and expose metrics:
@@ -393,6 +417,12 @@ frontend test
393
417
http-request set-header X-CrowdSec-IsoCode %[var(txn.crowdsec.isocode)] if { var(txn.crowdsec.isocode) -m found }
394
418
http-request lua.crowdsec_handle if { var(txn.crowdsec.remediation) -m found }
395
419
420
+
## Handle captcha cookie management via HAProxy (new approach)
421
+
## Set captcha cookie when SPOA provides captcha_status (pending or valid)
422
+
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 }
423
+
## Clear captcha cookie when cookie exists but no captcha_status (Allow decision)
424
+
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 }
0 commit comments