auth

Paddy 2014-08-16 Parent:fc5df8e68c7b

19:9fe684b33b3d Go to Latest

auth/storage.go

Implement session management and move login. Add a session store interface to validate and retrieve data about sessions. Implement session management in endpoints that need session support. Move the login functionality from inlined into the OAuth flow into its own handler, that the OAuth flow will redirect to. The login functionality should take a redirect URL parameter to return to the OAuth flow when login is completed.

History
1 package auth
3 import "secondbit.org/uuid"
5 type ClientStore interface {
6 GetClient(id uuid.ID) (Client, error)
7 CreateClient(name, logo, redirectURI string, owner uuid.ID) (Client, error)
8 UpdateClient(client uuid.ID, name, logo, redirectURI *string) error
9 RemoveClient(id uuid.ID) error
10 ListClients(id uuid.ID, page, num int) ([]Client, error)
11 }
13 type TokenStore interface {
14 SaveAuthorization(AuthorizeData) error
15 GetAuthorization(code string) (AuthorizeData, error)
16 RemoveAuthorization(code string) error
18 SaveAccess(AccessData) error
19 GetAccess(token string) (AccessData, error)
20 RemoveAccess(token string) error
22 GetRefresh(token string) (AccessData, error)
23 RemoveRefresh(token string) error
24 }
26 type ProfileStore interface {
27 GetProfile(username, password string) (uuid.ID, error)
28 }
30 type SessionStore interface {
31 GetSession(token string) (Session, error)
32 GetAllSessions(username string) ([]Session, error)
33 SetSession(Session) error
34 ExpireSession(token string) error
35 }