auth

Paddy 2015-03-03 Parent:bc842183181d Child:f59559b33c76

135:d30a3a12d387 Go to Latest

auth/client.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.

History
     1.1 --- a/client.go	Fri Feb 20 22:34:43 2015 -0500
     1.2 +++ b/client.go	Tue Mar 03 22:18:28 2015 -0500
     1.3 @@ -9,6 +9,7 @@
     1.4  	"net/http"
     1.5  	"net/url"
     1.6  	"strconv"
     1.7 +	"strings"
     1.8  	"time"
     1.9  
    1.10  	"github.com/PuerkitoBio/purell"
    1.11 @@ -662,8 +663,8 @@
    1.12  	return
    1.13  }
    1.14  
    1.15 -func clientCredentialsValidate(w http.ResponseWriter, r *http.Request, context Context) (scope string, profileID uuid.ID, valid bool) {
    1.16 -	scope = r.PostFormValue("scope")
    1.17 +func clientCredentialsValidate(w http.ResponseWriter, r *http.Request, context Context) (scopes []string, profileID uuid.ID, valid bool) {
    1.18 +	scopes = strings.Split(r.PostFormValue("scope"), " ")
    1.19  	valid = true
    1.20  	return
    1.21  }