server: add --authentication option
This commit is contained in:
parent
49ef38402f
commit
e94b4bf9f6
6 changed files with 57 additions and 5 deletions
23
src/server/auth.js
Normal file
23
src/server/auth.js
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue