summaryrefslogtreecommitdiff
path: root/src/server/api/service/github.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-13 09:44:00 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-13 09:44:00 +0900
commit22d2f2051c4cbe3da5b9ece674f36a6555f8c953 (patch)
tree0c29ea7c8f1797f9a28cab2d70d31e91cd9cb312 /src/server/api/service/github.ts
parentwip (diff)
downloadsharkey-22d2f2051c4cbe3da5b9ece674f36a6555f8c953.tar.gz
sharkey-22d2f2051c4cbe3da5b9ece674f36a6555f8c953.tar.bz2
sharkey-22d2f2051c4cbe3da5b9ece674f36a6555f8c953.zip
wip
Diffstat (limited to 'src/server/api/service/github.ts')
-rw-r--r--src/server/api/service/github.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/server/api/service/github.ts b/src/server/api/service/github.ts
index ee226cc5cc..cd9760a36d 100644
--- a/src/server/api/service/github.ts
+++ b/src/server/api/service/github.ts
@@ -35,10 +35,14 @@ if (config.github_bot != null) {
const secret = config.github_bot.hook_secret;
router.post('/hooks/github', ctx => {
+ const body = JSON.stringify(ctx.request.body);
+ const hash = crypto.createHmac('sha1', secret).update(body).digest('hex');
const sig1 = new Buffer(ctx.headers['x-hub-signature']);
- const sig2 = new Buffer(`sha1=${crypto.createHmac('sha1', secret).update(JSON.stringify(ctx.body)).digest('hex')}`);
+ const sig2 = new Buffer(`sha1=${hash}`);
+
+ // シグネチャ比較
if (sig1.equals(sig2)) {
- handler.emit(ctx.headers['x-github-event'], ctx.body);
+ handler.emit(ctx.headers['x-github-event'], ctx.request.body);
ctx.status = 204;
} else {
ctx.status = 400;