auth
auth/client.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.
| paddy@6 | 1 package auth |
| paddy@0 | 2 |
| paddy@0 | 3 import ( |
| paddy@0 | 4 "secondbit.org/uuid" |
| paddy@0 | 5 ) |
| paddy@0 | 6 |
| paddy@25 | 7 // Client represents a client that grants access |
| paddy@25 | 8 // to the auth server, exchanging grants for tokens, |
| paddy@25 | 9 // and tokens for access. |
| paddy@0 | 10 type Client struct { |
| paddy@0 | 11 ID uuid.ID |
| paddy@0 | 12 Secret string |
| paddy@0 | 13 RedirectURI string |
| paddy@0 | 14 OwnerID uuid.ID |
| paddy@0 | 15 Name string |
| paddy@0 | 16 Logo string |
| paddy@25 | 17 Website string |
| paddy@0 | 18 } |
| paddy@0 | 19 |
| paddy@25 | 20 // ClientStore abstracts the storage interface for |
| paddy@25 | 21 // storing and retrieving Clients. |
| paddy@25 | 22 type ClientStore interface { |
| paddy@25 | 23 GetClient(id uuid.ID) (Client, error) |
| paddy@25 | 24 SaveClient(client Client) error |
| paddy@25 | 25 UpdateClient(id uuid.ID, secret, redirectURI *string, ownerID uuid.ID, name, logo, website *string) error |
| paddy@25 | 26 DeleteClient(id uuid.ID) error |
| paddy@25 | 27 ListClientsByOwner(ownerID uuid.ID, page, num int) ([]Client, error) |
| paddy@0 | 28 } |