Skip to content

Commit 041353e

Browse files
committed
Forward all known github headers
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: #94
1 parent 39cc2e9 commit 041353e

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

pkg/providers/github.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ const (
1717

1818
// Header constants
1919
const (
20-
XHubSignature = "X-Hub-Signature"
21-
XGitHubEvent = "X-GitHub-Event"
22-
XGitHubDelivery = "X-GitHub-Delivery"
20+
XHubSignature = "X-Hub-Signature"
21+
XGitHubEvent = "X-GitHub-Event"
22+
XGitHubDelivery = "X-GitHub-Delivery"
23+
XHubSignature256 = "X-Hub-Signature-256"
2324
)
2425

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

4142
func (p *GithubProvider) GetHeaderKeys() []string {
42-
if len(strings.TrimSpace(p.secret)) > 0 {
43-
return []string{
44-
XHubSignature,
45-
XGitHubDelivery,
46-
XGitHubEvent,
47-
ContentTypeHeader,
48-
}
49-
}
50-
5143
return []string{
44+
XHubSignature,
45+
XHubSignature256,
5246
XGitHubDelivery,
5347
XGitHubEvent,
5448
ContentTypeHeader,

pkg/providers/github_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func TestGithubProvider_GetHeaderKeys(t *testing.T) {
7171
}{
7272
{
7373
name: "TestGetHeaderKeysWithCorrectValues",
74-
want: []string{XGitHubDelivery, XGitHubEvent, ContentTypeHeader},
74+
want: []string{XHubSignature, XHubSignature256, XGitHubDelivery, XGitHubEvent, ContentTypeHeader},
7575
},
7676
}
7777
for _, tt := range tests {

0 commit comments

Comments
 (0)