mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
lib/auth: add NewTokenPossibleMultitenant() for parsing auth token, which can be multitenant
Disallow parsing multitenant token at auth.NewToken().
Use auth.NewTokenPossibleMultitenant() at vminsert only. All the other callers should call auth.NewToken(),
since they do not support multitenant token.
This is a follow-up for f0c06b428e
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4910
This commit is contained in:
parent
f78d8b994d
commit
7db72dd7e6
2 changed files with 1 additions and 7 deletions
|
@ -208,7 +208,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||
// This is not our link.
|
||||
return false
|
||||
}
|
||||
at, err := auth.NewToken(p.AuthToken)
|
||||
at, err := auth.NewTokenPossibleMultitenant(p.AuthToken)
|
||||
if err != nil {
|
||||
httpserver.Errorf(w, r, "auth error: %s", err)
|
||||
return true
|
||||
|
|
|
@ -292,12 +292,6 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||
httpserver.Errorf(w, r, "auth error: %s", err)
|
||||
return true
|
||||
}
|
||||
if at == nil {
|
||||
// the only option for at to be nil is when p.AuthToken == "multitenant"
|
||||
// vmselect does not have multitenant endpoint, so request must be rejected
|
||||
httpserver.Errorf(w, r, "auth error: tenantID must be specified explicitly in the request path")
|
||||
return true
|
||||
}
|
||||
switch p.Prefix {
|
||||
case "select":
|
||||
return selectHandler(qt, startTime, w, r, p, at)
|
||||
|
|
Loading…
Reference in a new issue