mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 16:30:55 +01:00
Token authorization scheme (#2288)
This commit is contained in:
parent
a8a4581c37
commit
43dfa421c3
@ -7,6 +7,7 @@ import (
|
|||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -72,6 +73,11 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
|||||||
http.Error(w, "missing `Authorization` request header", http.StatusUnauthorized)
|
http.Error(w, "missing `Authorization` request header", http.StatusUnauthorized)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
if strings.HasPrefix(authToken, "Token ") {
|
||||||
|
// Handle InfluxDB's proprietary token authentication scheme as a bearer token authentication
|
||||||
|
// See https://docs.influxdata.com/influxdb/v2.0/api/
|
||||||
|
authToken = strings.Replace(authToken, "Token", "Bearer", 1)
|
||||||
|
}
|
||||||
ac := authConfig.Load().(map[string]*UserInfo)
|
ac := authConfig.Load().(map[string]*UserInfo)
|
||||||
ui := ac[authToken]
|
ui := ac[authToken]
|
||||||
if ui == nil {
|
if ui == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user