diff --git a/README.md b/README.md index 6117751..9340eb6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/app.js b/app.js index 858f8dd..8a077df 100644 --- a/app.js +++ b/app.js @@ -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()); diff --git a/config.js.example b/config.js.example index 4ed2b0a..3f5398e 100644 --- a/config.js.example +++ b/config.js.example @@ -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 + } };