package backend 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 } // SessionCache holds volatile information about the logged-in user type SessionCache struct { Valid bool Groups []string DisplayName string GivenName string SurName string Email string } type Backend interface { PutSession(session Session, cache SessionCache) error GetSession(id string) (Session, *SessionCache, error) EndSession(id string) NewSessionID() (string, error) 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 }