1
0
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:
Alexandre Iooss
2020-09-22 14:16:52 +02:00
parent 07c8dc6ca1
commit c1de814a2a
3 changed files with 30 additions and 11 deletions

View File

@ -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")