multildap

package
v0.0.0-testrgm3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidCredentials is returned if username and password do not match
	ErrInvalidCredentials = ldap.ErrInvalidCredentials
	// ErrCouldNotFindUser is returned when username hasn't been found (not username+password)
	ErrCouldNotFindUser = ldap.ErrCouldNotFindUser
	// ErrNoLDAPServers is returned when there is no LDAP servers specified
	ErrNoLDAPServers = errors.New("no LDAP servers are configured")
	// ErrDidNotFindUser if request for user is unsuccessful
	ErrDidNotFindUser = errors.New("did not find a user")
)
View Source
var GetConfig = ldap.GetConfig

GetConfig gets LDAP config

Functions

This section is empty.

Types

type IMultiLDAP

type IMultiLDAP interface {
	Ping() ([]*ServerStatus, error)
	Login(query *login.LoginUserQuery) (
		*login.ExternalUserInfo, error,
	)

	Users(logins []string) (
		[]*login.ExternalUserInfo, error,
	)

	User(login string) (
		*login.ExternalUserInfo, ldap.ServerConfig, error,
	)
}

IMultiLDAP is interface for MultiLDAP

func New

func New(configs []*ldap.ServerConfig, cfg *setting.Cfg) IMultiLDAP

New creates the new LDAP auth

type MultiLDAP

type MultiLDAP struct {
	// contains filtered or unexported fields
}

MultiLDAP is basic struct of LDAP authorization

func (*MultiLDAP) Login

func (multiples *MultiLDAP) Login(query *login.LoginUserQuery) (
	*login.ExternalUserInfo, error,
)

Login tries to log in the user in multiples LDAP

func (*MultiLDAP) Ping

func (multiples *MultiLDAP) Ping() ([]*ServerStatus, error)

Ping dials each of the LDAP servers and returns their status. If the server is unavailable, it also returns the error.

func (*MultiLDAP) User

func (multiples *MultiLDAP) User(login string) (
	*login.ExternalUserInfo,
	ldap.ServerConfig,
	error,
)

User attempts to find an user by login/username by searching into all of the configured LDAP servers. Then, if the user is found it returns the user alongisde the server it was found.

func (*MultiLDAP) Users

func (multiples *MultiLDAP) Users(logins []string) (
	[]*login.ExternalUserInfo,
	error,
)

Users gets users from multiple LDAP servers

type MultiLDAPmock

type MultiLDAPmock struct {
	MultiLDAP
	ID          int64
	UserCalled  bool
	LoginCalled bool
	UserInfo    *user.User
	AuthModule  string
	ExpectedErr error
}

func (*MultiLDAPmock) Login

func (*MultiLDAPmock) User

func (m *MultiLDAPmock) User(loginstr string) (
	*login.ExternalUserInfo,
	ldap.ServerConfig,
	error,
)

type ServerStatus

type ServerStatus struct {
	Host      string
	Port      int
	Available bool
	Error     error
}

ServerStatus holds the LDAP server status

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL