HTTP basic auth as simple as I could make it. This package is neither stable nor guaranteed to work.
Usage: In a server, pass request, response, and a callback to authorize(). The callback get the submitted user and pass and should return false if user is not authorized.
auth.authorize(req, res, callback)
auth.content_type = 'application/json'
auth.realm = "private"
auth.msg = '{"error":"401 Unauthorized"}'
Example: auth = require('./auth'); var creds = auth.authorize(req, res, function(user, pass) { if( user == 'validuser' && pass == 'correctpassword' ) return user; return false; }); if( ! creds ) return;