mirror of
https://github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin.git
synced 2026-07-21 11:38:59 +02:00
🔨 always set custom remediation header if configured for bans (#218)
This commit is contained in:
+3
-3
@@ -350,14 +350,14 @@ type Login struct {
|
|||||||
|
|
||||||
// To append Headers we need to call rw.WriteHeader after set any header.
|
// To append Headers we need to call rw.WriteHeader after set any header.
|
||||||
func handleBanServeHTTP(bouncer *Bouncer, rw http.ResponseWriter) {
|
func handleBanServeHTTP(bouncer *Bouncer, rw http.ResponseWriter) {
|
||||||
|
if bouncer.remediationCustomHeader != "" {
|
||||||
|
rw.Header().Set(bouncer.remediationCustomHeader, "ban")
|
||||||
|
}
|
||||||
if bouncer.banTemplateString == "" {
|
if bouncer.banTemplateString == "" {
|
||||||
rw.WriteHeader(http.StatusForbidden)
|
rw.WriteHeader(http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rw.Header().Set("Content-Type", "text/html; charset=utf-8")
|
rw.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||||
if bouncer.remediationCustomHeader != "" {
|
|
||||||
rw.Header().Set(bouncer.remediationCustomHeader, "ban")
|
|
||||||
}
|
|
||||||
rw.WriteHeader(http.StatusForbidden)
|
rw.WriteHeader(http.StatusForbidden)
|
||||||
_, err := fmt.Fprint(rw, bouncer.banTemplateString)
|
_, err := fmt.Fprint(rw, bouncer.banTemplateString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user