Skip to content
http basic auth for node as simple as I can make it
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README
auth.js
package.json

README

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;
Something went wrong with that request. Please try again.