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

Commit 2d0b785

Browse files
authored
Merge pull request #1084 from yguedidi/enforce_https
Strip 'enforce_https' param
2 parents 4f1c91f + 5f4a062 commit 2d0b785

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Version 5 of the Facebook PHP SDK is a complete refactor of version 4. It comes
1111
- Add `GraphPage::getFanCount()` to get the number of people who like the page (#815)
1212
- Fixed HTTP/2 support (#1079)
1313
- Fixed resumable upload error (#1001)
14+
- Strip 'enforce_https' param (#1084)
1415
- 5.6.3 (2018-07-01)
1516
- Add fix for countable error in PHP 7.2 (originally #969 by @andreybolonin)
1617
- 5.6.2 (2018-02-15)

src/Facebook/Helpers/FacebookRedirectLoginHelper.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ public function getAccessToken($redirectUrl = null)
222222
$this->resetCsrf();
223223

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

228228
return $this->oAuth2Client->getAccessTokenFromCode($code, $redirectUrl);
229229
}

tests/Helpers/FacebookRedirectLoginHelperTest.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class FacebookRedirectLoginHelperTest extends \PHPUnit_Framework_TestCase
4545

4646
const REDIRECT_URL = 'http://invalid.zzz';
4747
const FOO_CODE = "foo_code";
48+
const FOO_ENFORCE_HTTPS = "foo_enforce_https";
4849
const FOO_STATE = "foo_state";
4950
const FOO_PARAM = "some_param=blah";
5051

@@ -96,15 +97,17 @@ public function testLogoutURL()
9697

9798
public function testAnAccessTokenCanBeObtainedFromRedirect()
9899
{
99-
$this->persistentDataHandler->set('state', 'foo_state');
100-
$_GET['state'] = static::FOO_STATE;
100+
$this->persistentDataHandler->set('state', static::FOO_STATE);
101+
101102
$_GET['code'] = static::FOO_CODE;
103+
$_GET['enforce_https'] = static::FOO_ENFORCE_HTTPS;
104+
$_GET['state'] = static::FOO_STATE;
102105

103-
$fullUrl = self::REDIRECT_URL . '?state=' . static::FOO_STATE . '&code=' . static::FOO_CODE . '&' . static::FOO_PARAM;
106+
$fullUrl = self::REDIRECT_URL . '?state=' . static::FOO_STATE . '&enforce_https=' . static::FOO_ENFORCE_HTTPS . '&code=' . static::FOO_CODE . '&' . static::FOO_PARAM;
104107

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

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

0 commit comments

Comments
 (0)