Skip to content

Commit f959e79

Browse files
committed
Change parser to forward all headers
Previous to this changes, only the relevant headers for the hook were forwarded. Right now, we are keeping all of them and then we are checking that, required headers, are present. This should prevent removing the github signature when the proxy does not validate the request signature.
1 parent 39cc2e9 commit f959e79

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pkg/parser/parser.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,17 @@ func Parse(req *http.Request, provider providers.Provider) (*providers.Hook, err
1414
}
1515

1616
for _, header := range provider.GetHeaderKeys() {
17-
if req.Header.Get(header) != "" {
18-
hook.Headers[header] = req.Header.Get(header)
19-
continue
17+
if req.Header.Get(header) == "" {
18+
return nil, errors.New("Required header '" + header + "' not found in Request")
2019
}
21-
return nil, errors.New("Required header '" + header + "' not found in Request")
20+
21+
// Store required headers in the expected casing
22+
hook.Headers[header] = req.Header.Get(header)
23+
}
24+
25+
for header := range req.Header {
26+
// Store the rest of the headers in any casing
27+
hook.Headers[header] = req.Header.Get(header)
2228
}
2329

2430
if body, err := ioutil.ReadAll(req.Body); err != nil {

0 commit comments

Comments
 (0)