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

#39 add support for basic auth, update documentation, bump version #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ var matador = require('bull-ui/app')({
host: your host name,
port: your port number,
password: optional auth password
},
auth: { // optional
username: 'admin',
password: 'password'
}
});
```
Expand Down
16 changes: 14 additions & 2 deletions lib/setupAndMiddleware.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var redisAdapter = require('./redisConnector'),
express = require('express');
var bodyParser = require('body-parser');
express = require('express'),
bodyParser = require('body-parser'),
auth = require('http-auth');

module.exports = function(app, options){
options = options || {};
Expand All @@ -20,6 +21,17 @@ module.exports = function(app, options){
//Enforce that redis is connected to, will make render an error page if not connected
app.use(redisConnectionEnforcer);

// Add authentication if specified
if(options.auth){
var basic = auth.basic({
realm: 'NOTHING TO SEE HERE'
}, function(username, password, callback) {
callback(username == options.auth.username && password == options.auth.password);
})

app.use(auth.connect(basic))
}

app.use(bodyParser.urlencoded({extended: true}));

//Publicly accessible routes
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bull-ui",
"version": "1.2.3",
"version": "1.2.4",
"description": "Front-end web interface for Bull Job Manager",
"main": "index.js",
"dependencies": {
Expand All @@ -10,6 +10,7 @@
"consolidate": "~0.10.0",
"dustjs-linkedin": "~2.5.1",
"express": "^4.13.4",
"http-auth": "^3.1.3",
"less": "~2.1.2",
"lodash": "~2.4.1",
"moment": "^2.17.1",
Expand Down