auth

Paddy 2014-08-01 Parent:7a6f64db7246 Child:3423c552e249

1:7b9e0fc20256 Go to Latest

auth/storage.go

Continue our descent to horribleness. Remove all the nonsense about "extensibility" and "clean separation of concerns", instead hardcoding connections to decisions. Remove all those "test" things that stopped passing.

History
     1.1 --- a/storage.go	Fri Jul 18 07:13:22 2014 -0400
     1.2 +++ b/storage.go	Fri Aug 01 23:08:38 2014 -0400
     1.3 @@ -1,39 +1,28 @@
     1.4  package oauth2
     1.5  
     1.6 -// Storage interface
     1.7 -type Storage interface {
     1.8 +import "secondbit.org/uuid"
     1.9  
    1.10 -	// GetClient loads the client by id (client_id)
    1.11 -	GetClient(id string) (*Client, error)
    1.12 +type ClientStore interface {
    1.13 +	GetClient(id uuid.ID) (Client, error)
    1.14 +	CreateClient(name, logo, redirectURI string, owner uuid.ID) (Client, error)
    1.15 +	UpdateClient(client *Client, name, logo, redirectURI *string) error
    1.16 +	RemoveClient(id uuid.ID, ctx Context) error
    1.17 +	ListClients(id uuid.ID, page, num int, ctx Context) ([]Client, error)
    1.18 +}
    1.19  
    1.20 -	// SaveAuthorize saves authorize data.
    1.21 -	SaveAuthorize(*AuthorizeData) error
    1.22 +type TokenStore interface {
    1.23 +	SaveAuthorization(AuthorizeData) error
    1.24 +	GetAuthorization(code string) (AuthorizeData, error)
    1.25 +	RemoveAuthorization(code string) error
    1.26  
    1.27 -	// LoadAuthorize looks up AuthorizeData by a code.
    1.28 -	// Client information MUST be loaded together.
    1.29 -	// Optionally can return error if expired.
    1.30 -	LoadAuthorize(code string) (*AuthorizeData, error)
    1.31 -
    1.32 -	// RemoveAuthorize revokes or deletes the authorization code.
    1.33 -	RemoveAuthorize(code string) error
    1.34 -
    1.35 -	// SaveAccess writes AccessData.
    1.36 -	// If RefreshToken is not blank, it must save in a way that can be loaded using LoadRefresh.
    1.37 -	SaveAccess(*AccessData) error
    1.38 -
    1.39 -	// LoadAccess retrieves access data by token. Client information MUST be loaded together.
    1.40 -	// AuthorizeData and AccessData DON'T NEED to be loaded if not easily available.
    1.41 -	// Optionally can return error if expired.
    1.42 -	LoadAccess(token string) (*AccessData, error)
    1.43 -
    1.44 -	// RemoveAccess revokes or deletes an AccessData.
    1.45 +	SaveAccess(AccessData) error
    1.46 +	GetAccess(token string) (AccessData, error)
    1.47  	RemoveAccess(token string) error
    1.48  
    1.49 -	// LoadRefresh retrieves refresh AccessData. Client information MUST be loaded together.
    1.50 -	// AuthorizeData and AccessData DON'T NEED to be loaded if not easily available.
    1.51 -	// Optionally can return error if expired.
    1.52 -	LoadRefresh(token string) (*AccessData, error)
    1.53 -
    1.54 -	// RemoveRefresh revokes or deletes refresh AccessData.
    1.55 +	GetRefresh(token string) (AccessData, error)
    1.56  	RemoveRefresh(token string) error
    1.57  }
    1.58 +
    1.59 +type ProfileStore interface {
    1.60 +	GetProfile(username, password string) (uuid.ID, error)
    1.61 +}