mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2025-06-29 09:50:56 +02:00
Use NewLDAP to instanciate LDAP backend
This commit is contained in:
@ -15,14 +15,19 @@ type Options struct {
|
||||
// Backend to log user in
|
||||
type Backend interface {
|
||||
Login(string, string) (bool, error)
|
||||
Close()
|
||||
}
|
||||
|
||||
// New initialize authentification backend
|
||||
func New(cfg *Options) (Backend, error) {
|
||||
var backend Backend
|
||||
var err error
|
||||
|
||||
if cfg.Backend == "LDAP" {
|
||||
backend = ldap.LDAP{Cfg: cfg.LDAP}
|
||||
backend, err = ldap.NewLDAP(&cfg.LDAP)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
// Package is misconfigured
|
||||
return nil, errors.New("Authentification backend not found")
|
||||
|
Reference in New Issue
Block a user