Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

http basic auth for node as simple as I can make it

branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

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.