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

Closed
wants to merge 1 commit into 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

@vtopc vtopc Sep 15, 2024

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.

Maybe with some TODO(v5): to remove the fallback in the future.

vtopc pushed a commit that referenced this pull request Nov 28, 2024
…351)

Since [the other PR](#321)
didn't seem to be being addressed, I'm submitting my own. The issues
brought up in it have been resolved. Tests pass and it seems to work as
directed when testing it as a `replace` in a different project. Please
let me know if anything needs addressed, I'd like to have this available
as soon as I can get it. Thanks!
@vtopc
Copy link
Contributor

vtopc commented Nov 28, 2024

Done in #351

@vtopc vtopc closed this Nov 28, 2024
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