Add basic auth support to API

This commit is contained in:
Andrew Stewart 2014-04-03 16:04:11 -07:00
parent 89a5bbae2f
commit c81740e339
1 changed files with 10 additions and 0 deletions

View File

@ -40,6 +40,16 @@ namespace("Cylon", function() {
this.server.set('title', 'Cylon API Server'); this.server.set('title', 'Cylon API Server');
// configure basic auth, if requested
if (opts.auth.type && opts.auth.type === 'basic') {
var user = opts.auth.user,
pass = opts.auth.pass;
if (user && pass) {
this.server.use(express.basicAuth(user, pass));
}
}
this.server.use(express.json()); this.server.use(express.json());
this.server.use(express.urlencoded()); this.server.use(express.urlencoded());
this.server.use(express["static"](__dirname + "/../node_modules/robeaux/")); this.server.use(express["static"](__dirname + "/../node_modules/robeaux/"));