Form getter already decodes this URLs

This commit is contained in:
Matthew Dillon 2015-11-11 17:42:33 -07:00
parent 6b69668616
commit ce0235af93

10
jwt.go
View file

@ -11,7 +11,6 @@ import (
"fmt" "fmt"
"log" "log"
"net/http" "net/http"
"net/url"
"strings" "strings"
) )
@ -103,15 +102,10 @@ func (m *Middleware) Secure(h http.Handler, v VerifyClaimsFunc) http.Handler {
authHeader := r.Header.Get("Authorization") authHeader := r.Header.Get("Authorization")
if authHeader == "" { if authHeader == "" {
queryParam := r.FormValue("token") token = r.FormValue("token")
if queryParam == "" { if token == "" {
return &jwtError{status: http.StatusUnauthorized, err: ErrMissingToken} return &jwtError{status: http.StatusUnauthorized, err: ErrMissingToken}
} }
var err error
token, err = url.QueryUnescape(queryParam)
if err != nil {
return &jwtError{status: http.StatusUnauthorized, err: ErrMalformedToken}
}
} else { } else {
token = strings.Split(authHeader, " ")[1] token = strings.Split(authHeader, " ")[1]
} }