AuthZ: add headers for IP range AC checks for data source proxy requests (#81662)

* add a middleware that appens headers for IP range AC to data source proxy requests

* update code

* add tests

* fix a mistake

* add logging

* refactor to reuse code

* small cleanup

* skip the plugins middleware if the header is already set

* skip the plugins middleware if the header is already set
This commit is contained in:
Ieva
2024-03-06 12:40:48 +00:00
committed by GitHub
parent 401265522e
commit 2c5b72e844
5 changed files with 197 additions and 24 deletions

View File

@@ -1944,6 +1944,9 @@ func (cfg *Cfg) readDataSourceSecuritySettings() {
datasources := cfg.Raw.Section("datasources.ip_range_security")
cfg.IPRangeACEnabled = datasources.Key("enabled").MustBool(false)
cfg.IPRangeACSecretKey = datasources.Key("secret_key").MustString("")
if cfg.IPRangeACEnabled && cfg.IPRangeACSecretKey == "" {
cfg.Logger.Error("IP range access control is enabled but no secret key is set")
}
allowedURLString := datasources.Key("allow_list").MustString("")
for _, urlString := range util.SplitString(allowedURLString) {
allowedURL, err := url.Parse(urlString)