Skip to content

Commit

Permalink
cmd: require auth for debug endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Nov 16, 2023
1 parent 8e7f223 commit afc9e12
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/hostd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ func (wr webRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
req.URL.Path = strings.TrimPrefix(req.URL.Path, "/api") // strip the prefix
wr.api.ServeHTTP(w, req)
case strings.HasPrefix(req.URL.Path, "/debug/pprof"):
_, password, ok := req.BasicAuth()
if !ok || password != cfg.HTTP.Password {
w.WriteHeader(http.StatusUnauthorized)
return
}
http.DefaultServeMux.ServeHTTP(w, req)
default:
wr.ui.ServeHTTP(w, req)
Expand Down

0 comments on commit afc9e12

Please sign in to comment.