basic
HTTP Basic Auth for Node.js
Last updated 2 years ago by diy .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install basic 
SYNC missed versions from official npm registry.

basic

HTTP Basic Auth for Node.js

Build Status Greenkeeper badge

Installation

npm install basic

Basic Use

var http = require('http');
var basic = require('../../lib/index');

var auth = basic(function (user, pass, callback) {
    if (user === 'let' && pass === 'me in') return callback(null);
    callback(401);
});

http.createServer(function (req, res) {
    auth(req, res, function (err) {
        var head = (err) ? {'WWW-Authenticate': 'Basic realm="Secure Area"'} : {};
        res.writeHead(err || 200, head);
        res.end();
    });
}).listen(8000);
curl --head -H "Authorization:Basic bGV0Om1lIGlu" http://localhost:8000

Testing

npm test

Current Tags

  • 2.0.3                                ...           latest (2 years ago)

10 Versions

  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           3 years ago
  • 2.0.1                                ...           3 years ago
  • 2.0.0                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
  • 0.0.3                                ...           6 years ago
  • 0.0.1                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 4
This Month 6
Last Day 3
Last Week 2
Last Month 22
Dependencies (0)
None
Dev Dependencies (2)
Dependents (101)

Copyright 2014 - 2016 © taobao.org |