http-auth-passport

1.0.7 • Public • Published

http-auth-passport

Passport.js integration with http-auth module.

build

Installation

Via git (or downloaded tarball):

$ git clone git://github.com/http-auth/http-auth-passport.git

Via npm:

$ npm install http-auth-passport

Usage

// Express module.
const express = require("express");

// Authentication module.
const auth = require("http-auth");
const authPassport = require("http-auth-passport");
const basic = auth.basic({
  realm: "Simon Area.",
  file: __dirname + "/../data/users.htpasswd" // gevorg:gpass, Sarah:testpass
});

// Application setup.
const app = express();

// Passport.
const passport = require("passport");
passport.use(authPassport(basic));

// Setup route.
app.get("/", passport.authenticate("http", { session: false }), (req, res) => {
  res.end(`Welcome to private area - ${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)

Package Sidebar

Install

npm i http-auth-passport

Weekly Downloads

17

Version

1.0.7

License

MIT

Unpacked Size

4.65 kB

Total Files

4

Last publish

Collaborators

  • gevorg