merged branch havvg/feature/config-http_method_override (PR #7202)
This PR was squashed before being merged into the master branch (closes #7202).
Commits
-------
817453c
[2.2] add http_method_override option to ease setup
Discussion
----------
[2.2] add http_method_override option to ease setup
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| License | MIT
This commit is contained in:
commit
ea252671b0
@ -52,6 +52,10 @@ class Configuration implements ConfigurationInterface
|
|||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->scalarNode('secret')->end()
|
->scalarNode('secret')->end()
|
||||||
|
->scalarNode('http_method_override')
|
||||||
|
->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
|
->scalarNode('trust_proxy_headers')->defaultFalse()->end() // @deprecated, to be removed in 2.3
|
||||||
->arrayNode('trusted_proxies')
|
->arrayNode('trusted_proxies')
|
||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
|
@ -66,6 +66,8 @@ class FrameworkExtension extends Extension
|
|||||||
$container->setParameter('kernel.secret', $config['secret']);
|
$container->setParameter('kernel.secret', $config['secret']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$container->setParameter('kernel.http_method_override', $config['http_method_override']);
|
||||||
|
|
||||||
$container->setParameter('kernel.trusted_proxies', $config['trusted_proxies']);
|
$container->setParameter('kernel.trusted_proxies', $config['trusted_proxies']);
|
||||||
|
|
||||||
// @deprecated, to be removed in 2.3
|
// @deprecated, to be removed in 2.3
|
||||||
|
@ -46,6 +46,10 @@ class FrameworkBundle extends Bundle
|
|||||||
} elseif ($this->container->getParameter('kernel.trust_proxy_headers')) {
|
} elseif ($this->container->getParameter('kernel.trust_proxy_headers')) {
|
||||||
Request::trustProxyData(); // @deprecated, to be removed in 2.3
|
Request::trustProxyData(); // @deprecated, to be removed in 2.3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->container->getParameter('kernel.http_method_override')) {
|
||||||
|
Request::enableHttpMethodParameterOverride();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build(ContainerBuilder $container)
|
public function build(ContainerBuilder $container)
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
<!-- charset is deprecated and will be removed in 2.2 -->
|
<!-- charset is deprecated and will be removed in 2.2 -->
|
||||||
<xsd:attribute name="charset" type="xsd:string" />
|
<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="trust-proxy-headers" type="xsd:string" />
|
||||||
<xsd:attribute name="trusted-proxies" type="xsd:string" />
|
<xsd:attribute name="trusted-proxies" type="xsd:string" />
|
||||||
<xsd:attribute name="ide" type="xsd:string" />
|
<xsd:attribute name="ide" type="xsd:string" />
|
||||||
|
@ -88,6 +88,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'charset' => null,
|
'charset' => null,
|
||||||
|
'http_method_override' => true,
|
||||||
'trust_proxy_headers' => false,
|
'trust_proxy_headers' => false,
|
||||||
'trusted_proxies' => array(),
|
'trusted_proxies' => array(),
|
||||||
'ide' => null,
|
'ide' => null,
|
||||||
|
@ -4,6 +4,7 @@ $container->loadFromExtension('framework', array(
|
|||||||
'secret' => 's3cr3t',
|
'secret' => 's3cr3t',
|
||||||
'default_locale' => 'fr',
|
'default_locale' => 'fr',
|
||||||
'form' => null,
|
'form' => null,
|
||||||
|
'http_method_override' => false,
|
||||||
'trust_proxy_headers' => true,
|
'trust_proxy_headers' => true,
|
||||||
'trusted_proxies' => array('127.0.0.1', '10.0.0.1'),
|
'trusted_proxies' => array('127.0.0.1', '10.0.0.1'),
|
||||||
'csrf_protection' => array(
|
'csrf_protection' => array(
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
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">
|
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">
|
<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:csrf-protection enabled="true" field-name="_csrf" />
|
<framework:csrf-protection enabled="true" field-name="_csrf" />
|
||||||
<framework:form />
|
<framework:form />
|
||||||
<framework:esi enabled="true" />
|
<framework:esi enabled="true" />
|
||||||
|
@ -2,6 +2,7 @@ framework:
|
|||||||
secret: s3cr3t
|
secret: s3cr3t
|
||||||
default_locale: fr
|
default_locale: fr
|
||||||
form: ~
|
form: ~
|
||||||
|
http_method_override: false
|
||||||
trust_proxy_headers: true
|
trust_proxy_headers: true
|
||||||
trusted_proxies: ['127.0.0.1', '10.0.0.1']
|
trusted_proxies: ['127.0.0.1', '10.0.0.1']
|
||||||
csrf_protection:
|
csrf_protection:
|
||||||
|
@ -41,6 +41,13 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
$this->assertEquals(array('127.0.0.1', '10.0.0.1'), $container->getParameter('kernel.trusted_proxies'));
|
$this->assertEquals(array('127.0.0.1', '10.0.0.1'), $container->getParameter('kernel.trusted_proxies'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testHttpMethodOverride()
|
||||||
|
{
|
||||||
|
$container = $this->createContainerFromFile('full');
|
||||||
|
|
||||||
|
$this->assertFalse($container->getParameter('kernel.http_method_override'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testEsi()
|
public function testEsi()
|
||||||
{
|
{
|
||||||
$container = $this->createContainerFromFile('full');
|
$container = $this->createContainerFromFile('full');
|
||||||
|
Reference in New Issue
Block a user