Basic LDAP search works

This commit is contained in:
2023-10-25 00:50:24 +02:00
parent 7bcd00c97b
commit b934270d14
3 changed files with 175 additions and 27 deletions

View File

@@ -1,12 +1,25 @@
package backend
import "time"
import (
"errors"
"go.uber.org/zap"
"time"
)
type UserType string
var (
UtPerson UserType = "person"
UtHost UserType = "host"
UtService UserType = "service"
)
// Session holds info about the logged-in user that won't change
type Session struct {
SessionID string
Expiration time.Time
UserID string
UserType UserType
LdapDN string
}
@@ -15,6 +28,8 @@ type SessionCache struct {
Valid bool
Groups []string
DisplayName string
GivenName string
SurName string
Email string
}
@@ -26,3 +41,34 @@ type Backend interface {
DoMaintenance()
Ping() error
}
type NullBackend struct{}
func (n *NullBackend) PutSession(session Session, cache SessionCache) error {
//TODO implement me
zap.L().Info("Put session", zap.Any("session", session), zap.Any("cache", cache))
return nil
}
func (n *NullBackend) GetSession(id string) (Session, *SessionCache, error) {
//TODO implement me
return Session{}, nil, errors.New("no such session")
}
func (n *NullBackend) EndSession(id string) {
//TODO implement me
}
func (n *NullBackend) NewSessionID() (string, error) {
//TODO implement me
return "foo", nil
}
func (n *NullBackend) DoMaintenance() {
//TODO implement me
}
func (n *NullBackend) Ping() error {
//TODO implement me
return nil
}