This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
tstatic/src/basic-auth.js
2017-01-21 21:06:21 +00:00

18 lines
433 B
JavaScript

const basicAuth = require('express-basic-auth');
const { BASIC_AUTH_ENABLED } = require('./consts');
function basicAuthHandler(username, password) {
return process.env.BASIC_AUTH_USERNAME === username && process.env.BASIC_AUTH_PASSWORD === password;
}
if (BASIC_AUTH_ENABLED) {
module.exports = basicAuth({
authorizer: basicAuthHandler,
challenge: true
});
} else {
module.exports = (req, res, next) => next();
}