Team LBAC: Refactor to use only the teamHeader json part (#76756)

* refactor: to check for feature toggle and for checking for jsonData field

* fix tests

* whitelisting of X-Prom-Label-Policy Header
This commit is contained in:
Eric Leijonmarck
2023-10-18 16:09:22 +01:00
committed by GitHub
parent 756df61a88
commit 17fe1d3fc7
4 changed files with 30 additions and 55 deletions

View File

@@ -78,9 +78,13 @@ type TeamHTTPHeader struct {
}
func (ds DataSource) TeamHTTPHeaders() (TeamHTTPHeaders, error) {
teamHTTPHeadersJSON := TeamHTTPHeadersJSONData{}
if ds.JsonData != nil {
jsonData, err := ds.JsonData.MarshalJSON()
return GetTeamHTTPHeaders(ds.JsonData)
}
func GetTeamHTTPHeaders(jsonData *simplejson.Json) (TeamHTTPHeaders, error) {
teamHTTPHeadersJSON := TeamHTTPHeaders{}
if jsonData != nil && jsonData.Get("teamHttpHeaders") != nil {
jsonData, err := jsonData.Get("teamHttpHeaders").MarshalJSON()
if err != nil {
return nil, err
}
@@ -90,7 +94,7 @@ func (ds DataSource) TeamHTTPHeaders() (TeamHTTPHeaders, error) {
}
}
return teamHTTPHeadersJSON.TeamHTTPHeaders, nil
return teamHTTPHeadersJSON, nil
}
// AllowedCookies parses the jsondata.keepCookies and returns a list of