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

add optional http basic auth #2

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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Features
* Define multiple glob patterns to find log files
* List of log files refreshes automatically when new files are added
* Live filtering when watching logs
* Authentication to restrict tail viewing

Setup
-----
Expand Down
3 changes: 3 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"basicAuth": false,
"user": "admin",
"password": "admin",
"port": 8088,
"files": [
{
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"flatiron": "~0.3.11",
"glob": "~3.2.8",
"union": "~0.3.8",
"moment": "~2.5.1"
"moment": "~2.5.1",
"connect": "2.19.6"
}
}
17 changes: 16 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,29 @@ var moment = require('moment');

var Primus = require('primus.io');
var union = require('union');
var connect = require('connect');
var ecstatic = require('ecstatic');
var flatiron = require('flatiron');
var app = flatiron.app;

var tail = require('./lib/tail');
var config = require(__dirname + '/config.json');

app.use(flatiron.plugins.http);
// If the basicAuth property has been set to true in config.json
// http basic auth is used to restrict access to all pages
// user and password properties are also set in the config.json
if (config.basicAuth) {
app.use(flatiron.plugins.http, {
before: [
connect.basicAuth(function(user, pass){
return config.user == user && config.password == pass;
})
]
});
} else {
app.use(flatiron.plugins.http);
}


app.http.before.push(ecstatic(__dirname + '/public'));

Expand Down