add a new mode to enable only appsec checking (#128)

*  add a new mode to enable only appsec checking

* 🍱 fix comments
This commit is contained in:
maxlerebourg
2024-02-06 19:42:28 +01:00
committed by GitHub
parent bd71b58f19
commit 6c183d9231
3 changed files with 14 additions and 4 deletions
+8
View File
@@ -153,6 +153,9 @@ func New(ctx context.Context, next http.Handler, config *configuration.Config, n
},
cacheClient: &cache.Client{},
}
if config.CrowdsecMode == configuration.AppsecMode {
return bouncer, nil
}
config.RedisCachePassword, _ = configuration.GetVariable(config, "RedisCachePassword")
bouncer.cacheClient.New(
config.RedisCacheEnabled,
@@ -208,6 +211,11 @@ func (bouncer *Bouncer) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
return
}
if bouncer.crowdsecMode == configuration.AppsecMode {
handleNextServeHTTP(bouncer, remoteIP, rw, req)
return
}
// TODO This should be simplified
if bouncer.crowdsecMode != configuration.NoneMode {
isBanned, cacheErr := bouncer.cacheClient.GetDecision(remoteIP)