From e5fdb2d460feed6beda8cac764b15f173b67159d Mon Sep 17 00:00:00 2001 From: Rubén Beltrán del Río Date: Sun, 19 Feb 2017 01:59:26 -0600 Subject: Check the Account SID (#3) * Add twilio config to readme * Modify wording of main menu. * Modify wording of recording message * Add account sid setting to readme * Add the twilio account sid to config * Add check for accountSid * Update paw to send AccountSid --- lib/dead_drop.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/dead_drop.js') diff --git a/lib/dead_drop.js b/lib/dead_drop.js index 6f97645..3336444 100644 --- a/lib/dead_drop.js +++ b/lib/dead_drop.js @@ -45,10 +45,24 @@ module.exports = internals.DeadDrop = class DeadDrop { _initializeServer() { + const self = this; + this._app = Koa(); this._app.use(KoaBodyParser()); + this._app.use(function * (next) { + + const accountSid = this.request.body.AccountSid || this.request.query.AccountSid; + + if (accountSid === self.twilioAccountSid) { + yield next; + } + else { + this.throw('Unauthorized', 401); + } + }); + this._initializeMainMenuRoutes(); this._initializeRecordingMenuRoutes(); this._initializeRecordingsRoutes(); -- cgit