How to use the http-auth.passport function in http-auth

To help you get started, we’ve selected a few http-auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BarnesFoundation / barnes-tms-extract / src / dashboard / src / index.js View on Github external
const Express = require('express');
const path = require('path');
const Promise = require('bluebird');
const SenecaWeb = require('seneca-web');
const _ = require('lodash');
const bodyParser = require('body-parser');
const auth = require('http-auth');
const passport = require('passport');

const Router = Express.Router;
const context = new Router();

const basicAuth = auth.basic({
	file: config.Dashboard.htpasswd
});
passport.use(auth.passport(basicAuth));

const senecaWebConfig = {
	context,
	adapter: require('seneca-web-adapter-express'), // eslint-disable-line
	options: { parseBody: false },
};

const app = Express();
app.use(bodyParser.json());
app.use(context);
app.use(Express.static(path.resolve(`${__dirname}/../public`)) );
app.set('view engine', 'pug');
app.set('views', path.resolve(`${__dirname}/../views`));


// redirect http to https
github BarnesFoundation / barnes-tms-extract / src / es_api / server.js View on Github external
const bodyParser = require('body-parser');
const config = require('config');
const elasticsearch = require('elasticsearch');
const Express = require('express');
const passport = require('passport');
const path = require('path');
const Router = Express.Router;
const _ = require('lodash');
const { makeElasticsearchOptions } = require('../util/elasticOptions.js');

const context = new Router();

const basicAuth = auth.basic({
	file: config.ElasticsearchAPI.htpasswd
});
passport.use(auth.passport(basicAuth));

const app = Express();
app.use(bodyParser.json());
app.use(context);

// redirect http to https
if (process.env.NODE_ENV === "production") {
	app.enable('trust proxy');
	app.use(function(req, res, next) {
		if (req.headers['x-forwarded-proto'] && req.headers['x-forwarded-proto'].toLowerCase() === 'http') {
			return res.redirect('https://' + req.headers.host + req.url);
		}
		return next();
	});
}

http-auth

Node.js package for HTTP basic and digest access authentication.

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis