mirror of
https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin.git
synced 2026-10-17 23:19:37 +02:00
🍱 reduce complexity and set the remediationHeader to 'challenge' instead of decision.Action
This commit is contained in:
2 files changed
+3
-11
No files matched your search
@@ -428,7 +428,7 @@ make run
|
||||
- RemediationHeadersCustomName
|
||||
- string
|
||||
- default: ""
|
||||
- Name of the header you want in response when request are handled by plugin (possible value of the header `ban`, `captcha` or `solved-captcha`)
|
||||
- Name of the header you want in response when request are handled by plugin (possible value of the header `ban`, `challenge`, `captcha` or `solved-captcha`)
|
||||
- ForwardedHeadersCustomName
|
||||
- string
|
||||
- default: "X-Forwarded-For"
|
||||
|
||||
+2
-10
@@ -531,21 +531,13 @@ func (bouncer *Bouncer) handleAppsecResponseServeHTTP(rw http.ResponseWriter, re
|
||||
rw.Header().Add("Set-Cookie", cookie)
|
||||
}
|
||||
if bouncer.remediationCustomHeader != "" {
|
||||
rw.Header().Set(bouncer.remediationCustomHeader, decision.Action)
|
||||
}
|
||||
if rw.Header().Get("Content-Type") == "" && bouncer.banTemplateContentType != "" {
|
||||
rw.Header().Set("Content-Type", bouncer.banTemplateContentType)
|
||||
rw.Header().Set(bouncer.remediationCustomHeader, "challenge")
|
||||
}
|
||||
|
||||
status := decision.HTTPStatus
|
||||
if status == 0 {
|
||||
if status == 0 || status < 100 || status > 999 {
|
||||
status = bouncer.remediationStatusCode
|
||||
}
|
||||
|
||||
if status < 100 || status > 999 {
|
||||
status = bouncer.remediationStatusCode
|
||||
}
|
||||
|
||||
rw.WriteHeader(status)
|
||||
|
||||
if req.Method == http.MethodHead || decision.UserBodyContent == "" {
|
||||
|
||||
Reference in new issue
Block a user