10000 [FrameworkBundle] Force users to set "kernel.secret" to something dif… · symfony/symfony@f5290b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit f5290b9

Browse files
committed
[FrameworkBundle] Force users to set "kernel.secret" to something different than default "ThisTokenIsNotSoSecretChangeIt"
1 parent dc4a10e commit f5290b9

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ public function getConfigTreeBuilder()
5151
})
5252
->end()
5353
->end()
54-
->scalarNode('secret')->end()
54+
->scalarNode('secret')
55+
->validate()
56+
->ifTrue(function($v) { return 'ThisTokenIsNotSoSecretChangeIt' === $v; })
57+
->thenInvalid('The "secret" parameter is currently set to the default. It is really important that you change it to something unique.')
58+
->end()
59+
->end()
5560
->scalarNode('trust_proxy_headers')->defaultFalse()->end() // @deprecated, to be removed in 2.3
5661
->arrayNode('trusted_proxies')
5762
->beforeNormalization()

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testInvalidTypeTrustedProxies()
6666
{
6767
$processor = new Processor();
6868
$configuration = new Configuration(array());
69-
$config = $processor->processConfiguration($configuration, array(array('secret' => 's3cr3t', 'trusted_proxies' => 'Not an IP address')));
69+
$processor->processConfiguration($configuration, array(array('secret' => 's3cr3t', 'trusted_proxies' => 'Not an IP address')));
7070
}
7171

7272
/**
@@ -76,6 +76,16 @@ public function testInvalidValueTrustedProxies()
7676
{
7777
$processor = new Processor();
7878
$configuration = new Configuration(array());
79-
$config = $processor->processConfiguration($configuration, array(array('secret' => 's3cr3t', 'trusted_proxies' => array('Not an IP address'))));
79+
$processor->processConfiguration($configuration, array(array('secret' => 's3cr3t', 'trusted_proxies' => array('Not an IP address'))));
80+
}
81+
82+
/**
83+
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
84+
*/
85+
public function testDefaultSecretIsUsed()
86+
{
87+
$processor = new Processor();
88+
$configuration = new Configuration(array());
89+
$processor->processConfiguration($configuration, array(array('secret' => 'ThisTokenIsNotSoSecretChangeIt')));
8090
}
8191
}

0 commit comments

Comments
 (0)
0