use ENV variables

This commit is contained in:
Bilal Catic
2019-05-24 15:42:45 +02:00
parent aa3a4d8720
commit 304de9bd32
7 changed files with 41 additions and 13 deletions

22
helpers/auth.js Normal file
View File

@@ -0,0 +1,22 @@
'use strict';
const basicAuth = require('express-basic-auth');
function myAuthorizer(username, password) {
if (!process.env.BASIC_AUTH_USERNAME || !process.env.BASIC_AUTH_PASSWORD){
return false;
}
const userMatches = basicAuth.safeCompare(username, process.env.BASIC_AUTH_USERNAME);
const passwordMatches = basicAuth.safeCompare(password, process.env.BASIC_AUTH_PASSWORD);
return userMatches & passwordMatches
}
function getUnauthorizedResponse(req) {
return 'Forbidden';
}
module.exports = {
myAuthorizer,
getUnauthorizedResponse,
};