UNPKG

http-auth

Version:

Node.js package for HTTP basic and digest access authentication.

19 lines (15 loc) 503 B
// HTTP module var http = require('http'); // Authentication module. var auth = require('../gensrc/http-auth'); var basic = auth.basic({ realm: "Simon Area.", file: __dirname + "/../data/users.htpasswd" // gevorg:gpass, Sarah:testpass ... }); // Creating new HTTP server. http.createServer(basic, 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/"); });