8000 Minor fixes to the FrameworkBundle configuration by wouterj · Pull Request #11765 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Minor fixes to the FrameworkBundle configuration #11765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public function getConfigTreeBuilder()
$rootNode = $treeBuilder->root('framework');

$rootNode
->fixXmlConfig('trusted_proxy', 'trusted_proxies')
->fixXmlConfig('trusted_host')
->children()
->scalarNode('secret')->end()
->scalarNode('http_method_override')
Expand Down Expand Up @@ -152,7 +154,7 @@ private function addProfilerSection(ArrayNodeDefinition $rootNode)
->scalarNode('dsn')->defaultValue('file:%kernel.cache_dir%/profiler')->end()
->scalarNode('username')->defaultValue('')->end()
->scalarNode('password')->defaultValue('')->end()
->scalarNode('lifetime')->defaultValue(86400)->end()
->integerNode('lifetime')->defaultValue(86400)->end()
->arrayNode('matcher')
->canBeUnset()
->performNoDeepMerging()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<xsd:element name="config" type="config" />

<xsd:complexType name="config">
<xsd:all>
<xsd:sequence>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a major BC break, since elements now must have a predefined order. However, within xsd:all, all elements are either available or not, but they can't occur multiple times.

<xsd:element name="trusted-proxy" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="trusted-host" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
<xsd:element name="csrf-protection" type="csrf_protection" minOccurs="0" maxOccurs="1" />
<xsd:element name="esi" type="esi" minOccurs="0" maxOccurs="1" />
Expand All @@ -20,12 +22,12 @@
<xsd:element name="translator" type="translator" minOccurs="0" maxOccurs="1" />
<xsd:element name="validation" type="validation" minOccurs="0" maxOccurs="1" />
<xsd:element name="annotations" type="annotations" minOccurs="0" maxOccurs="1" />
</xsd:all>
</xsd:sequence>

<xsd:attribute name="http-method-override" type="xsd:boolean" />
<xsd:attribute name="trusted-proxies" type="xsd:string" />
<xsd:attribute name="ide" type="xsd:string" />
<xsd:attribute name="secret" type="xsd:string" />
<xsd:attribute name="trusted-proxies" type="xsd:string" />
<xsd:attribute name="default-locale" type="xsd:string" />
<xsd:attribute name="test" type="xsd:boolean" />
</xsd:complexType>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

$container->loadFromExtension('framework', array(
'secret' => 's3cr3t',
'trusted_proxies' => array('127.0.0.1', '10.0.0.1'),
));
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
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" trusted-proxies="127.0.0.1, 10.0.0.1" http-method-override="false">
<framework:csrf-protection enabled="true" field-name="_csrf" />
<framework:config secret="s3cr3t" ide="file%%link%%format" default-locale="fr" http-method-override="false">
<framework:trusted-proxy>127.0.0.1</framework:trusted-proxy>
<framework:trusted-proxy>10.0.0.1</framework:trusted-proxy>
<framework:form />
<framework:csrf-protection enabled="true" field-name="_csrf" />
<framework:esi enabled="true" />
<framework:profiler only-exceptions="true" enabled="false" />
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
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" trusted-proxies="127.0.0.1, 10.0.0.1" />
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
framework:
secret: s3cr3t
trusted_proxies: ['127.0.0.1', '10.0.0.1']
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public function testProxies()
$this->assertEquals(array('127.0.0.1', '10.0.0.1'), $container->getParameter('kernel.trusted_proxies'));
}

public function testBcProxies()
{
$container = $this->createContainerFromFile('proxies_bc');

$this->assertEquals(array('127.0.0.1', '10.0.0.1'), $container->getParameter('kernel.trusted_proxies'));
}

public function testHttpMethodOverride()
{
$container = $this->createContainerFromFile('full');
Expand Down
0