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