client

package
v0.0.0-...-46e61fc Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPortLDAP = 389
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IConnection

type IConnection interface {
	Start()
	Close()
	SetTimeout(timeout time.Duration)
	StartTLS(config *tls.Config) error
	Search(searchRequest *ldap.SearchRequest) (*ldap.SearchResult, error)
	Bind(username, password string) error
}

type ILdapClient

type ILdapClient interface {
	Connect() error
	Close()
	Authenticate(username, password string) (bool, map[string]string, error)
	GetUserGroups(userDN string) ([]string, error)
	IsAvailable() bool
}

func NewLdapClient

func NewLdapClient() ILdapClient

type LdapClient

type LdapClient struct {
	Host               string
	Port               int
	Base               string
	BindDN             string
	BindPassword       string
	ServerName         string
	InsecureSkipVerify bool
	UseSSL             bool
	SkipTLS            bool
	ClientCertificates []tls.Certificate
	Conn               IConnection
	UserFilter         string
}

func (*LdapClient) Authenticate

func (l *LdapClient) Authenticate(username, password string) (bool, map[string]string, error)

func (*LdapClient) Close

func (l *LdapClient) Close()

func (*LdapClient) Connect

func (l *LdapClient) Connect() error

func (*LdapClient) GetUserGroups

func (l *LdapClient) GetUserGroups(userDN string) ([]string, error)

func (*LdapClient) IsAvailable

func (l *LdapClient) IsAvailable() bool

type Mock

type Mock struct {
	mock.Mock
}

func (*Mock) Authenticate

func (m *Mock) Authenticate(_, _ string) (bool, map[string]string, error)

func (*Mock) Close

func (m *Mock) Close()

func (*Mock) Connect

func (m *Mock) Connect() error

func (*Mock) GetUserGroups

func (m *Mock) GetUserGroups(_ string) ([]string, error)

func (*Mock) IsAvailable

func (m *Mock) IsAvailable() bool

type MockConnection

type MockConnection struct {
	mock.Mock
}

func (*MockConnection) Bind

func (m *MockConnection) Bind(_, _ string) error

func (*MockConnection) Close

func (m *MockConnection) Close()

func (*MockConnection) Search

func (m *MockConnection) Search(_ *ldap.SearchRequest) (*ldap.SearchResult, error)

func (*MockConnection) SetTimeout

func (m *MockConnection) SetTimeout(_ time.Duration)

func (*MockConnection) Start

func (m *MockConnection) Start()

func (*MockConnection) StartTLS

func (m *MockConnection) StartTLS(_ *tls.Config) error

Jump to

Keyboard shortcuts

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