noauth 처리 추가
This commit is contained in:
@ -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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user