auth

Paddy 2014-12-13 Parent:42bc3e44f4fe Child:c1b3a36af1a7

88:61a802849b51 Go to Latest

auth/token.go

Add refresh expiration and revoking tokens. Add a property to hold the expiration date for a refresh token. Add a TODO for a tokenStore method to revoke a token.

History
     1.1 --- a/token.go	Sun Dec 07 03:40:25 2014 -0500
     1.2 +++ b/token.go	Sat Dec 13 19:05:06 2014 -0500
     1.3 @@ -8,7 +8,8 @@
     1.4  )
     1.5  
     1.6  const (
     1.7 -	defaultTokenExpiration = 3600 // one hour
     1.8 +	defaultTokenExpiration        = 3600  // one hour
     1.9 +	defaultRefreshTokenExpiration = 86400 // one day
    1.10  )
    1.11  
    1.12  var (
    1.13 @@ -24,16 +25,20 @@
    1.14  // Token represents an access and/or refresh token that the Client can use to access user data
    1.15  // or obtain a new access token.
    1.16  type Token struct {
    1.17 -	AccessToken  string
    1.18 -	RefreshToken string
    1.19 -	Created      time.Time
    1.20 -	ExpiresIn    int32
    1.21 -	TokenType    string
    1.22 -	Scope        string
    1.23 -	ProfileID    uuid.ID
    1.24 +	AccessToken      string
    1.25 +	RefreshToken     string
    1.26 +	Created          time.Time
    1.27 +	CreatedFrom      string
    1.28 +	ExpiresIn        int32
    1.29 +	RefreshExpiresIn int32
    1.30 +	TokenType        string
    1.31 +	Scope            string
    1.32 +	ProfileID        uuid.ID
    1.33 +	Revoked          bool
    1.34  }
    1.35  
    1.36  type tokenStore interface {
    1.37 +	// BUG(paddy): need to be able to revoke tokens and refresh tokens
    1.38  	getToken(token string, refresh bool) (Token, error)
    1.39  	saveToken(token Token) error
    1.40  	removeToken(token string) error