auth
auth/context.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.
1.1 --- a/context.go Tue May 12 21:14:21 2015 -0400 1.2 +++ b/context.go Fri May 15 19:44:40 2015 -0400 1.3 @@ -349,13 +349,12 @@ 1.4 } 1.5 1.6 // RevokeToken revokes the Token identfied by the passed token string from the tokenStore associated 1.7 -// with the context. If refresh is true, the token input should be compared against the refresh tokens, 1.8 -// not the access tokens. 1.9 -func (c Context) RevokeToken(token string, refresh bool) error { 1.10 +// with the context. 1.11 +func (c Context) RevokeToken(token string) error { 1.12 if c.tokens == nil { 1.13 return ErrNoTokenStore 1.14 } 1.15 - return c.tokens.revokeToken(token, refresh) 1.16 + return c.tokens.revokeToken(token) 1.17 } 1.18 1.19 // RevokeTokensByProfileID revokes the Tokens associated with the Profile identified by the passed ID in