From 43dfa421c33c608e4beeaf8a5ae804ebc7cbe5e2 Mon Sep 17 00:00:00 2001 From: Diego Circelli Date: Sat, 19 Mar 2022 05:31:58 +1300 Subject: [PATCH] Token authorization scheme (#2288) --- app/vmauth/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/vmauth/main.go b/app/vmauth/main.go index 88c75c97b3..06af2528cc 100644 --- a/app/vmauth/main.go +++ b/app/vmauth/main.go @@ -7,6 +7,7 @@ import ( "net/http/httputil" "net/url" "os" + "strings" "sync" "time" @@ -72,6 +73,11 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { http.Error(w, "missing `Authorization` request header", http.StatusUnauthorized) 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) ui := ac[authToken] if ui == nil {