auth
auth/session.go
I'm on a typo roll. ErrInvalidSession, not ErrInvalidSessior. Also, we want comparison, not assignment.
1 package auth
3 import (
4 "errors"
5 "time"
7 "code.secondbit.org/uuid"
8 )
10 var (
11 // ErrNoSessionStore is returned when a Context tries to act on a sessionStore without setting on first.
12 ErrNoSessionStore = errors.New("no sessionStore was specified for the Context")
13 // ErrSessionNotFound is returned when a Session is requested but not found in the sessionStore.
14 ErrSessionNotFound = errors.New("session not found in sessionStore")
15 // ErrInvalidSession is returned when a Session is specified but is not valid.
16 ErrInvalidSession = errors.New("session is not valid")
17 )
19 // Session represents a user's authenticated session, associating it with a profile
20 // and some audit data.
21 type Session struct {
22 ID string
23 IP string
24 UserAgent string
25 ProfileID uuid.ID
26 Created time.Time
27 Login string
28 Active bool
29 }
31 type sessionStore interface {
32 createSession(session Session) error
33 getSession(id string) (Session, error)
34 removeSession(id string) error
35 listSessions(profile uuid.ID, before time.Time, num int64) ([]Session, error)
36 }