noauth 처리 추가
This commit is contained in:
@ -458,7 +458,7 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
|
||||
Priority: 0,
|
||||
State: DivisionState_FullOpen,
|
||||
},
|
||||
Url: fmt.Sprintf("http://%s/warehouse", host),
|
||||
Url: fmt.Sprintf("http://%s.actionsquare.corp/warehouse", host),
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -576,18 +576,20 @@ func (mg *Maingate) query(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
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 !*flag.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) {
|
||||
logger.Println("MG-X-API-TOKEN is invalid :", apitoken)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
apitokenObj, _ := primitive.ObjectIDFromHex(apitoken)
|
||||
if !mg.service().isValidToken(apitokenObj) {
|
||||
logger.Println("MG-X-API-TOKEN is invalid :", apitoken)
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
bt, _ := json.Marshal(info)
|
||||
|
||||
Reference in New Issue
Block a user