Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f083728

Browse filesBrowse files
bug #27701 [SecurityBundle] Dont throw if "security.http_utils" is not found (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [SecurityBundle] Dont throw if "security.http_utils" is not found | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #27445 | License | MIT | Doc PR | - The comment + test were misleading, the actual important thing is wiring `AddSessionDomainConstraintPass` before removing passes, which is already the case already. Commits ------- db88330 [SecurityBundle] Dont throw if "security.http_utils" is not found
2 parents 8633f64 + db88330 commit f083728
Copy full SHA for f083728

File tree

2 files changed

+1
-15
lines changed
Filter options

2 files changed

+1
-15
lines changed

‎src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSessionDomainConstraintPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/AddSessionDomainConstraintPass.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ class AddSessionDomainConstraintPass implements CompilerPassInterface
2626
*/
2727
public function process(ContainerBuilder $container)
2828
{
29-
if (!$container->hasParameter('session.storage.options')) {
29+
if (!$container->hasParameter('session.storage.options') || !$container->has('security.http_utils')) {
3030
return;
3131
}
3232

3333
$sessionOptions = $container->getParameter('session.storage.options');
3434
$domainRegexp = empty($sessionOptions['cookie_domain']) ? '%s' : sprintf('(?:%%s|(?:.+\.)?%s)', preg_quote(trim($sessionOptions['cookie_domain'], '.')));
3535
$domainRegexp = (empty($sessionOptions['cookie_secure']) ? 'https?://' : 'https://').$domainRegexp;
3636

37-
// if the service doesn't exist, an exception must be thrown - ignoring would put security at risk
3837
$container->findDefinition('security.http_utils')->addArgument(sprintf('{^%s$}i', $domainRegexp));
3938
}
4039
}

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Compiler/AddSessionDomainConstraintPassTest.php
-13Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,6 @@ public function testNoSession()
9696
$this->assertTrue($utils->createRedirectResponse($request, 'http://pirate.com/foo')->isRedirect('http://pirate.com/foo'));
9797
}
9898

99-
/**
100-
* @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
101-
* @expectedExceptionMessage You have requested a non-existent service "security.http_utils".
102-
*/
103-
public function testNoHttpUtils()
104-
{
105-
$container = new ContainerBuilder();
106-
$container->setParameter('session.storage.options', array());
107-
108-
$pass = new AddSessionDomainConstraintPass();
109-
$pass->process($container);
110-
}
111-
11299
private function createContainer($sessionStorageOptions)
113100
{
114101
$container = new ContainerBuilder();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.