From 2a1f972de6f9f1a633f8f6762d0b321a0ffbc723 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sat, 18 Dec 2021 12:57:09 -0600 Subject: [PATCH] require basic auth for upload --- handler.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/handler.go b/handler.go index 3e83288..b0113d5 100644 --- a/handler.go +++ b/handler.go @@ -335,6 +335,12 @@ func (h handler) upload(modpath, modversion string, w http.ResponseWriter, r *ht return } + _, _, ok := r.BasicAuth() + if !ok { + writeError(w, apiError(http.StatusUnauthorized)) + return + } + dest := h.zipPath(modpath, modversion) if _, err := os.Stat(dest); !errors.Is(err, fs.ErrNotExist) { writeError(w, apiError(http.StatusConflict))