auth

Paddy 2015-05-15 Parent:3223a8e679db

168:581c60f8dd23 Go to Latest

auth/doc.go

Switch to a JWT approach. We're going to use a JWT as our access tokens (as discussed in &yet's excellent post https://blog.andyet.com/2015/05/12/micro-services-user-info-and-auth and my ensuing conversation with Fritzy). The benefit of this approach is that we can do authentication and even some authorization without touching the database at all. The drawback is that we can no longer revoke access tokens, only the refresh tokens that grant the access tokens. We need a new config variable to set our private key, used to sign the JWT. We get to remove our token handlers, as we no longer can revoke tokens, so there's no purpose in getting information about it or listing them. Our tokenStore revokeToken gets to be simplified, as it will only ever be used for refresh tokens now. We also updated our postgres and memstore implementations. We added a helper method for generating the signed "access token" (our JWT) and started using it in the places where we're creating a Token. We get to remove the `revoked` SQL column for the tokens table, and rename the `refresh_revoked` column to just be `revoked`. We shortened our access token expiration to 15 minutes instead of an hour, to deal with the token not being revokable.

History
1 /*
2 Package auth provides an authentication service for managing user accounts and an OAuth2 provider.
4 The service is an opinionated implementation of authentication using passphrases and the
5 code.secondbit.org/pass package to implement user credentials and accounts. Additionally, users
6 are permitted to login using any email address they have on record. Care is also taken to be able
7 to mitigate attacks that have already happened and plan ahead for the worst case scenarios.
9 An OAuth2 provider is also built-in and provided, complete with client registration and management,
10 as well as a specification-based set of handlers for managing the issuing of grants and tokens. Token
11 validiity may be asserted through an API, or a proxy service is provided for stripping auth-specific
12 information from requests and replacing it with a trusted header containing information about the user
13 and client that authorized the request.
14 */
15 package auth