diff options
author | techknowlogick <techknowlogick@gitea.io> | 2021-02-28 18:08:33 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-28 18:08:33 -0500 |
commit | 47f6a4ec3f058f69b65fb6501d6ac98994b8f8da (patch) | |
tree | 4d1421a4c836de9de4014117419c151035c17eec /vendor/github.com/mrjones/oauth | |
parent | 030646eea41e17e58e11e73b19339630b6d6148e (diff) | |
download | gitea-47f6a4ec3f058f69b65fb6501d6ac98994b8f8da.tar.gz gitea-47f6a4ec3f058f69b65fb6501d6ac98994b8f8da.zip |
go1.16 (#14783)
Diffstat (limited to 'vendor/github.com/mrjones/oauth')
-rw-r--r-- | vendor/github.com/mrjones/oauth/oauth.go | 29 | ||||
-rw-r--r-- | vendor/github.com/mrjones/oauth/provider.go | 9 |
2 files changed, 17 insertions, 21 deletions
diff --git a/vendor/github.com/mrjones/oauth/oauth.go b/vendor/github.com/mrjones/oauth/oauth.go index f16edb83dd..250e849277 100644 --- a/vendor/github.com/mrjones/oauth/oauth.go +++ b/vendor/github.com/mrjones/oauth/oauth.go @@ -806,19 +806,15 @@ func getBody(request *http.Request) ([]byte, error) { return originalBody, nil } -func parseBody(request *http.Request) (map[string]string, error) { - userParams := map[string]string{} +func parseBody(request *http.Request) (map[string][]string, error) { + userParams := map[string][]string{} // TODO(mrjones): factor parameter extraction into a separate method if request.Header.Get("Content-Type") != "application/x-www-form-urlencoded" { // Most of the time we get parameters from the query string: for k, vs := range request.URL.Query() { - if len(vs) != 1 { - return nil, fmt.Errorf("Must have exactly one value per param") - } - - userParams[k] = vs[0] + userParams[k] = vs } } else { // x-www-form-urlencoded parameters come from the body instead: @@ -833,24 +829,21 @@ func parseBody(request *http.Request) (map[string]string, error) { } for k, vs := range params { - if len(vs) != 1 { - return nil, fmt.Errorf("Must have exactly one value per param") - } - - userParams[k] = vs[0] + userParams[k] = vs } } return userParams, nil } -func paramsToSortedPairs(params map[string]string) pairs { +func paramsToSortedPairs(params map[string][]string) pairs { // Sort parameters alphabetically - paramPairs := make(pairs, len(params)) - i := 0 - for key, value := range params { - paramPairs[i] = pair{key: key, value: value} - i++ + paramPairs := pairs([]pair{}) + + for key, values := range params { + for _, value := range values { + paramPairs = append(paramPairs, pair{key: key, value: value}) + } } sort.Sort(paramPairs) diff --git a/vendor/github.com/mrjones/oauth/provider.go b/vendor/github.com/mrjones/oauth/provider.go index 3a37e38a1b..73ef5a4bde 100644 --- a/vendor/github.com/mrjones/oauth/provider.go +++ b/vendor/github.com/mrjones/oauth/provider.go @@ -58,13 +58,16 @@ func makeURLAbs(url *url.URL, request *http.Request) { // IsAuthorized takes an *http.Request and returns a pointer to a string containing the consumer key, // or nil if not authorized func (provider *Provider) IsAuthorized(request *http.Request) (*string, error) { + var userParams = map[string]string{} var err error - var userParams map[string]string // start with the body/query params - userParams, err = parseBody(request) - if err != nil { + if params_temp, err := parseBody(request); err != nil { return nil, err + } else { + for k, v := range params_temp { + userParams[k] = v[0] + } } // if the oauth params are in the Authorization header, grab them, and |