forked from mirrors/amnezia-wg-easy
		
	Prometheus password fix (#1319)
* Russian translation * Fix require prometheus password --------- Co-authored-by: Vadim Babadzhanyan <vadim.babadzhanyan@my.games>
This commit is contained in:
		
							parent
							
								
									e2fe3b8b32
								
							
						
					
					
						commit
						6e891ad9fb
					
				
					 1 changed files with 5 additions and 6 deletions
				
			
		| 
						 | 
					@ -336,10 +336,6 @@ module.exports = class Server {
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Prometheus Metrics API
 | 
					 | 
				
			||||||
    const routerPrometheusMetrics = createRouter();
 | 
					 | 
				
			||||||
    app.use(routerPrometheusMetrics);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // Check Prometheus credentials
 | 
					    // Check Prometheus credentials
 | 
				
			||||||
    app.use(
 | 
					    app.use(
 | 
				
			||||||
      fromNodeMiddleware((req, res, next) => {
 | 
					      fromNodeMiddleware((req, res, next) => {
 | 
				
			||||||
| 
						 | 
					@ -347,11 +343,10 @@ module.exports = class Server {
 | 
				
			||||||
          return next();
 | 
					          return next();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const user = basicAuth(req);
 | 
					        const user = basicAuth(req);
 | 
				
			||||||
        if (requiresPrometheusPassword && !user) {
 | 
					        if (!user) {
 | 
				
			||||||
          res.statusCode = 401;
 | 
					          res.statusCode = 401;
 | 
				
			||||||
          return { error: 'Not Logged In' };
 | 
					          return { error: 'Not Logged In' };
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (user.pass) {
 | 
					        if (user.pass) {
 | 
				
			||||||
          if (isPasswordValid(user.pass, PROMETHEUS_METRICS_PASSWORD)) {
 | 
					          if (isPasswordValid(user.pass, PROMETHEUS_METRICS_PASSWORD)) {
 | 
				
			||||||
            return next();
 | 
					            return next();
 | 
				
			||||||
| 
						 | 
					@ -364,6 +359,10 @@ module.exports = class Server {
 | 
				
			||||||
      }),
 | 
					      }),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Prometheus Metrics API
 | 
				
			||||||
 | 
					    const routerPrometheusMetrics = createRouter();
 | 
				
			||||||
 | 
					    app.use(routerPrometheusMetrics);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Prometheus Routes
 | 
					    // Prometheus Routes
 | 
				
			||||||
    routerPrometheusMetrics
 | 
					    routerPrometheusMetrics
 | 
				
			||||||
      .get('/metrics', defineEventHandler(async (event) => {
 | 
					      .get('/metrics', defineEventHandler(async (event) => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue