mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user