From 69657fbff32220c1a3d20bcd5df325e77ae43bbd Mon Sep 17 00:00:00 2001 From: mountain Date: Thu, 22 Jun 2023 11:56:13 +0900 Subject: [PATCH] =?UTF-8?q?noauth=20=EC=B2=98=EB=A6=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/maingate.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/core/maingate.go b/core/maingate.go index d6920bc..b759347 100644 --- a/core/maingate.go +++ b/core/maingate.go @@ -505,17 +505,20 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu } }() - apitoken := r.Header.Get("MG-X-API-TOKEN") - if len(apitoken) == 0 { - logger.Println("MG-X-API-TOKEN is missing") - w.WriteHeader(http.StatusBadRequest) - return + if !*noauth { + apitoken := r.Header.Get("MG-X-API-TOKEN") + if len(apitoken) == 0 { + logger.Println("MG-X-API-TOKEN is missing") + w.WriteHeader(http.StatusBadRequest) + return + } + + apitokenObj, _ := primitive.ObjectIDFromHex(apitoken) + if mg.service().isValidToken(apitokenObj) { + convertedConfig["divisions"] = mg.service().Divisions + } } - apitokenObj, _ := primitive.ObjectIDFromHex(apitoken) - if mg.service().isValidToken(apitokenObj) { - convertedConfig["divisions"] = mg.service().Divisions - } enc := json.NewEncoder(w) enc.Encode(convertedConfig) })