auth

Paddy 2014-09-01 Parent:043906283c65 Child:1f7b44b130a0

28:75cf37088852 Go to Latest

auth/profile.go

Rough out tokens and begin the memstore. Rough out the Token type for working with OAuth2 access and refresh tokens. Rough out the TokenStore interface that dictates how Tokens will be stored and retrieved. Write tests for the successful (in the working-as-intended sense) calls to TokenStore. Begin a Memstore type that stores data in memory. Implement the TokenStore interface for Memstore.

History
paddy@27 1 package auth
paddy@27 2
paddy@27 3 import (
paddy@27 4 "time"
paddy@27 5
paddy@27 6 "secondbit.org/uuid"
paddy@27 7 )
paddy@27 8
paddy@27 9 type Profile struct {
paddy@27 10 ID uuid.ID
paddy@27 11 Name string
paddy@27 12 Passphrase string
paddy@27 13 Email string
paddy@27 14 Created time.Time
paddy@27 15 LastSeen time.Time
paddy@27 16 }
paddy@27 17
paddy@27 18 type Login struct {
paddy@27 19 Type string
paddy@27 20 Value string
paddy@27 21 ProfileID uuid.ID
paddy@27 22 Created time.Time
paddy@27 23 LastUsed time.Time
paddy@27 24 }
paddy@27 25
paddy@27 26 type ProfileStore interface {
paddy@27 27 GetProfileByID(id uuid.ID) (Profile, error)
paddy@27 28 GetProfileByLogin(loginType, value, passphrase string) (Profile, error)
paddy@27 29 SaveProfile(user Profile) error
paddy@27 30 UpdateProfile(id uuid.ID, name, passphrase, email *string) error
paddy@27 31 DeleteProfile(id uuid.ID) error
paddy@27 32
paddy@27 33 SaveLogin(login Login) error
paddy@27 34 DeleteLogin(login Login) error
paddy@27 35 UpdateLogin(id uuid.ID, lastUsed time.Time) error
paddy@27 36 }