Make it possible to match the request based on HTTP methods in the firewall configuration
This commit is contained in:
parent
f0c0c2c99d
commit
a8e9ed5cf1
@ -201,6 +201,10 @@ class MainConfiguration implements ConfigurationInterface
|
|||||||
$firewallNodeBuilder
|
$firewallNodeBuilder
|
||||||
->scalarNode('pattern')->end()
|
->scalarNode('pattern')->end()
|
||||||
->scalarNode('host')->end()
|
->scalarNode('host')->end()
|
||||||
|
->arrayNode('methods')
|
||||||
|
->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end()
|
||||||
|
->prototype('scalar')->end()
|
||||||
|
->end()
|
||||||
->booleanNode('security')->defaultTrue()->end()
|
->booleanNode('security')->defaultTrue()->end()
|
||||||
->scalarNode('request_matcher')->end()
|
->scalarNode('request_matcher')->end()
|
||||||
->scalarNode('access_denied_url')->end()
|
->scalarNode('access_denied_url')->end()
|
||||||
|
@ -254,7 +254,8 @@ class SecurityExtension extends Extension
|
|||||||
} elseif (isset($firewall['pattern']) || isset($firewall['host'])) {
|
} elseif (isset($firewall['pattern']) || isset($firewall['host'])) {
|
||||||
$pattern = isset($firewall['pattern']) ? $firewall['pattern'] : null;
|
$pattern = isset($firewall['pattern']) ? $firewall['pattern'] : null;
|
||||||
$host = isset($firewall['host']) ? $firewall['host'] : null;
|
$host = isset($firewall['host']) ? $firewall['host'] : null;
|
||||||
$matcher = $this->createRequestMatcher($container, $pattern, $host);
|
$methods = isset($firewall['methods']) ? $firewall['methods'] : array();
|
||||||
|
$matcher = $this->createRequestMatcher($container, $pattern, $host, $methods);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Security disabled?
|
// Security disabled?
|
||||||
|
@ -117,6 +117,7 @@ abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(
|
array(
|
||||||
'/test',
|
'/test',
|
||||||
'foo\\.example\\.org',
|
'foo\\.example\\.org',
|
||||||
|
array('GET', 'POST'),
|
||||||
),
|
),
|
||||||
), $matchers);
|
), $matchers);
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,7 @@ $container->loadFromExtension('security', array(
|
|||||||
'host' => array(
|
'host' => array(
|
||||||
'pattern' => '/test',
|
'pattern' => '/test',
|
||||||
'host' => 'foo\\.example\\.org',
|
'host' => 'foo\\.example\\.org',
|
||||||
|
'methods' => array('GET', 'POST'),
|
||||||
'anonymous' => true,
|
'anonymous' => true,
|
||||||
'http_basic' => true,
|
'http_basic' => true,
|
||||||
),
|
),
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
<logout />
|
<logout />
|
||||||
</firewall>
|
</firewall>
|
||||||
|
|
||||||
<firewall name="host" pattern="/test" host="foo\.example\.org">
|
<firewall name="host" pattern="/test" host="foo\.example\.org" methods="GET,POST">
|
||||||
<anonymous />
|
<anonymous />
|
||||||
<http-basic />
|
<http-basic />
|
||||||
</firewall>
|
</firewall>
|
||||||
|
@ -56,6 +56,7 @@ security:
|
|||||||
host:
|
host:
|
||||||
pattern: /test
|
pattern: /test
|
||||||
host: foo\.example\.org
|
host: foo\.example\.org
|
||||||
|
methods: [GET,POST]
|
||||||
anonymous: true
|
anonymous: true
|
||||||
http_basic: true
|
http_basic: true
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user