auth

Paddy 2014-07-18 Child:7b9e0fc20256

0:7a6f64db7246 Go to Latest

auth/storage.go

Start rewriting the repo. This code originally was a carbon copy of https://github.com/RangelReale/osin, but I am methodically stripping out the extensible nature of it for a simpler interface, while simultaneously bringing the style into line with the Ducky style.

History
paddy@0 1 package oauth2
paddy@0 2
paddy@0 3 // Storage interface
paddy@0 4 type Storage interface {
paddy@0 5
paddy@0 6 // GetClient loads the client by id (client_id)
paddy@0 7 GetClient(id string) (*Client, error)
paddy@0 8
paddy@0 9 // SaveAuthorize saves authorize data.
paddy@0 10 SaveAuthorize(*AuthorizeData) error
paddy@0 11
paddy@0 12 // LoadAuthorize looks up AuthorizeData by a code.
paddy@0 13 // Client information MUST be loaded together.
paddy@0 14 // Optionally can return error if expired.
paddy@0 15 LoadAuthorize(code string) (*AuthorizeData, error)
paddy@0 16
paddy@0 17 // RemoveAuthorize revokes or deletes the authorization code.
paddy@0 18 RemoveAuthorize(code string) error
paddy@0 19
paddy@0 20 // SaveAccess writes AccessData.
paddy@0 21 // If RefreshToken is not blank, it must save in a way that can be loaded using LoadRefresh.
paddy@0 22 SaveAccess(*AccessData) error
paddy@0 23
paddy@0 24 // LoadAccess retrieves access data by token. Client information MUST be loaded together.
paddy@0 25 // AuthorizeData and AccessData DON'T NEED to be loaded if not easily available.
paddy@0 26 // Optionally can return error if expired.
paddy@0 27 LoadAccess(token string) (*AccessData, error)
paddy@0 28
paddy@0 29 // RemoveAccess revokes or deletes an AccessData.
paddy@0 30 RemoveAccess(token string) error
paddy@0 31
paddy@0 32 // LoadRefresh retrieves refresh AccessData. Client information MUST be loaded together.
paddy@0 33 // AuthorizeData and AccessData DON'T NEED to be loaded if not easily available.
paddy@0 34 // Optionally can return error if expired.
paddy@0 35 LoadRefresh(token string) (*AccessData, error)
paddy@0 36
paddy@0 37 // RemoveRefresh revokes or deletes refresh AccessData.
paddy@0 38 RemoveRefresh(token string) error
paddy@0 39 }