auth
auth/token.go
Attach our Scope type to AuthCodes and Tokens. When obtaining an AuthorizationCode or Token, attach a slice of strings, each one a Scope ID, instead of just attaching the encoded string the user passes in. This will allow us to change our Scope encoding down the line, and is more conceptually faithful. Also, if an authorization request is made with an invalid scope, return the invalid_scope error.
1.1 --- a/token.go Fri Feb 20 22:34:43 2015 -0500 1.2 +++ b/token.go Tue Mar 03 22:18:28 2015 -0500 1.3 @@ -43,7 +43,7 @@ 1.4 CreatedFrom string 1.5 ExpiresIn int32 1.6 TokenType string 1.7 - Scope string 1.8 + Scopes []string 1.9 ProfileID uuid.ID 1.10 ClientID uuid.ID 1.11 Revoked bool 1.12 @@ -139,7 +139,7 @@ 1.13 return tokens, nil 1.14 } 1.15 1.16 -func refreshTokenValidate(w http.ResponseWriter, r *http.Request, context Context) (scope string, profileID uuid.ID, valid bool) { 1.17 +func refreshTokenValidate(w http.ResponseWriter, r *http.Request, context Context) (scopes []string, profileID uuid.ID, valid bool) { 1.18 enc := json.NewEncoder(w) 1.19 refresh := r.PostFormValue("refresh_token") 1.20 if refresh == "" { 1.21 @@ -173,7 +173,7 @@ 1.22 renderJSONError(enc, "invalid_grant") 1.23 return 1.24 } 1.25 - return token.Scope, token.ProfileID, true 1.26 + return token.Scopes, token.ProfileID, true 1.27 } 1.28 1.29 func refreshTokenInvalidate(r *http.Request, context Context) error {