我正在嘗試獲取有關發生事件的通知。這是我使用的 webhook 端點。URL 必須是公開訪問的。在考慮安全性時,這是否足夠或者我應該使用任何其他方法?
[HttpPost("WebHook/{id}")]
public async Task<IActionResult> WebHook(int id)
{
var json = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync();
Event stripeEvent;
try
{
//Get webhook secret
string webHookSecret = XXXX;
//Construct stripe Event
stripeEvent = EventUtility.ConstructEvent(
json,
Request.Headers["Stripe-Signature"],
webHookSecret
);
}
catch (Exception ex)
{
LoggingUtil.LogError(ex, ex.Message);
return BadRequest();
}
}
uj5u.com熱心網友回復:
僅憑 webhook 簽名驗證是不夠的,因為 Stripe 使用共享秘密的訊息身份驗證而不是非對稱加密數字簽名。如果您沒有構建防彈服務器的偏執意圖,您可以從Stripe 的安全建議開始。微不足道的IP 地址過濾可以使您的 URL 不那么“可公開訪問”。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/460901.html
