mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
06ceafd905
This simplifies the interface to just expose the methods from the underlying connection that we need. The addition of gen.go makes creating the generated mocks easy go generate.
29 lines
831 B
Go
29 lines
831 B
Go
package authentication
|
|
|
|
import (
|
|
"github.com/go-ldap/ldap/v3"
|
|
)
|
|
|
|
// LDAPConnectionFactory an interface of factory of ldap connections.
|
|
type LDAPConnectionFactory interface {
|
|
DialURL(addr string, opts ...ldap.DialOpt) (LDAPConnection, error)
|
|
}
|
|
|
|
// LDAPConnectionFactoryImpl the production implementation of an ldap connection factory.
|
|
type LDAPConnectionFactoryImpl struct{}
|
|
|
|
// NewLDAPConnectionFactoryImpl create a concrete ldap connection factory.
|
|
func NewLDAPConnectionFactoryImpl() *LDAPConnectionFactoryImpl {
|
|
return &LDAPConnectionFactoryImpl{}
|
|
}
|
|
|
|
// DialURL creates a connection from an LDAP URL when successful.
|
|
func (lcf *LDAPConnectionFactoryImpl) DialURL(addr string, opts ...ldap.DialOpt) (LDAPConnection, error) {
|
|
conn, err := ldap.DialURL(addr, opts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return conn, nil
|
|
}
|