Disable metrics access if no token is set (#1470)

backport of #1469
This commit is contained in:
Anbraten 2022-12-23 18:13:00 +01:00 committed by GitHub
parent 7651c7311d
commit 414df473f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,7 @@ package metrics
import (
"errors"
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus/promhttp"
@ -35,7 +36,7 @@ func PromHandler() gin.HandlerFunc {
token := server.Config.Prometheus.AuthToken
if token == "" {
handler.ServeHTTP(c.Writer, c.Request)
c.AbortWithStatus(http.StatusNotFound)
return
}