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 for ensuring the redirect uri is identical across the initial aut… #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions lib/OAuth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -888,12 +888,8 @@ protected function grantAccessTokenAuthCode(IOAuth2Client $client, array $input)
throw new OAuth2ServerException(self::HTTP_BAD_REQUEST, self::ERROR_INVALID_GRANT, "Code doesn't exist or is invalid for the client");
}

// Validate the redirect URI. If a redirect URI has been provided on input, it must be validated
if ($input["redirect_uri"] && !$this->validateRedirectUri(
$input["redirect_uri"],
$authCode->getRedirectUri()
)
) {
// Validate the redirect URI. If a redirect URI has been provided on input, it must be identical
if ($input["redirect_uri"] && $input["redirect_uri"] === $authCode->getRedirectUri()) {

Choose a reason for hiding this comment

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

Shouldn't this be !== for "fail if redirect_uri is set and is not equal to the stored one"?

throw new OAuth2ServerException(self::HTTP_BAD_REQUEST, self::ERROR_REDIRECT_URI_MISMATCH, "The redirect URI is missing or do not match");
}

Expand Down Expand Up @@ -1501,7 +1497,7 @@ private function getJsonHeaders()
* Internal method for validating redirect URI supplied
*
* @param string $inputUri
* @param string|array $storedUris
* @param array $storedUris
*
* @return bool
*/
Expand All @@ -1525,10 +1521,6 @@ protected function validateRedirectUri($inputUri, $storedUris)
}
}

if (!is_array($storedUris)) {
$storedUris = array($storedUris);
}

foreach ($storedUris as $storedUri) {
if (strcasecmp(substr($inputUri, 0, strlen($storedUri)), $storedUri) === 0) {
return true;
Expand Down