introduce flags to take basic auth credentials

Signed-off-by: Syed Nihal <syed.nihal@nokia.com>
This commit is contained in:
Syed Nihal 2024-06-13 15:42:25 +05:30
parent 1733070b37
commit f0839dc227

View file

@ -443,13 +443,6 @@ func CheckAuthFlag(w http.ResponseWriter, r *http.Request, flagValue string, fla
return CheckBasicAuth(w, r)
}
if r.FormValue("authKey") != flagValue {
// Check and allow the request if the header 'X-AuthKey' matches the flagValue
// Currently, this is only applicable for snapshotAuthKey. Below condition can be modified to remove
// the check for flagName if 'X-AuthKey' header is to be allowed for other authKeys related flags (for instance reloadAuthKey)
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5973
if flagName == "snapshotAuthKey" && r.Header.Get("X-AuthKey") == flagValue {
return true
}
authKeyRequestErrors.Inc()
http.Error(w, fmt.Sprintf("The provided authKey doesn't match -%s", flagName), http.StatusUnauthorized)
return false