Class JdyWebhookUtil

java.lang.Object
cn.toint.jdy4j.core.util.JdyWebhookUtil

public class JdyWebhookUtil extends Object
Author:
Toint
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    decode(jakarta.servlet.http.HttpServletRequest request, String secret)
    解码简道云 webhook 请求 为了防止 webhook 的接收服务器被第三方恶意攻击,用户在开发回调接口时,建议对回调请求进行签名校验,以确保回调请求来源来自于简道云。

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JdyWebhookUtil

      public JdyWebhookUtil()
  • Method Details

    • decode

      public static JdyWebhookRequest decode(jakarta.servlet.http.HttpServletRequest request, String secret)
      解码简道云 webhook 请求 为了防止 webhook 的接收服务器被第三方恶意攻击,用户在开发回调接口时,建议对回调请求进行签名校验,以确保回调请求来源来自于简道云。hook会以POST的形式将内容以JSON格式发送给指定地址。 1. 在界面上随机生成一个secret或者自己指定一个secret,并保存。这样,数据推送时就会把加密前的内容和通过secret加密后的内容一起推送到指定地址。 2. 把http请求体字符串作为payload,将其和secret,请求参数里的 nonce、timestamp 按照 “{nonce}:{payload}:{secret}:{timestamp}” 的形式(用冒号分隔),组合为校验字符串 signature。 3. 以 utf-8 编码形式计算 signature 的 sha-1 散列 4. 将 signature 散列的十六进制字符串与 POST 请求 header 中的 ‘X-JDY-Signature’ 做比较,若比较结果相同,则通过签名验证;若比较结果不同,则无法通过检查