server: lint
This commit is contained in:
parent
a560313619
commit
f0bb17193d
2 changed files with 12 additions and 13 deletions
|
|
@ -4,18 +4,17 @@ var settings = require('./settings'),
|
|||
if (settings.read('authentication')) {
|
||||
|
||||
var [name, pwd] = settings.read('authentication').split(':'),
|
||||
httpAuth = require("http-auth")
|
||||
httpAuth = require('http-auth')
|
||||
|
||||
|
||||
auth = httpAuth.basic(
|
||||
{
|
||||
realm: "Open Stage Control"
|
||||
},
|
||||
(username, password, callback) => {
|
||||
// Custom authentication method.
|
||||
callback(username === name && password === pwd);
|
||||
}
|
||||
)
|
||||
auth = httpAuth.basic(
|
||||
{
|
||||
realm: 'Open Stage Control'
|
||||
},
|
||||
(username, password, callback) => {
|
||||
// Custom authentication method.
|
||||
callback(username === name && password === pwd)
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ class Ipc extends EventEmitter {
|
|||
this.server.on('connection', (socket, req)=>{
|
||||
|
||||
if (settings.read('authentication')) {
|
||||
if (!req.headers.authorization) return;
|
||||
if (req.headers.authorization.search('Basic ') !== 0) return;
|
||||
if (!req.headers.authorization) return
|
||||
if (req.headers.authorization.search('Basic ') !== 0) return
|
||||
var auth = new Buffer(req.headers.authorization.split(' ')[1], 'base64').toString()
|
||||
if (settings.read('authentication') !== auth) {
|
||||
console.log(`(WARNING) Client connexion refused for ${req.connection.remoteAddress} (authentication failed)`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue