auth
2014-07-18
Child:7b9e0fc20256
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.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/storage.go Fri Jul 18 07:13:22 2014 -0400 1.3 @@ -0,0 +1,39 @@ 1.4 +package oauth2 1.5 + 1.6 +// Storage interface 1.7 +type Storage interface { 1.8 + 1.9 + // GetClient loads the client by id (client_id) 1.10 + GetClient(id string) (*Client, error) 1.11 + 1.12 + // SaveAuthorize saves authorize data. 1.13 + SaveAuthorize(*AuthorizeData) error 1.14 + 1.15 + // LoadAuthorize looks up AuthorizeData by a code. 1.16 + // Client information MUST be loaded together. 1.17 + // Optionally can return error if expired. 1.18 + LoadAuthorize(code string) (*AuthorizeData, error) 1.19 + 1.20 + // RemoveAuthorize revokes or deletes the authorization code. 1.21 + RemoveAuthorize(code string) error 1.22 + 1.23 + // SaveAccess writes AccessData. 1.24 + // If RefreshToken is not blank, it must save in a way that can be loaded using LoadRefresh. 1.25 + SaveAccess(*AccessData) error 1.26 + 1.27 + // LoadAccess retrieves access data by token. Client information MUST be loaded together. 1.28 + // AuthorizeData and AccessData DON'T NEED to be loaded if not easily available. 1.29 + // Optionally can return error if expired. 1.30 + LoadAccess(token string) (*AccessData, error) 1.31 + 1.32 + // RemoveAccess revokes or deletes an AccessData. 1.33 + RemoveAccess(token string) error 1.34 + 1.35 + // LoadRefresh retrieves refresh AccessData. Client information MUST be loaded together. 1.36 + // AuthorizeData and AccessData DON'T NEED to be loaded if not easily available. 1.37 + // Optionally can return error if expired. 1.38 + LoadRefresh(token string) (*AccessData, error) 1.39 + 1.40 + // RemoveRefresh revokes or deletes refresh AccessData. 1.41 + RemoveRefresh(token string) error 1.42 +}