support passing api token in Basic auth password (#12416)

This commit is contained in:
Dan Cech
2018-06-28 12:08:32 +02:00
committed by Torkel Ödegaard
parent c2381f088f
commit 3056d9a80e
3 changed files with 38 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import (
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/session"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
)
type AuthOptions struct {
@ -34,6 +35,11 @@ func getApiKey(c *m.ReqContext) string {
return key
}
username, password, err := util.DecodeBasicAuthHeader(header)
if err == nil && username == "api_key" {
return password
}
return ""
}