new(all): Web log.

This commit is contained in:
Rodrigo Rodriguez 2022-08-07 11:05:20 -03:00
parent 28a6f33700
commit c508019ca0

View file

@ -203,18 +203,20 @@ export class GBServer {
'admin': { password: process.env.ADMIN_PASS },
};
// ... some not authenticated middlewares
// ... some not authenticated middlewares
server.use((req, res, next) => {
var user = auth(req);
if (!user || !admins[user.name] || admins[user.name].password !== user.pass) {
res.set('WWW-Authenticate', 'Basic realm="example"');
return res.status(401).send();
if (req.originalUrl.startsWith('/logs')) {
var user = auth(req);
if (!user || !admins[user.name] || admins[user.name].password !== user.pass) {
res.set('WWW-Authenticate', 'Basic realm="example"');
return res.status(401).send();
}
}
return next();
});
// If global log enabled, reorders transports adding web logging.
// If global log enabled, reorders transports adding web logging.
const loggers = GBLog.getLogger();
require('winston-logs-display')(server, loggers[1]);