From 041353e90d6f6fdc6e81573ff4b0842c8fd75ec5 Mon Sep 17 00:00:00 2001 From: Guillem Nieto Date: Fri, 8 Apr 2022 16:01:42 +0200 Subject: [PATCH] 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: https://github.com/stakater/GitWebhookProxy/issues/94 --- pkg/providers/github.go | 18 ++++++------------ pkg/providers/github_test.go | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/pkg/providers/github.go b/pkg/providers/github.go index 8a1688d..d4b57e7 100644 --- a/pkg/providers/github.go +++ b/pkg/providers/github.go @@ -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 ( @@ -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, diff --git a/pkg/providers/github_test.go b/pkg/providers/github_test.go index 8a1bbd0..8ab66c7 100644 --- a/pkg/providers/github_test.go +++ b/pkg/providers/github_test.go @@ -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 {