mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TeamSync: Fix team syncing out of orgs mapped by auth method (#53257)
This commit is contained in:
parent
bca8a5d153
commit
09c95bc31f
@ -331,6 +331,7 @@ func (hs *HTTPServer) GetUserFromLDAP(c *models.ReqContext) response.Response {
|
||||
unmappedUserGroups[strings.ToLower(userGroup)] = struct{}{}
|
||||
}
|
||||
|
||||
orgIDs := []int64{} // IDs of the orgs the user is a member of
|
||||
orgRolesMap := map[int64]models.RoleType{}
|
||||
for _, group := range serverConfig.Groups {
|
||||
// only use the first match for each org
|
||||
@ -343,6 +344,7 @@ func (hs *HTTPServer) GetUserFromLDAP(c *models.ReqContext) response.Response {
|
||||
u.OrgRoles = append(u.OrgRoles, LDAPRoleDTO{GroupDN: group.GroupDN,
|
||||
OrgId: group.OrgId, OrgRole: group.OrgRole})
|
||||
delete(unmappedUserGroups, strings.ToLower(group.GroupDN))
|
||||
orgIDs = append(orgIDs, group.OrgId)
|
||||
}
|
||||
}
|
||||
|
||||
@ -355,7 +357,7 @@ func (hs *HTTPServer) GetUserFromLDAP(c *models.ReqContext) response.Response {
|
||||
return response.Error(http.StatusBadRequest, "An organization was not found - Please verify your LDAP configuration", err)
|
||||
}
|
||||
|
||||
u.Teams, err = hs.ldapGroups.GetTeams(user.Groups)
|
||||
u.Teams, err = hs.ldapGroups.GetTeams(user.Groups, orgIDs)
|
||||
if err != nil {
|
||||
return response.Error(http.StatusBadRequest, "Unable to find the teams for this user", err)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package ldap
|
||||
import "github.com/grafana/grafana/pkg/models"
|
||||
|
||||
type Groups interface {
|
||||
GetTeams(groups []string) ([]models.TeamOrgGroupDTO, error)
|
||||
GetTeams(groups []string, orgIDs []int64) ([]models.TeamOrgGroupDTO, error)
|
||||
}
|
||||
|
||||
type OSSGroups struct{}
|
||||
@ -12,6 +12,6 @@ func ProvideGroupsService() *OSSGroups {
|
||||
return &OSSGroups{}
|
||||
}
|
||||
|
||||
func (*OSSGroups) GetTeams(_ []string) ([]models.TeamOrgGroupDTO, error) {
|
||||
func (*OSSGroups) GetTeams(_ []string, _ []int64) ([]models.TeamOrgGroupDTO, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user