Make password configurable / add UI for upload

This commit is contained in:
Senad Uka
2019-05-28 13:48:58 +02:00
parent 84443783da
commit d850aef0b8
22 changed files with 353 additions and 45 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,
};