Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[SecurityBundle] Fix typo in the check_path validator #8782

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
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 @@ -283,7 +283,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
continue;
}

if (false !== strpos('/', $firewall[$k]['check_path']) && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) {
if (false !== strpos($firewall[$k]['check_path'], '/') && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) {
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']));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$container->loadFromExtension('security', array(
'providers' => array(
'default' => array('id' => 'foo'),
),

'firewalls' => array(
'some_firewall' => array(
'pattern' => '/secured_area/.*',
'form_login' => array(
'check_path' => '/some_area/login_check',
)
)
)
));
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>

<srv:container xmlns="http://symfony.com/schema/dic/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:srv="http://symfony.com/schema/dic/services"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<config>
<provider name="default" id="foo" />

<firewall name="some_firewall" pattern="/secured_area/.*">
<form-login check-path="/some_area/login_check" />
</firewall>
</config>

</srv:container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
security:
providers:
default: { id: foo }

firewalls:
some_firewall:
pattern: /secured_area/.*
form_login:
check_path: /some_area/login_check
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ public function testCustomAclProvider()
$this->assertEquals('foo', (string) $container->getAlias('security.acl.provider'));
}

/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage not matched by the firewall pattern
*/
public function testInvalidCheckPath()
{
$container = $this->getContainer('invalid_check_path');
}

protected function getContainer($file)
{
$container = new ContainerBuilder();
Expand Down