diff --git a/authorize.go b/authorize.go index f5c67d1..982d000 100644 --- a/authorize.go +++ b/authorize.go @@ -107,7 +107,7 @@ func (s *Server) HandleAuthorizeRequest(w *Response, r *http.Request) *Authorize r.ParseForm() // create the authorization request - unescapedUri, err := url.QueryUnescape(r.Form.Get("redirect_uri")) + unescapedUri, err := url.QueryUnescape(r.FormValue("redirect_uri")) if err != nil { w.SetErrorState(E_INVALID_REQUEST, "", "") w.InternalError = err @@ -115,15 +115,15 @@ func (s *Server) HandleAuthorizeRequest(w *Response, r *http.Request) *Authorize } ret := &AuthorizeRequest{ - State: r.Form.Get("state"), - Scope: r.Form.Get("scope"), + State: r.FormValue("state"), + Scope: r.FormValue("scope"), RedirectUri: unescapedUri, Authorized: false, HttpRequest: r, } // must have a valid client - ret.Client, err = w.Storage.GetClient(r.Form.Get("client_id")) + ret.Client, err = w.Storage.GetClient(r.FormValue("client_id")) if err == ErrNotFound { w.SetErrorState(E_UNAUTHORIZED_CLIENT, "", ret.State) return nil @@ -156,7 +156,7 @@ func (s *Server) HandleAuthorizeRequest(w *Response, r *http.Request) *Authorize w.SetRedirect(ret.RedirectUri) - requestType := AuthorizeRequestType(r.Form.Get("response_type")) + requestType := AuthorizeRequestType(r.FormValue("response_type")) if s.Config.AllowedAuthorizeTypes.Exists(requestType) { switch requestType { case CODE: @@ -164,14 +164,14 @@ func (s *Server) HandleAuthorizeRequest(w *Response, r *http.Request) *Authorize ret.Expiration = s.Config.AuthorizationExpiration // Optional PKCE support (https://tools.ietf.org/html/rfc7636) - if codeChallenge := r.Form.Get("code_challenge"); len(codeChallenge) == 0 { + if codeChallenge := r.FormValue("code_challenge"); len(codeChallenge) == 0 { if s.Config.RequirePKCEForPublicClients && CheckClientSecret(ret.Client, "") { // https://tools.ietf.org/html/rfc7636#section-4.4.1 w.SetErrorState(E_INVALID_REQUEST, "code_challenge (rfc7636) required for public clients", ret.State) return nil } } else { - codeChallengeMethod := r.Form.Get("code_challenge_method") + codeChallengeMethod := r.FormValue("code_challenge_method") // allowed values are "plain" (default) and "S256", per https://tools.ietf.org/html/rfc7636#section-4.3 if len(codeChallengeMethod) == 0 { codeChallengeMethod = PKCE_PLAIN diff --git a/example/complete/complete.go b/example/complete/complete.go index fc88311..51f18f4 100644 --- a/example/complete/complete.go +++ b/example/complete/complete.go @@ -103,7 +103,7 @@ func main() { http.HandleFunc("/appauth/code", func(w http.ResponseWriter, r *http.Request) { r.ParseForm() - code := r.Form.Get("code") + code := r.FormValue("code") w.Write([]byte("
")) w.Write([]byte("APP AUTH - CODE