1.0.7 • Published 2 years ago

http-auth-passport v1.0.7

Weekly downloads
1
License
MIT
Repository
github
Last release
2 years ago

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)

1.0.7

2 years ago

1.0.6

3 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago