Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add basic auth #74

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@
},
"dependencies": {
"animate.css": "^3.4.0",
"basicauth-middleware": "^2.0.0",
"d3": "^3.5.7",
"eventemitter3": "^1.1.1",
"express": "^4.13.3",
"express-ws": "2.0.0",
"less": "^2.5.3",
"less-loader": "^2.0.0",
"lodash": "^3.10.1",
"normalize.css": "^3.0.3",
"request": "^2.65.0",
"superagent": "^1.4.0",
"svg-inline-loader": "^0.3.0",
"ws":"1.1.0",
"express-ws":"2.0.0"

"ws": "1.1.0"
}
}
6 changes: 4 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var superagent = require('superagent');
var net = require('net');
var http = require('http');
var https = require('https');
var basicauth = require('basicauth-middleware');
var WS = require('ws');

var WebSocketServer = WS.Server;
Expand All @@ -28,7 +29,6 @@ app.use(ctxRoot, express.static('dist'));

var server = app.listen(8080, function () {
indexData = _.template(fs.readFileSync('index.tpl'))(process.env);

});

app.get(ctxRoot, function(req, res) {
Expand Down Expand Up @@ -58,7 +58,9 @@ console.log(process.env.DOCKER_HOST)

var wss = new WebSocketServer({server: server});

app.get(ctxRoot + 'apis/*', function(req, response) {
var authMiddleware = basicauth(process.env.USERNAME, process.env.PASSWORD, 'Docker Swarm Visualizer');

app.get(ctxRoot + 'apis/*', authMiddleware, function(req, response) {
var path = req.params[0];
var jsonData={};
var options = {
Expand Down