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 !*noauth {
|
||||||
if len(apitoken) == 0 {
|
apitoken := r.Header.Get("MG-X-API-TOKEN")
|
||||||
logger.Println("MG-X-API-TOKEN is missing")
|
if len(apitoken) == 0 {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
logger.Println("MG-X-API-TOKEN is missing")
|
||||||
return
|
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 := json.NewEncoder(w)
|
||||||
enc.Encode(convertedConfig)
|
enc.Encode(convertedConfig)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user