multildap

package
v0.0.85-test Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCouldNotFindUser = ldap.ErrCouldNotFindUser

ErrCouldNotFindUser is returned when username hasn't been found (not username+password)

View Source
var ErrDidNotFindUser = errors.New("did not find a user")

ErrDidNotFindUser if request for user is unsuccessful

View Source
var ErrInvalidCredentials = ldap.ErrInvalidCredentials

ErrInvalidCredentials is returned if username and password do not match

View Source
var ErrNoLDAPServers = errors.New("no LDAP servers are configured")

ErrNoLDAPServers is returned when there is no LDAP servers specified

View Source
var GetConfig = ldap.GetConfig

GetConfig gets LDAP config

View Source
var IsEnabled = ldap.IsEnabled

IsEnabled checks if LDAP is enabled

Functions

This section is empty.

Types

type IMultiLDAP

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

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

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

IMultiLDAP is interface for MultiLDAP

func New

func New(configs []*ldap.ServerConfig) 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 *models.LoginUserQuery) (
	*models.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) (
	*models.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) (
	[]*models.ExternalUserInfo,
	error,
)

Users gets users from multiple LDAP servers

type MultiLDAPmock

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

func (*MultiLDAPmock) Login

func (*MultiLDAPmock) User

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