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

Chore: add sendgrid webhook endpoints to receive webhook events #1150

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

StrongMonkey
Copy link
Contributor

Add sendgrid webhook endpoint to be able to receive sendgrid inbound parse event and trigger workflow.

A use case would be getting emails regarding to receipts and have dedicated workflows processing these emails.

return types.NewErrHttp(http.StatusMethodNotAllowed, "Invalid request method")
}

inboundEmail, err := inbound.Parse(req.Request)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sendgrid doesn't have a way to attach secret header so it is a bit tricky to vefify whether requests are coming from sendgrid...this makes our webhook server vulnerable to unverified webhook events from other places. (at least not from our account that you can configure to send a secret key as a header)

so there is no validation right to validate if requests are actually coming from sendgrid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added basic auth protection for now. The username and password can be configured at global level to protect webhook endpoint, and sendgrid webhook can be configured to have configured username and password in front of the url.

@@ -0,0 +1,132 @@
package emailtrigger
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored the code a bit to be able to share some common trigger code from both smtp and sendgrid.

@StrongMonkey StrongMonkey force-pushed the webhook-sendgrid branch 4 times, most recently from 83c04f0 to 4b99147 Compare January 8, 2025 15:57
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.

1 participant