Add basic auth support to API
This commit is contained in:
parent
89a5bbae2f
commit
c81740e339
10
lib/api.js
10
lib/api.js
|
@ -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/"));
|
||||||
|
|
Loading…
Reference in New Issue