shaj13 / go-guardian

Go-Guardian is a golang library that provides a simple, clean, and idiomatic way to create powerful modern API and web authentication.
MIT License
543 stars 55 forks source link

Doesn't work with LDAP version >3.4.4 #130

Open iliesh opened 3 months ago

iliesh commented 3 months ago

What version of Go are you using (go version)?

$ go version
go version go1.22.4 linux/amd64

Does this issue reproduce with the latest release?

yes

What version of Go-Guardian are you using ?

Go-Guardian Version: 
github.com/shaj13/go-guardian/v2 v2.11.5

What did you do?

var strategy auth.Strategy
var cacheObj libcache.Cache

func InitLDAPConnection(cfg *config.Config) {
    ldapConfig := &ldap.Config{
        BaseDN:       cfg.LDAPBaseDN,
        BindDN:       "uid=" + cfg.LDAPBindUser + "," + cfg.LDAPBaseDN,
        Port:         cfg.LDAPPort,
        Host:         cfg.LDAPHost,
        BindPassword: cfg.LDAPBindPassord,
        Filter:       "(uid=%s)",
    }
    cacheObj = libcache.FIFO.New(0)
    cacheObj.SetTTL(time.Minute * 10)
    strategy = ldap.NewCached(ldapConfig, cacheObj)
}

What did you see instead?

# github.com/shaj13/go-guardian/v2/auth/strategies/ldap
/home/user/go/pkg/mod/github.com/shaj13/go-guardian/v2@v2.11.5/auth/strategies/ldap/ldap.go:71:9: cannot use ldap.DialURL(cfg.URL, opts...) (value of type *"github.com/go-ldap/ldap/v3".Conn) as conn value in return statement: *"github.com/go-ldap/ldap/v3".Conn does not implement conn (wrong type for method Close)
                have Close() (error)
                want Close()

Works ok with LDAP version 3.4.4:

github.com/go-ldap/ldap/v3 v3.4.4