mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-30 12:20:33 +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
|
> Default: empty
|
||||||
|
|
||||||
Token to secure the Prometheus metrics endpoint.
|
Token to secure the Prometheus metrics endpoint.
|
||||||
|
Must be set to enable the endpoint.
|
||||||
|
|
||||||
### `WOODPECKER_PROMETHEUS_AUTH_TOKEN_FILE`
|
### `WOODPECKER_PROMETHEUS_AUTH_TOKEN_FILE`
|
||||||
> Default: empty
|
> Default: empty
|
||||||
|
|
|
@ -17,6 +17,7 @@ package metrics
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
|
@ -35,7 +36,7 @@ func PromHandler() gin.HandlerFunc {
|
||||||
token := server.Config.Prometheus.AuthToken
|
token := server.Config.Prometheus.AuthToken
|
||||||
|
|
||||||
if token == "" {
|
if token == "" {
|
||||||
handler.ServeHTTP(c.Writer, c.Request)
|
c.AbortWithStatus(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue