Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the VerifyWebhookSignature method to use the WebhookSigningKey as the signature key #321

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

l306287405
Copy link

Correct the VerifyWebhookSignature method to use the WebhookSigningKey as the signature key, instead of incorrectly using the APIKey as the signature key.

…y as the signature key, instead of incorrectly using the APIKey as the signature key.
client *http.Client
baseURL string
overrideHeaders map[string]string
capturedCurlOutput string
}

// NewMailGun creates a new client instance.
func NewMailgun(domain, apiKey string) *MailgunImpl {
// If you need to verify whether a Webhook originates from Mailgun, the webhookSigningKey is required.
func NewMailgun(domain, apiKey string, webhookSigningKey ...string) *MailgunImpl {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we needed some other keys later?
Ideally, this should be an option, but they are slow(https://www.evanjones.ca/go-functional-options-slow.html)

So having some (mg *MailgunImpl) SetWebhookSigningKey(string) should be OK.

Comment on lines +124 to +126
if mg.WebhookSigningKey() == "" {
return false, fmt.Errorf("webhook signing key not set")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of a breaking change, it is better to fall back to the API key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants