Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Strip 'enforce_https' param #1084

Merged
merged 1 commit into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Version 5 of the Facebook PHP SDK is a complete refactor of version 4. It comes
- Add `GraphPage::getFanCount()` to get the number of people who like the page (#815)
- Fixed HTTP/2 support (#1079)
- Fixed resumable upload error (#1001)
- Strip 'enforce_https' param (#1084)
- 5.6.3 (2018-07-01)
- Add fix for countable error in PHP 7.2 (originally #969 by @andreybolonin)
- 5.6.2 (2018-02-15)
Expand Down
4 changes: 2 additions & 2 deletions src/Facebook/Helpers/FacebookRedirectLoginHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ public function getAccessToken($redirectUrl = null)
$this->resetCsrf();

$redirectUrl = $redirectUrl ?: $this->urlDetectionHandler->getCurrentUrl();
// At minimum we need to remove the 'state' and 'code' params
$redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl, ['code', 'state']);
// At minimum we need to remove the 'code', 'enforce_https' and 'state' params
$redirectUrl = FacebookUrlManipulator::removeParamsFromUrl($redirectUrl, ['code', 'enforce_https', 'state']);

return $this->oAuth2Client->getAccessTokenFromCode($code, $redirectUrl);
}
Expand Down
11 changes: 7 additions & 4 deletions tests/Helpers/FacebookRedirectLoginHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class FacebookRedirectLoginHelperTest extends \PHPUnit_Framework_TestCase

const REDIRECT_URL = 'http://invalid.zzz';
const FOO_CODE = "foo_code";
const FOO_ENFORCE_HTTPS = "foo_enforce_https";
const FOO_STATE = "foo_state";
const FOO_PARAM = "some_param=blah";

Expand Down Expand Up @@ -96,15 +97,17 @@ public function testLogoutURL()

public function testAnAccessTokenCanBeObtainedFromRedirect()
{
$this->persistentDataHandler->set('state', 'foo_state');
$_GET['state'] = static::FOO_STATE;
$this->persistentDataHandler->set('state', static::FOO_STATE);

$_GET['code'] = static::FOO_CODE;
$_GET['enforce_https'] = static::FOO_ENFORCE_HTTPS;
$_GET['state'] = static::FOO_STATE;

$fullUrl = self::REDIRECT_URL . '?state=' . static::FOO_STATE . '&code=' . static::FOO_CODE . '&' . static::FOO_PARAM;
$fullUrl = self::REDIRECT_URL . '?state=' . static::FOO_STATE . '&enforce_https=' . static::FOO_ENFORCE_HTTPS . '&code=' . static::FOO_CODE . '&' . static::FOO_PARAM;

$accessToken = $this->redirectLoginHelper->getAccessToken($fullUrl);

// code and state should be stripped from the URL
// 'code', 'enforce_https' and 'state' should be stripped from the URL
$expectedUrl = self::REDIRECT_URL . '?' . static::FOO_PARAM;
$expectedString = 'foo_token_from_code|' . static::FOO_CODE . '|' . $expectedUrl;

Expand Down