Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong redirect following authorization step #171

Merged
merged 2 commits into from
Jul 12, 2013
Merged

Fix wrong redirect following authorization step #171

merged 2 commits into from
Jul 12, 2013

Conversation

davidkuridza
Copy link
Contributor

#163 fix broke redirect after granting or denying client's access. If there is no redirect_uri, null is stored in oauth_access_tokens, which is correct. However, when user grants or denies access, OAuth2\Controller\AuthorizeController->handleAuthorizeRequest() redirected to ?code=.... The fix in this PR checks the value, and if empty, loads client's registered URI.

@simshaun
Copy link
Contributor

simshaun commented Jul 2, 2013

👍

I encountered this issue after pressing Cancel on the authorization request form. No redirect_uri param was given in the URL and the lib was not using the redirect_uri from storage, so Response threw an exception about redirecting to an empty URL.

This PR fixed it.

@bshaffer
Copy link
Owner

bshaffer commented Jul 3, 2013

As the existing test suite did not catch this error, we need to include tests to check this case.

@@ -86,6 +93,11 @@ public function handleAuthorizeRequest(RequestInterface $request, ResponseInterf
$authResult = $this->responseTypes[$this->response_type]->getAuthorizeResponse($params, $user_id);

list($redirect_uri, $uri_params) = $authResult;

if ( empty($redirect_uri) && ! empty($registered_redirect_uri) ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to keep whitespace consistent here

@davidkuridza
Copy link
Contributor Author

I fixed problematic whitespace indentation and amended the commit for this PR, as a side affect @bshaffer's comments where hidden. Sorry about that.

As for unit test, I'm having problems running the suite locally, will try again later today if time permits.

On a side note, do you have or plan on having a contribute guide?

@bshaffer
Copy link
Owner

bshaffer commented Jul 3, 2013

Good call, I do not have a contribute guide, but will add one shortly. Thank you for the fix!

The problem running the suite probably has to do with the redis tests... Unless you have a redis server running on localhost, they will fail.

Fix for #163 (#163) allowed
authorize flow to handle `redirect_uri` as an optional parameter. The change
resulted in user not being redirected back to the client after granting or
denying client's access.

This fix verifies whether `redirect_uri` is set or not in
`OAuth2\Controller\AuthorizeController`'s `handleAuthorizeRequest()` method.
If it's not set, it grabs the client's registered value.

If/When support for PHP 5.3 is dropped, the code can be modified to
`$this->clientStorage->getClientDetails($this->client_id)['redirect_uri']`.
@davidkuridza
Copy link
Contributor Author

I apologize for taking so long. Test added to verify #163 was not checking the actual value contained in $response->getHttpHeader('Location'), only the presence of code in the string. Try running the test on develop branch, you'll see it's failing, if you try debugging, $response->getHttpHeader('Location') will only contain ?code=....&state=xyz.

Changes from develop branch have also been rebased and pushed to this one. There shouldn't be any problems merging it to upstream.

@F21
Copy link
Contributor

F21 commented Jul 9, 2013

Looking good! 😄
@bshaffer Can this be merged?

@mihahribar
Copy link
Contributor

👍

bshaffer added a commit that referenced this pull request Jul 12, 2013
…on-flow

Fix wrong redirect following authorization step
@bshaffer bshaffer merged commit 8c460c9 into bshaffer:develop Jul 12, 2013
@davidkuridza davidkuridza deleted the fix-redirect-in-authorization-flow branch July 22, 2013 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants