mirror of
https://dev.azure.com/schwarzit/schwarzit.stackit-public/_git/audit-go
synced 2026-02-08 00:57:24 +00:00
Filter :authority gRPC header
This commit is contained in:
parent
d1b1ae040f
commit
965fa4e617
2 changed files with 3 additions and 2 deletions
|
|
@ -603,12 +603,12 @@ func byteArrayToPbStruct(bytes []byte) (*structpb.Struct, error) {
|
|||
return structpb.NewStruct(bodyMap)
|
||||
}
|
||||
|
||||
// FilterAndMergeHeaders filters the "Authorization" and "B3" headers as well as
|
||||
// FilterAndMergeHeaders filters ":authority", "Authorization" and "B3" headers as well as
|
||||
// all headers starting with the prefixes "X-" and "STACKIT-".
|
||||
// Headers are merged if there is more than one value for a given name.
|
||||
func FilterAndMergeHeaders(headers map[string][]string) map[string]string {
|
||||
var resultMap = make(map[string]string)
|
||||
skipHeaders := []string{"authorization", "b3"}
|
||||
skipHeaders := []string{":authority", "authorization", "b3"}
|
||||
skipPrefixHeaders := []string{"x-", "stackit-"}
|
||||
|
||||
if len(headers) == 0 {
|
||||
|
|
|
|||
|
|
@ -366,6 +366,7 @@ func Test_FilterAndMergeRequestHeaders(t *testing.T) {
|
|||
headers := make(map[string][]string)
|
||||
headers["Authorization"] = []string{"ey..."}
|
||||
headers["B3"] = []string{"80f198ee56343ba864fe8b2a57d3eff7-e457b5a2e4d86bd1-1-05e3ac9a4f6e3b90"}
|
||||
headers[":authority"] = []string{"localhost:9090"}
|
||||
|
||||
filteredHeaders := FilterAndMergeHeaders(headers)
|
||||
assert.Equal(t, 0, len(filteredHeaders))
|
||||
|
|
|
|||
Loading…
Reference in a new issue