Browse Source

Prometheus password fix (#1319)

* Russian translation

* Fix require prometheus password

---------

Co-authored-by: Vadim Babadzhanyan <[email protected]>
pull/1390/head
Vadim Babadzhanyan 7 months ago
committed by GitHub
parent
commit
6e891ad9fb
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 11
      src/lib/Server.js

11
src/lib/Server.js

@ -336,10 +336,6 @@ module.exports = class Server {
});
};
// Prometheus Metrics API
const routerPrometheusMetrics = createRouter();
app.use(routerPrometheusMetrics);
// Check Prometheus credentials
app.use(
fromNodeMiddleware((req, res, next) => {
@ -347,11 +343,10 @@ module.exports = class Server {
return next();
}
const user = basicAuth(req);
if (requiresPrometheusPassword && !user) {
if (!user) {
res.statusCode = 401;
return { error: 'Not Logged In' };
}
if (user.pass) {
if (isPasswordValid(user.pass, PROMETHEUS_METRICS_PASSWORD)) {
return next();
@ -364,6 +359,10 @@ module.exports = class Server {
}),
);
// Prometheus Metrics API
const routerPrometheusMetrics = createRouter();
app.use(routerPrometheusMetrics);
// Prometheus Routes
routerPrometheusMetrics
.get('/metrics', defineEventHandler(async (event) => {

Loading…
Cancel
Save