LDAP: Show non-matched groups returned from LDAP (#19208)

* LDAP: Show all LDAP groups

* Use the returned LDAP groups as the reference when debugging LDAP

We need to use the LDAP groups returned as the main reference for
assuming what we were able to match and what wasn't. Before, we were
using the configured groups in LDAP TOML configuration file.

* s/User name/Username

* Add a title to for the LDAP mapping results

* LDAP: UI Updates to debug view

* LDAP: Make it explicit when we weren't able to match teams
This commit is contained in:
gotjosh
2019-09-19 16:13:38 +01:00
committed by GitHub
parent 98c95a8a83
commit b20a258b72
10 changed files with 115 additions and 79 deletions

View File

@@ -408,12 +408,12 @@ func (server *Server) buildGrafanaUser(user *ldap.Entry) (*models.ExternalUserIn
for _, group := range server.Config.Groups {
// only use the first match for each org
if extUser.OrgRoles[group.OrgID] != "" {
if extUser.OrgRoles[group.OrgId] != "" {
continue
}
if isMemberOf(memberOf, group.GroupDN) {
extUser.OrgRoles[group.OrgID] = group.OrgRole
extUser.OrgRoles[group.OrgId] = group.OrgRole
if extUser.IsGrafanaAdmin == nil || !*extUser.IsGrafanaAdmin {
extUser.IsGrafanaAdmin = group.IsGrafanaAdmin
}

View File

@@ -3,11 +3,10 @@ package ldap
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
"gopkg.in/ldap.v3"
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/models"
. "github.com/smartystreets/goconvey/convey"
"gopkg.in/ldap.v3"
)
func TestLDAPPrivateMethods(t *testing.T) {
@@ -124,7 +123,7 @@ func TestLDAPPrivateMethods(t *testing.T) {
Config: &ServerConfig{
Groups: []*GroupToOrgRole{
{
OrgID: 1,
OrgId: 1,
},
},
},
@@ -162,7 +161,7 @@ func TestLDAPPrivateMethods(t *testing.T) {
Config: &ServerConfig{
Groups: []*GroupToOrgRole{
{
OrgID: 1,
OrgId: 1,
},
},
},

View File

@@ -55,7 +55,7 @@ type AttributeMap struct {
// config "group_mappings" setting
type GroupToOrgRole struct {
GroupDN string `toml:"group_dn"`
OrgID int64 `toml:"org_id"`
OrgId int64 `toml:"org_id"`
// This pointer specifies if setting was set (for backwards compatibility)
IsGrafanaAdmin *bool `toml:"grafana_admin"`
@@ -139,8 +139,8 @@ func readConfig(configFile string) (*Config, error) {
}
for _, groupMap := range server.Groups {
if groupMap.OrgID == 0 {
groupMap.OrgID = 1
if groupMap.OrgId == 0 {
groupMap.OrgId = 1
}
}
}