Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

21 lines (17 sloc) 0.677 kb
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;
Jump to Line
Something went wrong with that request. Please try again.