Skip to content

Commit

Permalink
unescape uri in HandleAuthorizeRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Novgorodsky committed Feb 3, 2014
1 parent e486e57 commit 40db961
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions authorize.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package osin

import (
"net/http"
"net/url"
"time"
)

Expand Down Expand Up @@ -95,17 +96,19 @@ func (s *Server) HandleAuthorizeRequest(w *Response, r *http.Request) *Authorize

func (s *Server) handleCodeRequest(w *Response, r *http.Request) *AuthorizeRequest {
// create the authorization request
unescapedUri, err := url.QueryUnescape(r.Form.Get("redirect_uri"))
if err != nil {
unescapedUri = ""
}
ret := &AuthorizeRequest{
Type: CODE,
State: r.Form.Get("state"),
Scope: r.Form.Get("scope"),
RedirectUri: r.Form.Get("redirect_uri"),
RedirectUri: unescapedUri,
Authorized: false,
Expiration: s.Config.AuthorizationExpiration,
}

var err error

// must have a valid client
ret.Client, err = s.Storage.GetClient(r.Form.Get("client_id"))
if err != nil {
Expand Down Expand Up @@ -140,18 +143,20 @@ func (s *Server) handleCodeRequest(w *Response, r *http.Request) *AuthorizeReque

func (s *Server) handleTokenRequest(w *Response, r *http.Request) *AuthorizeRequest {
// create the authorization request
unescapedUri, err := url.QueryUnescape(r.Form.Get("redirect_uri"))
if err != nil {
unescapedUri = ""
}
ret := &AuthorizeRequest{
Type: TOKEN,
State: r.Form.Get("state"),
Scope: r.Form.Get("scope"),
RedirectUri: r.Form.Get("redirect_uri"),
RedirectUri: unescapedUri,
Authorized: false,
// this type will generate a token directly, use access token expiration instead.
Expiration: s.Config.AccessExpiration,
}

var err error

// must have a valid client
ret.Client, err = s.Storage.GetClient(r.Form.Get("client_id"))
if err != nil {
Expand Down

0 comments on commit 40db961

Please sign in to comment.