Use HTTP Basic Auth if username and password is defined in config

Fixes #5
This commit is contained in:
Björn Dahlgren 2015-05-30 02:29:48 +02:00
parent f973eca818
commit 2738e61597
3 changed files with 9 additions and 0 deletions

View File

@ -24,6 +24,7 @@ path | Folder path to game server
port | Web port to use
host | IP or Hostname to listen on
type | Which kind of server to use, can be 'linux', 'windows' or 'wine'
auth | If both username and password is set, HTTP Basic Auth will be used
## How to Use

4
app.js
View File

@ -9,6 +9,10 @@ var app = express();
var server = require('http').Server(app);
var io = require('socket.io')(server);
if (config.auth && config.auth.username && config.auth.password) {
app.use(express.basicAuth(config.auth.username, config.auth.password));
}
app.use(express.logger('dev'));
app.use(express.cookieParser());
app.use(express.bodyParser());

View File

@ -4,4 +4,8 @@ module.exports = {
port: 3000,
host: '0.0.0.0', // Can be either an IP or a Hostname
type: 'linux', // Can be either linux, windows or wine
auth: { // If both username and password is set, HTTP Basic Auth will be used
username: '', // Username for HTTP Basic Auth
password: '', // Password for HTTP Basic Auth
}
};