auth

Paddy 2014-11-11 Child:d43c3fbf00f3

70:8398c3e4b3d9 Go to Latest

auth/session.go

Actually define Sessions. That last commit (42bc3e44f4fe) didn't actually include Sessions. Oops. Add the file and include our Session definition and sessionStore.

History
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 }