Documentation
¶
Index ¶
- func SetDefaultEnvironment(env config.Environment)
- func StartSharedTTLCache(ctx context.Context)
- type LDAPConnection
- type LDAPConnectionImpl
- func (l *LDAPConnectionImpl) Bind(ctx context.Context, guid string, cfg config.File, logger *slog.Logger, ...) error
- func (l *LDAPConnectionImpl) Connect(guid string, cfg config.File, logger *slog.Logger, ldapConf *config.LDAPConf) error
- func (l *LDAPConnectionImpl) GetConn() *ldap.Conn
- func (l *LDAPConnectionImpl) GetMutex() *sync.Mutex
- func (l *LDAPConnectionImpl) GetState() definitions.LDAPState
- func (l *LDAPConnectionImpl) IsClosing() bool
- func (l *LDAPConnectionImpl) Modify(ctx context.Context, cfg config.File, logger *slog.Logger, ...) (err error)
- func (l *LDAPConnectionImpl) Search(ctx context.Context, cfg config.File, logger *slog.Logger, ...) (result bktype.AttributeMapping, rawResult []*ldap.Entry, err error)
- func (l *LDAPConnectionImpl) SetConn(conn *ldap.Conn)
- func (l *LDAPConnectionImpl) SetState(state definitions.LDAPState)
- func (l *LDAPConnectionImpl) Unbind() (err error)
- type LDAPPool
- type Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDefaultEnvironment ¶ added in v1.12.0
func SetDefaultEnvironment(env config.Environment)
SetDefaultEnvironment sets the process-wide default environment for `ldappool`.
func StartSharedTTLCache ¶ added in v1.11.1
StartSharedTTLCache initializes the LDAP-scoped shared TTL cache and binds the cleanup janitor to the provided context. Calling it multiple times is safe.
Types ¶
type LDAPConnection ¶
type LDAPConnection interface {
// SetState sets the current state of the LDAP connection to the specified LDAPState value.
SetState(state definitions.LDAPState)
// GetState returns the current state of the LDAP connection as a value of type definitions.LDAPState.
GetState() definitions.LDAPState
// SetConn sets the LDAP connection instance to be used for subsequent operations.
SetConn(*ldap.Conn)
// GetConn retrieves the current LDAP connection instance, allowing interaction with the LDAP server.
GetConn() *ldap.Conn
// GetMutex retrieves the mutex associated with the LDAP connection for synchronization purposes.
GetMutex() *sync.Mutex
// Connect establishes an LDAP connection using the provided GUID and configuration, returning an error if it fails.
Connect(guid string, cfg config.File, logger *slog.Logger, ldapConf *config.LDAPConf) error
// Bind attempts to authenticate and establish a bound state for the LDAP connection using the provided credentials.
Bind(ctx context.Context, guid string, cfg config.File, logger *slog.Logger, ldapConf *config.LDAPConf) error
// Unbind gracefully disconnects the LDAP connection by sending an unbind request to the server and returns any error encountered.
Unbind() error
// IsClosing checks whether the LDAP connection is in the process of closing and returns true if it is.
IsClosing() bool
// Search executes an LDAP search request based on the specified LDAPRequest and returns the results, raw entries, or an error.
Search(ctx context.Context, cfg config.File, logger *slog.Logger, ldapRequest *bktype.LDAPRequest) (bktype.AttributeMapping, []*ldap.Entry, error)
// Modify performs an LDAP modify operation based on the provided LDAP request and returns an error if the operation fails.
Modify(ctx context.Context, cfg config.File, logger *slog.Logger, ldapRequest *bktype.LDAPRequest) error
}
LDAPConnection defines behaviors for managing and interacting with an LDAP connection.
type LDAPConnectionImpl ¶
type LDAPConnectionImpl struct {
// contains filtered or unexported fields
}
LDAPConnectionImpl represents the connection with an LDAP server. It encapsulates the LDAP connection state and provides a means to synchronize access to it.
func (*LDAPConnectionImpl) Bind ¶
func (l *LDAPConnectionImpl) Bind(ctx context.Context, guid string, cfg config.File, logger *slog.Logger, ldapConf *config.LDAPConf) error
Bind establishes a connection to the LDAP server using either SASL External or simple bind based on the configuration provided.
func (*LDAPConnectionImpl) Connect ¶
func (l *LDAPConnectionImpl) Connect(guid string, cfg config.File, logger *slog.Logger, ldapConf *config.LDAPConf) error
Connect establishes a connection to the LDAP server using the provided configuration and GUID. It handles TLS setup, retries, connection timeouts, and supports failover across multiple server URIs. Returns an error if the connection could not be established or times out.
func (*LDAPConnectionImpl) GetConn ¶
func (l *LDAPConnectionImpl) GetConn() *ldap.Conn
GetConn retrieves the current LDAP connection instance managed by LDAPConnectionImpl.
func (*LDAPConnectionImpl) GetMutex ¶
func (l *LDAPConnectionImpl) GetMutex() *sync.Mutex
func (*LDAPConnectionImpl) GetState ¶
func (l *LDAPConnectionImpl) GetState() definitions.LDAPState
GetState returns the current state of the LDAP connection as a value of type definitions.LDAPState.
func (*LDAPConnectionImpl) IsClosing ¶
func (l *LDAPConnectionImpl) IsClosing() bool
IsClosing checks if the underlying LDAP connection is in the process of closing. Returns true if closing, false otherwise.
func (*LDAPConnectionImpl) Modify ¶ added in v1.5.5
func (l *LDAPConnectionImpl) Modify(ctx context.Context, cfg config.File, logger *slog.Logger, ldapRequest *bktype.LDAPRequest) (err error)
Modify applies changes to an LDAP entry based on the given LDAP request and returns an error if any operation fails.
func (*LDAPConnectionImpl) Search ¶
func (l *LDAPConnectionImpl) Search(ctx context.Context, cfg config.File, logger *slog.Logger, ldapRequest *bktype.LDAPRequest) (result bktype.AttributeMapping, rawResult []*ldap.Entry, err error)
Search performs an LDAP search based on the provided LDAPRequest and returns the corresponding results or an error.
func (*LDAPConnectionImpl) SetConn ¶
func (l *LDAPConnectionImpl) SetConn(conn *ldap.Conn)
SetConn sets the internal LDAP connection instance to the provided *ldap.Conn.
func (*LDAPConnectionImpl) SetState ¶
func (l *LDAPConnectionImpl) SetState(state definitions.LDAPState)
SetState updates the current state of the LDAPConnectionImpl to the provided LDAPState value.
func (*LDAPConnectionImpl) Unbind ¶
func (l *LDAPConnectionImpl) Unbind() (err error)
Unbind closes the LDAP connection and unbinds from the server.
type LDAPPool ¶
type LDAPPool interface {
// StartHouseKeeper starts a background process for resource management and cleanup within the LDAP pool.
StartHouseKeeper()
// GetNumberOfWorkers returns the total number of workers allocated to the LDAP pool.
GetNumberOfWorkers() int
// SetIdleConnections configures and manages idle connections in the pool based on the provided bind parameter.
SetIdleConnections(bind bool) error
// HandleLookupRequest handles an LDAP lookup request asynchronously.
HandleLookupRequest(ldapRequest *bktype.LDAPRequest) error
// HandleAuthRequest processes an LDAP authentication request.
HandleAuthRequest(ldapAuthRequest *bktype.LDAPAuthRequest) error
// Close releases all resources used by the LDAPPool and terminates any background processes or connections.
Close()
}
LDAPPool is an interface that represents a pool for managing LDAP connections and operations efficiently.