|
@@ -30,7 +30,6 @@ type IConnection interface {
|
|
|
type IServer interface {
|
|
type IServer interface {
|
|
|
Login(*models.LoginUserQuery) (*models.ExternalUserInfo, error)
|
|
Login(*models.LoginUserQuery) (*models.ExternalUserInfo, error)
|
|
|
Users([]string) ([]*models.ExternalUserInfo, error)
|
|
Users([]string) ([]*models.ExternalUserInfo, error)
|
|
|
- ExtractGrafanaUser(*UserInfo) (*models.ExternalUserInfo, error)
|
|
|
|
|
InitialBind(string, string) error
|
|
InitialBind(string, string) error
|
|
|
Dial() error
|
|
Dial() error
|
|
|
Close()
|
|
Close()
|
|
@@ -148,6 +147,11 @@ func (server *Server) Login(query *models.LoginUserQuery) (
|
|
|
|
|
|
|
|
// Check if a second user bind is needed
|
|
// Check if a second user bind is needed
|
|
|
user := users[0]
|
|
user := users[0]
|
|
|
|
|
+
|
|
|
|
|
+ if err := server.validateGrafanaUser(user); err != nil {
|
|
|
|
|
+ return nil, err
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if server.requireSecondBind {
|
|
if server.requireSecondBind {
|
|
|
err = server.secondBind(user, query.Password)
|
|
err = server.secondBind(user, query.Password)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -188,16 +192,6 @@ func (server *Server) Users(logins []string) (
|
|
|
return serializedUsers, nil
|
|
return serializedUsers, nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// ExtractGrafanaUser extracts external user info from LDAP user
|
|
|
|
|
-func (server *Server) ExtractGrafanaUser(user *UserInfo) (*models.ExternalUserInfo, error) {
|
|
|
|
|
- result := server.buildGrafanaUser(user)
|
|
|
|
|
- if err := server.validateGrafanaUser(result); err != nil {
|
|
|
|
|
- return nil, err
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return result, nil
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// validateGrafanaUser validates user access.
|
|
// validateGrafanaUser validates user access.
|
|
|
// If there are no ldap group mappings access is true
|
|
// If there are no ldap group mappings access is true
|
|
|
// otherwise a single group must match
|
|
// otherwise a single group must match
|