auth

Paddy 2014-12-13 Parent:1fb166575e69 Child:9c50b2e2e03b

93:a22b35677cd5 Go to Latest

auth/context.go

Implement RevokeToken helper for Context. Add a RevokeToken wrapper to Context that checks for the a tokenStore set on the Context and calls the underlying tokenStore.revokeToken if a tokenStore is set.

History
     1.1 --- a/context.go	Sat Dec 13 19:22:20 2014 -0500
     1.2 +++ b/context.go	Sat Dec 13 19:24:31 2014 -0500
     1.3 @@ -272,6 +272,16 @@
     1.4  	return c.tokens.removeToken(token)
     1.5  }
     1.6  
     1.7 +// RevokeToken revokes the Token identfied by the passed token string from the tokenStore associated
     1.8 +// with the context. If refresh is true, the token input should be compared against the refresh tokens,
     1.9 +// not the access tokens.
    1.10 +func (c Context) RevokeToken(token string, refresh bool) error {
    1.11 +	if c.tokens == nil {
    1.12 +		return ErrNoTokenStore
    1.13 +	}
    1.14 +	return c.tokens.revokeToken(token, refresh)
    1.15 +}
    1.16 +
    1.17  // GetTokensByProfileID returns a slice of up to num Tokens with a ProfileID that matches the specified
    1.18  // profileID from the tokenStore associated with the Context, skipping offset Tokens.
    1.19  func (c Context) GetTokensByProfileID(profileID uuid.ID, num, offset int) ([]Token, error) {