basic

HTTP Basic Auth for Node.js

npm install basic
8 downloads in the last day
61 downloads in the last week
157 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