SendGrid event notification authentication

醉酒当歌 提交于 2020-02-28 07:44:05

问题


I have setup an endpoint for sendgrid to send event notifications. However, the server is setup with basic authentication and the events don't come through because they are not authenticated. How can I authenticate these event webhooks by SendGrid or whitelist SendGrid?


回答1:


You can use basic authentication when setting up the HTTP POST URL by setting it to a value like https://user:password@this.is.my.test/listening/endpoint

Where "user" is the basic authentication user name and "password" is the basic authentication password for the user.

Or

Turn off basic authentication to your listening endpoint and use a simple check to prevent random people/bots from executing all the code at your listening endpoint, when setting the HTTP POST URL include a querystring value:

Then the first thing your listening code should do is extract the querystring and check that "key" = "some_random_value" if is doesn't then just return bad/invalid request. If the querystring contains "key" = "some_random_value" then your code should parse the body. It's not bulletproof but should stop most random requests.

Or

Combine the techniques and do them both!



来源:https://stackoverflow.com/questions/55727577/sendgrid-event-notification-authentication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!