removed deprected way to declared trusted proxies
This commit is contained in:
parent
5ff6006fa6
commit
c28f1b0926
@ -56,7 +56,6 @@ class Configuration implements ConfigurationInterface
|
||||
->info("Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests.")
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->scalarNode('trust_proxy_headers')->defaultFalse()->end() // @deprecated, to be removed in 2.3
|
||||
->arrayNode('trusted_proxies')
|
||||
->beforeNormalization()
|
||||
->ifTrue(function($v) { return !is_array($v) && !is_null($v); })
|
||||
|
@ -69,10 +69,6 @@ class FrameworkExtension extends Extension
|
||||
$container->setParameter('kernel.http_method_override', $config['http_method_override']);
|
||||
|
||||
$container->setParameter('kernel.trusted_proxies', $config['trusted_proxies']);
|
||||
|
||||
// @deprecated, to be removed in 2.3
|
||||
$container->setParameter('kernel.trust_proxy_headers', $config['trust_proxy_headers']);
|
||||
|
||||
$container->setParameter('kernel.default_locale', $config['default_locale']);
|
||||
|
||||
if (!empty($config['test'])) {
|
||||
|
@ -43,8 +43,6 @@ class FrameworkBundle extends Bundle
|
||||
{
|
||||
if ($trustedProxies = $this->container->getParameter('kernel.trusted_proxies')) {
|
||||
Request::setTrustedProxies($trustedProxies);
|
||||
} elseif ($this->container->getParameter('kernel.trust_proxy_headers')) {
|
||||
Request::trustProxyData(); // @deprecated, to be removed in 2.3
|
||||
}
|
||||
|
||||
if ($this->container->getParameter('kernel.http_method_override')) {
|
||||
|
@ -25,7 +25,6 @@
|
||||
<!-- charset is deprecated and will be removed in 2.2 -->
|
||||
<xsd:attribute name="charset" type="xsd:string" />
|
||||
<xsd:attribute name="http-method-override" type="xsd:boolean" />
|
||||
<xsd:attribute name="trust-proxy-headers" type="xsd:string" />
|
||||
<xsd:attribute name="trusted-proxies" type="xsd:string" />
|
||||
<xsd:attribute name="ide" type="xsd:string" />
|
||||
<xsd:attribute name="secret" type="xsd:string" />
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<parameters>
|
||||
<parameter key="event_dispatcher.class">Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher</parameter>
|
||||
<parameter key="http_kernel.class">Symfony\Bundle\FrameworkBundle\HttpKernel</parameter>
|
||||
<parameter key="http_kernel.class">Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel</parameter>
|
||||
<parameter key="filesystem.class">Symfony\Component\Filesystem\Filesystem</parameter>
|
||||
<parameter key="cache_warmer.class">Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate</parameter>
|
||||
<parameter key="cache_clearer.class">Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer</parameter>
|
||||
|
@ -89,7 +89,6 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||
return array(
|
||||
'charset' => null,
|
||||
'http_method_override' => true,
|
||||
'trust_proxy_headers' => false,
|
||||
'trusted_proxies' => array(),
|
||||
'ide' => null,
|
||||
'default_locale' => 'en',
|
||||
|
@ -5,7 +5,6 @@ $container->loadFromExtension('framework', array(
|
||||
'default_locale' => 'fr',
|
||||
'form' => null,
|
||||
'http_method_override' => false,
|
||||
'trust_proxy_headers' => true,
|
||||
'trusted_proxies' => array('127.0.0.1', '10.0.0.1'),
|
||||
'csrf_protection' => array(
|
||||
'enabled' => true,
|
||||
|
@ -6,7 +6,7 @@
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||
|
||||
<framework:config secret="s3cr3t" ide="file%%link%%format" default-locale="fr" trust-proxy-headers="true" trusted-proxies="127.0.0.1, 10.0.0.1" http-method-override="false">
|
||||
<framework:config secret="s3cr3t" ide="file%%link%%format" default-locale="fr" trusted-proxies="127.0.0.1, 10.0.0.1" http-method-override="false">
|
||||
<framework:csrf-protection enabled="true" field-name="_csrf" />
|
||||
<framework:form />
|
||||
<framework:esi enabled="true" />
|
||||
|
@ -3,7 +3,6 @@ framework:
|
||||
default_locale: fr
|
||||
form: ~
|
||||
http_method_override: false
|
||||
trust_proxy_headers: true
|
||||
trusted_proxies: ['127.0.0.1', '10.0.0.1']
|
||||
csrf_protection:
|
||||
enabled: true
|
||||
|
@ -37,7 +37,6 @@ abstract class FrameworkExtensionTest extends TestCase
|
||||
{
|
||||
$container = $this->createContainerFromFile('full');
|
||||
|
||||
$this->assertTrue($container->getParameter('kernel.trust_proxy_headers'));
|
||||
$this->assertEquals(array('127.0.0.1', '10.0.0.1'), $container->getParameter('kernel.trusted_proxies'));
|
||||
}
|
||||
|
||||
|
@ -464,18 +464,6 @@ class Request
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trusts $_SERVER entries coming from proxies.
|
||||
*
|
||||
* @deprecated Deprecated since version 2.0, to be removed in 2.3. Use setTrustedProxies instead.
|
||||
*/
|
||||
public static function trustProxyData()
|
||||
{
|
||||
trigger_error('trustProxyData() is deprecated since version 2.0 and will be removed in 2.3. Use setTrustedProxies() instead.', E_USER_DEPRECATED);
|
||||
|
||||
self::$trustProxy = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a list of trusted proxies.
|
||||
*
|
||||
@ -527,19 +515,6 @@ class Request
|
||||
self::$trustedHeaders[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if $_SERVER entries coming from proxies are trusted,
|
||||
* false otherwise.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @deprecated Deprecated since version 2.2, to be removed in 2.3. Use getTrustedProxies instead.
|
||||
*/
|
||||
public static function isProxyTrusted()
|
||||
{
|
||||
return self::$trustProxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a query string.
|
||||
*
|
||||
|
@ -764,12 +764,7 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
$request->initialize(array(), array(), array(), array(), array(), $server);
|
||||
if ($proxy) {
|
||||
set_error_handler(array($this, "deprecationErrorHandler"));
|
||||
$this->startTrustingProxyData();
|
||||
restore_error_handler();
|
||||
}
|
||||
$this->assertEquals($expected, $request->getClientIp($proxy));
|
||||
$this->assertEquals($expected, $request->getClientIp());
|
||||
|
||||
Request::setTrustedProxies(array());
|
||||
}
|
||||
@ -884,8 +879,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function testOverrideGlobals()
|
||||
{
|
||||
set_error_handler(array($this, "deprecationErrorHandler"));
|
||||
|
||||
$request = new Request();
|
||||
$request->initialize(array('foo' => 'bar'));
|
||||
|
||||
@ -903,7 +896,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertArrayNotHasKey('HTTP_X_FORWARDED_PROTO', $_SERVER);
|
||||
|
||||
$this->startTrustingProxyData();
|
||||
$request->headers->set('X_FORWARDED_PROTO', 'https');
|
||||
|
||||
Request::setTrustedProxies(array('1.1.1.1'));
|
||||
@ -1208,11 +1200,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertFalse($request->isMethod('post'));
|
||||
}
|
||||
|
||||
private function startTrustingProxyData()
|
||||
{
|
||||
Request::trustProxyData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getBaseUrlData
|
||||
*/
|
||||
@ -1342,15 +1329,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(80, $request->getPort());
|
||||
$this->assertFalse($request->isSecure());
|
||||
|
||||
// trusted proxy via deprecated trustProxyData()
|
||||
set_error_handler(array($this, "deprecationErrorHandler"));
|
||||
Request::trustProxyData();
|
||||
$this->assertEquals('2.2.2.2', $request->getClientIp());
|
||||
$this->assertEquals('real.example.com', $request->getHost());
|
||||
$this->assertEquals(443, $request->getPort());
|
||||
$this->assertTrue($request->isSecure());
|
||||
restore_error_handler();
|
||||
|
||||
// disabling proxy trusting
|
||||
Request::setTrustedProxies(array());
|
||||
$this->assertEquals('3.3.3.3', $request->getClientIp());
|
||||
|
Reference in New Issue
Block a user