Make password configurable / add UI for upload
This commit is contained in:
22
helpers/auth.js
Normal file
22
helpers/auth.js
Normal 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,
|
||||
};
|
||||
Reference in New Issue
Block a user