itcast bd67f780cf 完成 10 månader sedan
..
src bd67f780cf 完成 10 månader sedan
LICENSE bd67f780cf 完成 10 månader sedan
README.md bd67f780cf 完成 10 månader sedan
package.json bd67f780cf 完成 10 månader sedan

README.md

http-auth-connect

Connect integration with http-auth module.

build

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

// Express module.
// eslint-disable-next-line node/no-unpublished-require
const express = require("express");

// Authentication module.
// eslint-disable-next-line node/no-unpublished-require
const auth = require("http-auth");
// eslint-disable-next-line node/no-unpublished-require
const authConnect = require("http-auth-connect");

const basic = auth.basic({
  realm: "Simon Area.",
  file: __dirname + "/../data/users.htpasswd" // gevorg:gpass, Sarah:testpass
});

// Application setup.
const app = express();
app.use(authConnect(basic));

// Setup route.
app.get("/", (req, res) => {
  res.send(`Hello from express - ${req.user}!`);
});

// Start server.
app.listen(1337, () => {
  // Log URL.
  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)