auth

Paddy 2014-11-11 Parent:8398c3e4b3d9 Child:d43c3fbf00f3

73:4ae226929e92 Go to Latest

auth/session.go

Rename http.go. We're going to have a lot of HTTP handlers, and I'd rather make it clear that this is taking care of our OAuth2 HTTP logic. So rename the file, and we'll put the API handlers in their files, or something.

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 }