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:
24
auth/auth.go
24
auth/auth.go
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user