This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const basicAuthParser = require('basic-auth') | |
var basicAuth = function (req, res, next) { | |
const user = basicAuthParser(req) | |
const validUser = user && | |
user.name === process.env.BASIC_AUTH_USER && | |
user.pass === process.env.BASIC_AUTH_PASS | |
if (!validUser) { | |
res.set('WWW-Authenticate', 'Basic realm=Authorization Required') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Title: | |
// Loopback Logging - intercept all HTTP responses, | |
// regardless of which middleware/route produced it | |
// References: | |
// https://apidocs.strongloop.com/loopback/#app-middleware | |
// https://apidocs.strongloop.com/loopback/#app-middlewarefromconfig | |
// https://apidocs.strongloop.com/loopback/#app-definemiddlewarephases | |
//Sample # 1 - super simple |