diff --git a/ChangeLog b/ChangeLog index 993d7fa308..77902054d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -57,6 +57,7 @@ phpMyAdmin - ChangeLog - issue Fix php notice "Undefined index table_create_time" when setting displayed columns on results of a view - issue #15571 Fix fatal error when trying to edit row with row checked and button under the table - issue #15633 Fix designer set display field broken for php 5.x versions +- issue #15621 Support CloudFront-Forwarded-Proto header for Amazon CloudFront proxy 4.9.2 (2019-11-21) - issue #14184 Change the cookie name from phpMyAdmin to phpMyAdmin_https for HTTPS, fixes many "Failed to set session cookie" errors diff --git a/libraries/classes/Config.php b/libraries/classes/Config.php index b57a889712..44c1b1b241 100644 --- a/libraries/classes/Config.php +++ b/libraries/classes/Config.php @@ -1328,6 +1328,9 @@ class Config $is_https = true; } elseif (strtolower(Core::getenv('HTTP_X_FORWARDED_PROTO')) == 'https') { $is_https = true; + } elseif (strtolower(Core::getenv('HTTP_CLOUDFRONT_FORWARDED_PROTO')) === 'https') { + // Amazon CloudFront, issue #15621 + $is_https = true; } elseif (Core::getenv('SERVER_PORT') == 443) { $is_https = true; } diff --git a/test/classes/ConfigTest.php b/test/classes/ConfigTest.php index 6e3a77f099..8b709b9881 100644 --- a/test/classes/ConfigTest.php +++ b/test/classes/ConfigTest.php @@ -483,20 +483,22 @@ class ConfigTest extends PmaTestCase /** * test for IsHttp * - * @param string $scheme http scheme - * @param string $https https - * @param string $uri request uri - * @param string $lb http https from lb - * @param string $front http front end https - * @param string $proto http x forwarded proto - * @param int $port server port - * @param bool $expected expected result + * @param string $scheme http scheme + * @param string $https https + * @param string $uri request uri + * @param string $lb http https from lb + * @param string $front http front end https + * @param string $proto http x forwarded proto + * @param string $protoCloudFront http cloudfront forwarded proto + * @param string $pmaAbsoluteUri phpMyAdmin absolute URI + * @param int $port server port + * @param bool $expected expected result * * @return void * * @dataProvider httpsParams */ - public function testIsHttps($scheme, $https, $uri, $lb, $front, $proto, $port, $expected): void + public function testIsHttps($scheme, $https, $uri, $lb, $front, $proto, $protoCloudFront, $pmaAbsoluteUri, $port, $expected): void { $_SERVER['HTTP_SCHEME'] = $scheme; $_SERVER['HTTPS'] = $https; @@ -504,9 +506,11 @@ class ConfigTest extends PmaTestCase $_SERVER['HTTP_HTTPS_FROM_LB'] = $lb; $_SERVER['HTTP_FRONT_END_HTTPS'] = $front; $_SERVER['HTTP_X_FORWARDED_PROTO'] = $proto; + $_SERVER['HTTP_CLOUDFRONT_FORWARDED_PROTO'] = $protoCloudFront; $_SERVER['SERVER_PORT'] = $port; $this->object->set('is_https', null); + $this->object->set('PmaAbsoluteUri', $pmaAbsoluteUri); $this->assertEquals($expected, $this->object->isHttps()); } @@ -525,6 +529,8 @@ class ConfigTest extends PmaTestCase '', '', 'http', + '', + '', 80, false, ], @@ -535,6 +541,8 @@ class ConfigTest extends PmaTestCase '', '', 'http', + '', + '', 80, false, ], @@ -545,6 +553,8 @@ class ConfigTest extends PmaTestCase '', '', 'http', + '', + '', 443, true, ], @@ -555,6 +565,8 @@ class ConfigTest extends PmaTestCase '', '', 'https', + '', + '', 80, true, ], @@ -565,6 +577,8 @@ class ConfigTest extends PmaTestCase '', 'on', 'http', + '', + '', 80, true, ], @@ -575,6 +589,8 @@ class ConfigTest extends PmaTestCase 'on', '', 'http', + '', + '', 80, true, ], @@ -585,6 +601,8 @@ class ConfigTest extends PmaTestCase '', '', 'http', + '', + '', 80, true, ], @@ -595,6 +613,8 @@ class ConfigTest extends PmaTestCase '', '', 'http', + '', + '', 80, true, ], @@ -605,9 +625,83 @@ class ConfigTest extends PmaTestCase '', '', 'http', + '', + '', 80, true, ], + [ + 'http', + '', + '', + '', + '', + '', + 'https', + '', + 80, + true, + ], + [ + 'http', + '', + '', + '', + '', + 'https', + 'http', + '', + 80, + true, + ], + [ + 'https', + '', + '', + '', + '', + '', + '', + '', + 80, + true, + ], + [ + 'http', + '', + '', + '', + '', + '', + '', + '', + 8080, + false, + ], + [ + '', + '', + '', + '', + '', + '', + '', + 'https://127.0.0.1', + 80, + true, + ], + [ + '', + '', + '', + '', + '', + '', + '', + 'http://127.0.0.1', + 80, + false, + ], ]; }