Skip to content

Commit ce5363a

Browse files
committed
feature #15372 [FrameworkBundle] Change the default value of cookie_httponly (jderusse)
This PR was merged into the 2.8 branch. Discussion ---------- [FrameworkBundle] Change the default value of cookie_httponly | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15303 | License | MIT | Doc PR | symfony/symfony-docs#5561 Commits ------- a7bef1e Change the default value of cookie_httponly to fix #15303
2 parents 251314e + a7bef1e commit ce5363a

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

UPGRADE-2.8.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@ Form
88
option together with the `Valid` constraint instead. Contrary to
99
"cascade_validation", "constraints" must be set on the respective child forms,
1010
not the parent form.
11-
11+
1212
Before:
13-
13+
1414
```php
1515
$form = $this->createForm('form', $article, array('cascade_validation' => true))
1616
->add('author', new AuthorType())
1717
->getForm();
1818
```
19-
19+
2020
After:
21-
21+
2222
```php
2323
use Symfony\Component\Validator\Constraints\Valid;
24-
24+
2525
$form = $this->createForm('form', $article)
2626
->add('author', new AuthorType(), array(
2727
'constraints' => new Valid(),
2828
))
2929
->getForm();
3030
```
31-
31+
3232
Alternatively, you can set the `Valid` constraint in the model itself:
33-
33+
3434
```php
3535
use Symfony\Component\Validator\Constraints as Assert;
36-
36+
3737
class Article
3838
{
3939
/**
@@ -197,3 +197,17 @@ to the toolbar templates:
197197
{% endset %}
198198
{% endblock %}
199199
```
200+
201+
FrameworkBundle
202+
---------------
203+
204+
* The default value of the parameter `session`.`cookie_httponly` is now `true`.
205+
It prevents scripting languages, such as JavaScript to access the cookie,
206+
which help to reduce identity theft through XSS attacks. If your
207+
application needs to access the session cookie, override this parameter:
208+
209+
```yaml
210+
framework:
211+
session:
212+
cookie_httponly: false
213+
```

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
340340
->scalarNode('cookie_path')->end()
341341
->scalarNode('cookie_domain')->end()
342342
->booleanNode('cookie_secure')->end()
343-
->booleanNode('cookie_httponly')->end()
343+
->booleanNode('cookie_httponly')->defaultTrue()->end()
344344
->scalarNode('gc_divisor')->end()
345345
->scalarNode('gc_probability')->defaultValue(1)->end()
346346
->scalarNode('gc_maxlifetime')->end()

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
'cookie_path' => '/',
3333
'cookie_domain' => 'example.com',
3434
'cookie_secure' => true,
35-
'cookie_httponly' => true,
35+
'cookie_httponly' => false,
3636
'gc_maxlifetime' => 90000,
3737
'gc_divisor' => 108,
3838
'gc_probability' => 1,

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<framework:esi enabled="true" />
1515
<framework:profiler only-exceptions="true" enabled="false" />
1616
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
17-
<framework:session gc-maxlifetime="90000" gc-probability="1" gc-divisor="108" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" save-path="/path/to/sessions" />
17+
<framework:session gc-maxlifetime="90000" gc-probability="1" gc-divisor="108" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="false" save-path="/path/to/sessions" />
1818
<framework:request>
1919
<framework:format name="csv">
2020
<framework:mime-type>text/csv</framework:mime-type>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ framework:
2424
cookie_path: /
2525
cookie_domain: example.com
2626
cookie_secure: true
27-
cookie_httponly: true
27+
cookie_httponly: false
2828
gc_probability: 1
2929
gc_divisor: 108
3030
gc_maxlifetime: 90000

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function testSession()
149149
$this->assertEquals('/', $options['cookie_path']);
150150
$this->assertEquals('example.com', $options['cookie_domain']);
151151
$this->assertTrue($options['cookie_secure']);
152-
$this->assertTrue($options['cookie_httponly']);
152+
$this->assertFalse($options['cookie_httponly']);
153153
$this->assertEquals(108, $options['gc_divisor']);
154154
$this->assertEquals(1, $options['gc_probability']);
155155
$this->assertEquals(90000, $options['gc_maxlifetime']);

0 commit comments

Comments
 (0)