Merge pull request #3 from izqui/webhook-secret

Add webhook secret security measure
This commit is contained in:
Jorge Izquierdo 2017-06-15 10:03:12 +02:00 committed by GitHub
commit 5cb709084d
2 changed files with 4 additions and 2 deletions

View File

@ -5,3 +5,4 @@ EXPOSE 8080
ENV NAME autobounty ENV NAME autobounty
ENV STANDARD_BOUNTY 0.001 ENV STANDARD_BOUNTY 0.001
ENV WEBHOOK_SECRET test

View File

@ -14,6 +14,7 @@ const Eth = require('ethjs-query');
const address = process.env.ADDRESS; const address = process.env.ADDRESS;
const name = process.env.NAME; const name = process.env.NAME;
const webhook_secret = process.env.WEBHOOK_SECRET;
const provider = new SignerProvider(process.env.NODE, { const provider = new SignerProvider(process.env.NODE, {
signTransaction: (rawTx, cb) => cb(null, sign(rawTx, process.env.KEY)), signTransaction: (rawTx, cb) => cb(null, sign(rawTx, process.env.KEY)),
@ -33,7 +34,7 @@ app.use(cors());
var issueData = {}; var issueData = {};
// Receive a POST request at the address specified by an env. var. // Receive a POST request at the address specified by an env. var.
app.post('/' + address.toString(), jsonParser, function(req, res, next){ app.post(`/comment/${webhook_secret}`, jsonParser, function(req, res, next){
if (!req.body) if (!req.body)
return res.sendStatus(400); return res.sendStatus(400);
var commentBody = req.body.comment.body; var commentBody = req.body.comment.body;