mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-06-10 12:23:45 +03:00
docs: update docs for *authKey, add authKey to HTTP 401 resp body (#7971)
### Describe Your Changes
optimize for
https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6226
for user who set `*AuthKey` flag, they will receive new response in
body:
```go
// query arg not set
The provided authKey '' doesn't match -search.resetCacheAuthKey
// incorrect query arg
The provided authKey '5dxd71hsz==' doesn't match -search.resetCacheAuthKey
```
previously, they receive:
```
The provided authKey doesn't match -search.resetCacheAuthKey
```
### Checklist
The following checks are **mandatory**:
- [x] My change adheres [VictoriaMetrics contributing
guidelines](https://docs.victoriametrics.com/contributing/).
(cherry picked from commit 1f0b03aebe)
Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
@@ -439,6 +439,11 @@ func CheckAuthFlag(w http.ResponseWriter, r *http.Request, expectedKey *flagutil
|
||||
if expectedValue == "" {
|
||||
return CheckBasicAuth(w, r)
|
||||
}
|
||||
if len(r.FormValue("authKey")) == 0 {
|
||||
authKeyRequestErrors.Inc()
|
||||
http.Error(w, fmt.Sprintf("Expected to receive non-empty authKey when -%s is set", expectedKey.Name()), http.StatusUnauthorized)
|
||||
return false
|
||||
}
|
||||
if r.FormValue("authKey") != expectedValue {
|
||||
authKeyRequestErrors.Inc()
|
||||
http.Error(w, fmt.Sprintf("The provided authKey doesn't match -%s", expectedKey.Name()), http.StatusUnauthorized)
|
||||
|
||||
Reference in New Issue
Block a user