From 78cc7412770d1288fa5225832a570dfa1e1b56b0 Mon Sep 17 00:00:00 2001 From: Travis Truman Date: Thu, 5 Nov 2015 09:20:01 -0500 Subject: [PATCH] Closes #100 by removing support for HTTP basic auth --- node_exporter.go | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/node_exporter.go b/node_exporter.go index ef500f7a..434dd3df 100644 --- a/node_exporter.go +++ b/node_exporter.go @@ -43,8 +43,6 @@ var ( metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.") enabledCollectors = flag.String("collectors.enabled", "diskstats,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,sockstat,stat,textfile,time,uname", "Comma-separated list of collectors to use.") printCollectors = flag.Bool("collectors.print", false, "If true, print available collectors and exit.") - authUser = flag.String("auth.user", "", "Username for basic auth.") - authPass = flag.String("auth.pass", "", "Password for basic auth.") collectorLabelNames = []string{"collector", "result"} @@ -83,23 +81,6 @@ func (n NodeCollector) Collect(ch chan<- prometheus.Metric) { scrapeDurations.Collect(ch) } -type basicAuthHandler struct { - handler http.HandlerFunc - user string - password string -} - -func (h *basicAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - user, password, ok := r.BasicAuth() - if !ok || password != h.password || user != h.user { - w.Header().Set("WWW-Authenticate", "Basic realm=\"metrics\"") - http.Error(w, "Invalid username or password", http.StatusUnauthorized) - return - } - h.handler(w, r) - return -} - func execute(name string, c collector.Collector, ch chan<- prometheus.Metric) { begin := time.Now() err := c.Update(ch) @@ -164,16 +145,6 @@ func main() { signal.Notify(sigUsr1, syscall.SIGUSR1) handler := prometheus.Handler() - if *authUser != "" || *authPass != "" { - if *authUser == "" || *authPass == "" { - log.Fatal("You need to specify -auth.user and -auth.pass to enable basic auth") - } - handler = &basicAuthHandler{ - handler: prometheus.Handler().ServeHTTP, - user: *authUser, - password: *authPass, - } - } http.Handle(*metricsPath, handler) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {