aboutsummaryrefslogtreecommitdiff
path: root/internal/app/metrics.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/app/metrics.go')
-rw-r--r--internal/app/metrics.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/internal/app/metrics.go b/internal/app/metrics.go
index 80ff32f6..45a9b74e 100644
--- a/internal/app/metrics.go
+++ b/internal/app/metrics.go
@@ -9,14 +9,14 @@ import (
"gopkg.in/macaron.v1"
+ "gogs.io/gogs/internal/authutil"
"gogs.io/gogs/internal/conf"
- "gogs.io/gogs/internal/context"
)
func MetricsFilter() macaron.Handler {
- return func(c *context.Context) {
+ return func(w http.ResponseWriter, r *http.Request) {
if !conf.Prometheus.Enabled {
- c.Status(http.StatusNotFound)
+ w.WriteHeader(http.StatusNotFound)
return
}
@@ -24,6 +24,10 @@ func MetricsFilter() macaron.Handler {
return
}
- c.RequireBasicAuth(conf.Prometheus.BasicAuthUsername, conf.Prometheus.BasicAuthPassword)
+ username, password := authutil.DecodeBasic(r.Header)
+ if username != conf.Prometheus.BasicAuthUsername || password != conf.Prometheus.BasicAuthPassword {
+ w.WriteHeader(http.StatusForbidden)
+ return
+ }
}
}