http-auth-connect
Connect integration with http-auth module.
Installation
Via git (or downloaded tarball):
$ git clone git://github.com/http-auth/http-auth-connect.git
Via npm:
$ npm install http-auth-connect
Usage
const express = require("express");
const auth = require("http-auth");
const authConnect = require("http-auth-connect");
const basic = auth.basic({
realm: "Simon Area.",
file: __dirname + "/../data/users.htpasswd"
});
const app = express();
app.use(authConnect(basic));
app.get("/", (req, res) => {
res.send(`Hello from express - ${req.user}!`);
});
app.listen(1337, () => {
console.log("Server running at http://127.0.0.1:1337/");
});
Running tests
It uses mocha, so just run following command in package directory:
$ npm test
License
The MIT License (MIT)