mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-21 07:56:31 +00:00
disable metrics access if no token is set (#1469)
This commit is contained in:
parent
cfb288201f
commit
a3f4f3056c
2 changed files with 3 additions and 1 deletions
|
@ -294,6 +294,7 @@ Read the value for `WOODPECKER_DATABASE_DATASOURCE` from the specified filepath
|
|||
> Default: empty
|
||||
|
||||
Token to secure the Prometheus metrics endpoint.
|
||||
Must be set to enable the endpoint.
|
||||
|
||||
### `WOODPECKER_PROMETHEUS_AUTH_TOKEN_FILE`
|
||||
> Default: empty
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue