basicauth

0.0.1 • Public • Published

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;

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i basicauth

      Weekly Downloads

      7

      Version

      0.0.1

      License

      none

      Last publish

      Collaborators

      • rupa