auth
auth/doc.go
Implement postgres version of the tokenStore. Create a postgres implementation for the tokenStore. Note that because pq doesn't support Postgres' array types (see https://github.com/lib/pq/issues/49), we couldn't just store the token.Scopes field as a Postgres array of varchars, which would have been the ideal. Instead, we need a many-to-many table that maps tokens to scopes. This meant we needed a special tokenScope type for our database mapping, and we needed to complicate the token storage/retrieval functions a little bit. It's kind of ugly, I'm not a huge fan of it, and I'd much rather be using the Postgres array types, but... well, here we are. We also added the postgres tokenStore to our slice of tokenStores to test when the correct environment variables are present. We wrote initialization SQL for the tables required by the postgres tokenStore. Also, added a helper script for emptying the test database, because I got tired of doing it by hand. We should be doing that in an automated fashion in the tests themselves, but that would mean extending the *Store interfaces.
| 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 |