auth
auth/session.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/session.go Fri Feb 20 22:34:43 2015 -0500 1.2 +++ b/session.go Tue Mar 03 22:18:28 2015 -0500 1.3 @@ -10,6 +10,7 @@ 1.4 "log" 1.5 "net/http" 1.6 "sort" 1.7 + "strings" 1.8 "time" 1.9 1.10 "code.secondbit.org/pass.hg" 1.11 @@ -319,11 +320,11 @@ 1.12 }) 1.13 } 1.14 1.15 -func credentialsValidate(w http.ResponseWriter, r *http.Request, context Context) (scope string, profileID uuid.ID, valid bool) { 1.16 +func credentialsValidate(w http.ResponseWriter, r *http.Request, context Context) (scopes []string, profileID uuid.ID, valid bool) { 1.17 enc := json.NewEncoder(w) 1.18 username := r.PostFormValue("username") 1.19 password := r.PostFormValue("password") 1.20 - scope = r.PostFormValue("scope") 1.21 + scopes = strings.Split(r.PostFormValue("scope"), " ") 1.22 profile, err := authenticate(username, password, context) 1.23 if err != nil { 1.24 if err == ErrIncorrectAuth || err == ErrProfileCompromised || err == ErrProfileLocked {