Exemple #1
0
func (s *settingsManager) validateAuth(w http.ResponseWriter, r *http.Request) bool {
	valid, err := common.IsAuthValid(r, s.config["indexer.clusterAddr"].String())
	if err != nil {
		s.writeError(w, err)
	} else if valid == false {
		w.WriteHeader(401)
		w.Write([]byte("401 Unauthorized\n"))
	}
	return valid
}
Exemple #2
0
func doAuth(r *http.Request, w http.ResponseWriter, clusterUrl string) bool {

	valid, err := common.IsAuthValid(r, clusterUrl)
	if err != nil {
		sendIndexResponseWithError(w, err.Error())
		return false
	} else if valid == false {
		w.WriteHeader(401)
		w.Write([]byte("401 Unauthorized\n"))
		return false
	}

	return true
}
Exemple #3
0
func (s *statsManager) handleStatsResetReq(w http.ResponseWriter, r *http.Request) {
	conf := s.config.Load()
	valid, _ := common.IsAuthValid(r, conf["clusterAddr"].String())
	if !valid {
		w.WriteHeader(401)
		w.Write([]byte("401 Unauthorized"))
		return
	}

	if r.Method == "POST" || r.Method == "GET" {
		s.supvMsgch <- &MsgResetStats{}
		w.WriteHeader(200)
		w.Write([]byte("OK"))
	} else {
		w.WriteHeader(400)
		w.Write([]byte("Unsupported method"))
	}
}