server: add --authentication option

This commit is contained in:
bordun 2020-05-05 12:05:46 +02:00
parent 49ef38402f
commit e94b4bf9f6
6 changed files with 57 additions and 5 deletions

23
src/server/auth.js Normal file
View file

@ -0,0 +1,23 @@
var settings = require('./settings'),
auth = null
if (settings.read('authentication')) {
var [name, pwd] = settings.read('authentication').split(':'),
httpAuth = require("http-auth")
auth = httpAuth.basic(
{
realm: "Open Stage Control"
},
(username, password, callback) => {
// Custom authentication method.
callback(username === name && password === pwd);
}
)
}
module.exports = auth