Run Express basic http auth from a user json file. Inspired by apache .htpasswd files :)
npm install express-json-auth --save
user.json
{
"ted": "123321",
"bear": "123456"
}server.js
var app = require('express')(),
auth = require('express-json-auth')(); // default path: process cwd dir + user.json
// throughout the app
app.use(auth);
// through a route
app.get('/admin', auth, function (req, res) {
res.send('Logged!');
});...
auth = require('express-json-auth')('./private/admin.json');
......
users = {
"ted": "123321",
"bear": "123456"
},
auth = require('express-json-auth').plain(users);
...- 0.0.1 - First release - Basic auth from a json
MIT License (c) Helder Santana