rvagg / rvagg/github-webhook-handler
X-Hub-Signature does not match blob signature
未关闭
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 793
- 派生
- 121
- PR 合并指标
- 30 天内没有已合并 PR
描述
using my own function works but it crash with github-webhook-handler:
const createComparisonSignature = (body) => {
const hmac = crypto.createHmac('sha1', process.env.GITHUB_SECRET);
const self_signature = hmac.update(JSON.stringify(body)).digest('hex');
return `sha1=${self_signature}`; // shape in GitHub header
}
const compareSignatures = (signature, comparison_signature) => {
const source = Buffer.from(signature);
const comparison = Buffer.from(comparison_signature);
return crypto.timingSafeEqual(source, comparison); // constant time comparison
}
const { headers, body } = req;
const signature = headers['x-hub-signature'];
const comparison_signature = createComparisonSignature(req.body);
if (!compareSignatures(signature, comparison_signature)) {
return res.status(401).send('Mismatched signatures');
} else {
console.log("signature match")
const { action, ...payload } = body;
req.event_type = headers['x-github-event']; // one of: https://developer.github.com/v3/activity/events/types/
req.action = action;
req.payload = payload;
next();
}
return next()
please let me know if there is any solution
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
issue 中没有指定源文件或测试。首先跟踪 github-webhook-handler 如何接收和解析 req.body,然后将用于签名验证的字节与原始请求正文进行比较。在没有报告中的不匹配的情况下,能够始终如一地验证有效的 X-Hub-Signature,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- api, backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100