|
@@ -27,7 +27,7 @@ func init() {
|
|
|
SearchFilter: "(cn=%s)",
|
|
SearchFilter: "(cn=%s)",
|
|
|
SearchBaseDNs: []string{"dc=grafana,dc=org"},
|
|
SearchBaseDNs: []string{"dc=grafana,dc=org"},
|
|
|
LdapGroups: []*LdapGroupToOrgRole{
|
|
LdapGroups: []*LdapGroupToOrgRole{
|
|
|
- {GroupDN: "cn=users,dc=grafana,dc=org", OrgName: "Main Org.", OrgRole: "Editor"},
|
|
|
|
|
|
|
+ {GroupDN: "cn=users,dc=grafana,dc=org", OrgRole: "Editor"},
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
}
|
|
}
|
|
@@ -77,6 +77,10 @@ func (a *ldapAuther) login(query *AuthenticateUserQuery) error {
|
|
|
if grafanaUser, err := a.getGrafanaUserFor(ldapUser); err != nil {
|
|
if grafanaUser, err := a.getGrafanaUserFor(ldapUser); err != nil {
|
|
|
return err
|
|
return err
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ // sync org roles
|
|
|
|
|
+ if err := a.syncOrgRoles(grafanaUser, ldapUser); err != nil {
|
|
|
|
|
+ return err
|
|
|
|
|
+ }
|
|
|
query.User = grafanaUser
|
|
query.User = grafanaUser
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
@@ -111,7 +115,6 @@ func (a *ldapAuther) getGrafanaUserFor(ldapUser *ldapUserInfo) (*m.User, error)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (a *ldapAuther) createGrafanaUser(ldapUser *ldapUserInfo) (*m.User, error) {
|
|
func (a *ldapAuther) createGrafanaUser(ldapUser *ldapUserInfo) (*m.User, error) {
|
|
|
-
|
|
|
|
|
cmd := m.CreateUserCommand{
|
|
cmd := m.CreateUserCommand{
|
|
|
Login: ldapUser.Username,
|
|
Login: ldapUser.Username,
|
|
|
Email: ldapUser.Email,
|
|
Email: ldapUser.Email,
|
|
@@ -125,6 +128,10 @@ func (a *ldapAuther) createGrafanaUser(ldapUser *ldapUserInfo) (*m.User, error)
|
|
|
return &cmd.Result, nil
|
|
return &cmd.Result, nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (a *ldapAuther) syncOrgRoles(user *m.User, ldapUser *ldapUserInfo) error {
|
|
|
|
|
+ return nil
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func (a *ldapAuther) initialBind(username, userPassword string) error {
|
|
func (a *ldapAuther) initialBind(username, userPassword string) error {
|
|
|
if a.server.BindPassword != "" {
|
|
if a.server.BindPassword != "" {
|
|
|
userPassword = a.server.BindPassword
|
|
userPassword = a.server.BindPassword
|