auth
auth/doc.go
Implement postgres clientStore. Stop requiring the client ID be passed to clientStore.addEndpoints and context.AddEndpoints. The Endpoints themselves contain the client ID. When using the authd server, set the log flags to include the file path and line number. Add an ErrEndpointAlreadyExists error, to return when creating an endpoint and its ID already exists in the database. Add a Deleted property to Clients and remove the clientStore.deleteClient and context.DeleteClient methods. We're not going to actually remove that data, and we want to be able to restore it, so include it in the ClientChange type and call it using UpdateClient. Create a ClientChange.Empty helper method that will return whether the ClientChange has any changes to perform. Return ErrClientNotFound from clientStore.getClient if the Client's Deleted property is set to true. This also requires us to ignore ErrClientNotFound errors when calling memstore.listClientsByOwner, as they should just be skipped instead of returning an error. Add the postgres type methods needed to implement clientStore. Include postgres as a clientStore if the testing.Short() flag is not set. Generate a new ID for the Client on every run in the tests, now that we can't actually remove it from the database/memstore in code. We really just need a *Store.Reset() function that erases all the data and starts over again, to give the tests a clean execution environment (and so they can clean up after themselves). Add the CREATE TABLE statements for the Clients table and the Endpoints table to sql/postgres_init.sql.
| paddy@57 | 1 /* |
| paddy@57 | 2 Package auth provides an authentication service for managing user accounts and an OAuth2 provider. |
| paddy@57 | 3 |
| paddy@57 | 4 The service is an opinionated implementation of authentication using passphrases and the |
| paddy@57 | 5 code.secondbit.org/pass package to implement user credentials and accounts. Additionally, users |
| paddy@57 | 6 are permitted to login using their email address on record or their username interchangeably. |
| paddy@57 | 7 Care is also taken to be able to mitigate attacks that have already happened and plan ahead for |
| paddy@57 | 8 the worst case scenarios. |
| paddy@57 | 9 |
| paddy@57 | 10 An OAuth2 provider is also built-in and provided, complete with client registration and management, |
| paddy@57 | 11 as well as a specification-based set of handlers for managing the issuing of grants and tokens. Token |
| paddy@57 | 12 validiity may be asserted through an API, or a proxy service is provided for stripping auth-specific |
| paddy@57 | 13 information from requests and replacing it with a trusted header containing information about the user |
| paddy@57 | 14 and client that authorized the request. |
| paddy@57 | 15 */ |
| paddy@57 | 16 package auth |