Skip to content

Commit

Permalink
Forward all known github headers
Browse files Browse the repository at this point in the history
Previous implementation was preventing to proxy signature headers,
unless some secret was set up.

By forwarding all the known GitHub headers, upstream service can do this
checks. Note that this do not break the signature validation on this
proxy.

I've also added the sha256 signature header to the list of known GitHub
headers.

Fixes: stakater#94
  • Loading branch information
gnieto committed Apr 8, 2022
1 parent 39cc2e9 commit 041353e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 6 additions & 12 deletions pkg/providers/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ const (

// Header constants
const (
XHubSignature = "X-Hub-Signature"
XGitHubEvent = "X-GitHub-Event"
XGitHubDelivery = "X-GitHub-Delivery"
XHubSignature = "X-Hub-Signature"
XGitHubEvent = "X-GitHub-Event"
XGitHubDelivery = "X-GitHub-Delivery"
XHubSignature256 = "X-Hub-Signature-256"
)

const (
Expand All @@ -39,16 +40,9 @@ func NewGithubProvider(secret string) (*GithubProvider, error) {
}

func (p *GithubProvider) GetHeaderKeys() []string {
if len(strings.TrimSpace(p.secret)) > 0 {
return []string{
XHubSignature,
XGitHubDelivery,
XGitHubEvent,
ContentTypeHeader,
}
}

return []string{
XHubSignature,
XHubSignature256,
XGitHubDelivery,
XGitHubEvent,
ContentTypeHeader,
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestGithubProvider_GetHeaderKeys(t *testing.T) {
}{
{
name: "TestGetHeaderKeysWithCorrectValues",
want: []string{XGitHubDelivery, XGitHubEvent, ContentTypeHeader},
want: []string{XHubSignature, XHubSignature256, XGitHubDelivery, XGitHubEvent, ContentTypeHeader},
},
}
for _, tt := range tests {
Expand Down

0 comments on commit 041353e

Please sign in to comment.