basic

HTTP Basic Auth for Node.js

npm install basic
24 downloads in the last day
142 downloads in the last week
284 downloads in the last month

basic

HTTP Basic Auth for Node.js

Installation

npm install basic

Basic Use

var basic   = require('basic'),
    http    = require('http');


var auth    = basic(function (user, pass, callback) {
    if (user === 'let' && pass === 'me in') return callback(null);
    callback(401);
});

http.createServer(function (req, res) {
    auth(req, res, function (err) {
        if (err) {
            res.writeHead(err);
            res.end();
        }

        res.writeHead(200);
        res.end();
    });
}).listen(8000);

Testing

npm test
npm loves you