Skip to content

http-auth/http-auth-connect

Folders and files

NameName
Last commit message
Last commit date
Sep 21, 2022
Feb 2, 2020
Feb 3, 2020
Feb 3, 2020
Feb 3, 2020
Feb 3, 2020
Feb 2, 2020
Feb 3, 2020
Feb 3, 2020
Feb 2, 2020
Jun 24, 2021
Jul 18, 2023
Dec 30, 2022

Repository files navigation

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)