Skip to content

Commit

Permalink
Added Basic Auth to the API
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Campos committed Nov 2, 2017
1 parent 57988d7 commit aecce88
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
10 changes: 10 additions & 0 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var redisConfig = {

var storage = require('./lib/storage.js')(redisConfig);

var basicAuth = require('express-basic-auth');


//
// BotKit initialization
//
Expand Down Expand Up @@ -96,6 +99,13 @@ controller.setupWebserver(process.env.PORT || 3000, function(err, webserver) {
console.log("Cisco Spark: Webhooks set up!");
});

var users = {};
users[process.env.API_USERNAME] = process.env.API_PASSWORD;

webserver.use(basicAuth({
users: users
}))

webserver.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE");
Expand Down
17 changes: 15 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"engines": {
"node": "8.2.1"
},
"express-basic-auth": "^1.1.3",
"jfs": "^0.2.6",
"node-env-file": "0.1.8",
"uuid": "^3.1.0"
Expand Down

0 comments on commit aecce88

Please sign in to comment.