Skip to content

Commit 2b8d3b7

Browse files
committed
Merge branch '2.0' into 2.1
* 2.0: [DependencyInjection] fixed composer.json [Form] Updated checks for the ICU version from 4.5+ to 4.7+ due to test failures with ICU 4.6 fixed CS small fix of #5984 when the container param is not set fixed CS Use better default ports in urlRedirectAction Add tests for urlRedirectAction Update src/Symfony/Component/DomCrawler/Tests/FormTest.php Update src/Symfony/Component/DomCrawler/Form.php [Security] remove escape charters from username provided by Digest DigestAuthenticationListener [Security] added test extra for digest authentication fixed CS [Security] Fixed digest authentication [Security] Fixed digest authentication [SecurityBundle] Convert Http method to uppercase in the config Use Norm Data instead of Data Conflicts: src/Symfony/Bridge/Doctrine/Form/EventListener/MergeCollectionListener.php src/Symfony/Bundle/FrameworkBundle/Controller/RedirectController.php src/Symfony/Component/DependencyInjection/composer.json
2 parents dedd1c3 + 474e0dc commit 2b8d3b7

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

DependencyInjection/SecurityExtension.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private function createAuthorization($config, ContainerBuilder $container)
182182
$container,
183183
$access['path'],
184184
$access['host'],
185-
count($access['methods']) === 0 ? null : $access['methods'],
185+
$access['methods'],
186186
$access['ip']
187187
);
188188

@@ -574,7 +574,7 @@ private function createSwitchUserListener($container, $id, $config, $defaultProv
574574
return $switchUserListenerId;
575575
}
576576

577-
private function createRequestMatcher($container, $path = null, $host = null, $methods = null, $ip = null, array $attributes = array())
577+
private function createRequestMatcher($container, $path = null, $host = null, $methods = array(), $ip = null, array $attributes = array())
578578
{
579579
$serialized = serialize(array($path, $host, $methods, $ip, $attributes));
580580
$id = 'security.request_matcher.'.md5($serialized).sha1($serialized);
@@ -583,6 +583,10 @@ private function createRequestMatcher($container, $path = null, $host = null, $m
583583
return $this->requestMatchers[$id];
584584
}
585585

586+
if ($methods) {
587+
$methods = array_map('strtoupper', (array) $methods);
588+
}
589+
586590
// only add arguments that are necessary
587591
$arguments = array($path, $host, $methods, $ip, $attributes);
588592
while (count($arguments) > 0 && !end($arguments)) {

Tests/DependencyInjection/Fixtures/php/container1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
),
6464

6565
'access_control' => array(
66-
array('path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https'),
66+
array('path' => '/blog/524', 'role' => 'ROLE_USER', 'requires_channel' => 'https', 'methods' => array('get', 'POST')),
6767
array('path' => '/blog/.*', 'role' => 'IS_AUTHENTICATED_ANONYMOUSLY'),
6868
),
6969

Tests/DependencyInjection/Fixtures/xml/container1.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<role id="ROLE_SUPER_ADMIN">ROLE_USER,ROLE_ADMIN,ROLE_ALLOWED_TO_SWITCH</role>
5858
<role id="ROLE_REMOTE">ROLE_USER,ROLE_ADMIN</role>
5959

60-
<rule path="/blog/524" role="ROLE_USER" requires-channel="https" />
60+
<rule path="/blog/524" role="ROLE_USER" requires-channel="https" methods="get,POST" />
6161
<rule role='IS_AUTHENTICATED_ANONYMOUSLY' path="/blog/.*" />
6262
</config>
6363
</srv:container>

Tests/DependencyInjection/Fixtures/yml/container1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ security:
5151
ROLE_REMOTE: ROLE_USER,ROLE_ADMIN
5252

5353
access_control:
54-
- { path: /blog/524, role: ROLE_USER, requires_channel: https }
54+
- { path: /blog/524, role: ROLE_USER, requires_channel: https, methods: [get, POST]}
5555
-
5656
path: /blog/.*
5757
role: IS_AUTHENTICATED_ANONYMOUSLY

Tests/DependencyInjection/SecurityExtensionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function testAccess()
102102
$matcherIds = array();
103103
foreach ($rules as $rule) {
104104
list($matcherId, $roles, $channel) = $rule;
105+
$requestMatcher = $container->getDefinition($matcherId);
105106

106107
$this->assertFalse(isset($matcherIds[$matcherId]));
107108
$matcherIds[$matcherId] = true;
@@ -110,9 +111,17 @@ public function testAccess()
110111
if (1 === $i) {
111112
$this->assertEquals(array('ROLE_USER'), $roles);
112113
$this->assertEquals('https', $channel);
114+
$this->assertEquals(
115+
array('/blog/524', null, array('GET', 'POST')),
116+
$requestMatcher->getArguments()
117+
);
113118
} elseif (2 === $i) {
114119
$this->assertEquals(array('IS_AUTHENTICATED_ANONYMOUSLY'), $roles);
115120
$this->assertNull($channel);
121+
$this->assertEquals(
122+
array('/blog/.*'),
123+
$requestMatcher->getArguments()
124+
);
116125
}
117126
}
118127
}

0 commit comments

Comments
 (0)