1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2025-06-29 09:50:56 +02:00

LDAP authentification backend

This commit is contained in:
Alexandre Iooss
2020-09-22 12:54:12 +02:00
parent 5ac336393b
commit 07c8dc6ca1
5 changed files with 66 additions and 2 deletions

View File

@ -1,11 +1,33 @@
package auth
import (
"errors"
"gitlab.crans.org/nounous/ghostream/auth/ldap"
)
// Options holds web package configuration
// Options holds package configuration
type Options struct {
Backend string
LDAP ldap.Options
}
// Backend to log user in
type Backend interface {
Login(string, string) (bool, error)
}
// New initialize authentification backend
func New(cfg *Options) (Backend, error) {
var backend Backend
if cfg.Backend == "LDAP" {
backend = ldap.LDAP{Cfg: cfg.LDAP}
} else {
// Package is misconfigured
return nil, errors.New("Authentification backend not found")
}
// Init and return backend
return backend, nil
}