diff options
author | Dave Cole <dave@developmentseed.org> | 2013-04-10 11:35:29 -0400 |
---|---|---|
committer | Dave Cole <dave@developmentseed.org> | 2013-04-10 11:35:29 -0400 |
commit | 1f4b487caa217758245c6fbc819d001e61ac22cc (patch) | |
tree | d766f49d640712bdc2f54f1851fc6cb35cfedb67 /jekyll-hook.js | |
parent | 5e47199c472a2052a7393e3493b8d7c95be53189 (diff) |
Whitelist accounts. Set allowed branch as webhook parameter so it can vary based on repository.
Diffstat (limited to 'jekyll-hook.js')
-rwxr-xr-x | jekyll-hook.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/jekyll-hook.js b/jekyll-hook.js index e020836..399bbe5 100755 --- a/jekyll-hook.js +++ b/jekyll-hook.js @@ -11,8 +11,9 @@ var mailer = email.server.connect(config.email); app.use(express.bodyParser()); // Receive webhook post -app.post('/hooks/jekyll', function(req, res){ +app.post('/hooks/jekyll/:branch', function(req, res){ var data = JSON.parse(req.body.payload); + var branch = req.params.branch; var params = []; // Parse webhook data for internal variables @@ -23,9 +24,15 @@ app.post('/hooks/jekyll', function(req, res){ // Close connection res.send(202); - // End early if not master branch - if (data.branch !== config.branch) { - console.log('Not ' + config.branch + ' branch.'); + // End early if not permitted account + if (config.accounts.indexOf(data.owner) === -1) { + console.log(data.owner + ' is not an authorized account.'); + return; + } + + // End early if not permitted branch + if (data.branch !== branch) { + console.log('Not ' + branch + ' branch.'); return; } |