Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change parser to forward all headers
Browse files Browse the repository at this point in the history
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.
gnieto committed Apr 27, 2022
1 parent 39cc2e9 commit f959e79
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/parser/parser.go
Original file line number Diff line number Diff line change
@@ -14,11 +14,17 @@ func Parse(req *http.Request, provider providers.Provider) (*providers.Hook, err
}

for _, header := range provider.GetHeaderKeys() {
if req.Header.Get(header) != "" {
hook.Headers[header] = req.Header.Get(header)
continue
if req.Header.Get(header) == "" {
return nil, errors.New("Required header '" + header + "' not found in Request")
}
return nil, errors.New("Required header '" + header + "' not found in Request")

// Store required headers in the expected casing
hook.Headers[header] = req.Header.Get(header)
}

for header := range req.Header {
// Store the rest of the headers in any casing
hook.Headers[header] = req.Header.Get(header)
}

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

0 comments on commit f959e79

Please sign in to comment.