support additional fields in authproxy (#11661)

This commit is contained in:
Dan Cech
2018-05-07 10:39:16 +02:00
committed by Torkel Ödegaard
parent b4ad044044
commit 543c7fe587
3 changed files with 24 additions and 0 deletions
+11
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"net"
"net/mail"
"reflect"
"strings"
"time"
@@ -111,6 +112,16 @@ func initContextWithAuthProxy(ctx *m.ReqContext, orgID int64) bool {
return true
}
for _, field := range []string{"Name", "Email", "Login"} {
if setting.AuthProxyHeaders[field] == "" {
continue
}
if val := ctx.Req.Header.Get(setting.AuthProxyHeaders[field]); val != "" {
reflect.ValueOf(extUser).Elem().FieldByName(field).SetString(val)
}
}
// add/update user in grafana
cmd := &m.UpsertUserCommand{
ReqContext: ctx,