Skip to content

Commit da950d0

Browse files
unkindfabpot
authored andcommitted
Fix typo in the check_path validator
1 parent 2491239 commit da950d0

File tree

5 files changed

+51
-1
lines changed

5 files changed

+51
-1
lines changed

DependencyInjection/MainConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
283283
continue;
284284
}
285285

286-
if (false !== strpos('/', $firewall[$k]['check_path']) && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) {
286+
if (false !== strpos($firewall[$k]['check_path'], '/') && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) {
287287
throw new \LogicException(sprintf('The check_path "%s" for login method "%s" is not matched by the firewall pattern "%s".', $firewall[$k]['check_path'], $k, $firewall['pattern']));
288288
}
289289
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$container->loadFromExtension('security', array(
4+
'providers' => array(
5+
'default' => array('id' => 'foo'),
6+
),
7+
8+
'firewalls' => array(
9+
'some_firewall' => array(
10+
'pattern' => '/secured_area/.*',
11+
'form_login' => array(
12+
'check_path' => '/some_area/login_check',
13+
)
14+
)
15+
)
16+
));
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<srv:container xmlns="http://symfony.com/schema/dic/security"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:srv="http://symfony.com/schema/dic/services"
6+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
7+
8+
<config>
9+
<provider name="default" id="foo" />
10+
11+
<firewall name="some_firewall" pattern="/secured_area/.*">
12+
<form-login check-path="/some_area/login_check" />
13+
</firewall>
14+
</config>
15+
16+
</srv:container>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
security:
2+
providers:
3+
default: { id: foo }
4+
5+
firewalls:
6+
some_firewall:
7+
pattern: /secured_area/.*
8+
form_login:
9+
check_path: /some_area/login_check

Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ public function testCustomAclProvider()
184184
$this->assertEquals('foo', (string) $container->getAlias('security.acl.provider'));
185185
}
186186

187+
/**
188+
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
189+
* @expectedExceptionMessage not matched by the firewall pattern
190+
*/
191+
public function testInvalidCheckPath()
192+
{
193+
$container = $this->getContainer('invalid_check_path');
194+
}
195+
187196
protected function getContainer($file)
188197
{
189198
$container = new ContainerBuilder();

0 commit comments

Comments
 (0)