我目前正在构建一个利用Shippo的webhooks功能的应用程序,但想知道是否可以确保HTTP POST请求来自Shippo的服务器而不是某些恶意的第三方。
向Shippo添加webhook: https://shippo-static.s3.amazonaws.com/img/illustrations/webhooks.png
当收到HTTP请求时,看起来好像Shippo没有提供密钥或我可以用来验证请求来自shippo的任何东西。有没有办法能够追溯并安全地确保请求来自Shippo的服务器?
示例标题:
User-Agent:python-requests / 2.9.1
Via:1.1 vegur
接受: /
连接:关闭
内容长度:2203
总路线时间:0
Cf-Connecting-Ip:54.87.248.176
Cf-Ipcountry:美国
X-Request-Id:cec0a1aa-6a1a-47e9-ac9d-c685a893591d
Cf-Ray:3d0718455e149fea-IAD
连接时间:1
Accept-Encoding:gzip
主持人:requestb.in
Shippo-Api-Version:2017-08-01
Cf-Visitor:{“scheme”:“https”}
Content-Type:application / json
示例JSON响应: https://goshippo.com/docs/tracking
答案 0 :(得分:0)
你需要做两件事:
https://yourapp.com/webhookroute/?secure_token=123abc
。解析并检查令牌服务器端。可以添加多个令牌,即https://yourapp.com/webhookroute/?secure_token_1=123abc&secure_token_2=456def
如果令牌设置为env vars服务器端,则应该是安全的。