http-auth
Version:
Node.js package for HTTP basic and digest access authentication.
17 lines (15 loc) • 494 B
JavaScript
// HTTP module
var http = require('http');
// Authentication module.
var auth = require('../gensrc/http-auth');
var digest = auth.digest({
realm: "Simon Area.",
file: __dirname + "/../data/users.htdigest" // vivi:anna, sona:testpass
});
// Creating new HTTP server.
http.createServer(digest, function(req, res) {
res.end("Welcome to private area - " + req.user + "!");
}).listen(1337, function () {
// Log URL.
console.log("Server running at http://127.0.0.1:1337/");
});