Skip to content

Commit

Permalink
Merge pull request tmaiaroto#15 from mariano/i14
Browse files Browse the repository at this point in the history
Fixing issue where namespace were not taken into account in AuthRbac adapter
  • Loading branch information
tmaiaroto committed Jan 10, 2012
2 parents 24c841f + ce15b7f commit 386d00d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 6 additions & 4 deletions extensions/adapter/security/access/AuthRbac.php
Expand Up @@ -119,9 +119,11 @@ public static function parseMatch($match, $request) {
$params = array();
foreach ((array) $match as $key => $param) {
if (is_string($param)) {
if (preg_match('/^[A-Za-z0-9_\*]+::[A-Za-z0-9_\*]+$/', $param, $regexMatches)) {
list($controller, $action) = explode('::', reset($regexMatches));
$params += compact('controller', 'action');
if (preg_match('/^([A-Za-z0-9_\*\\\]+)::([A-Za-z0-9_\*]+)$/', $param, $regexMatches)) {
$params += array(
'controller' => $regexMatches[1],
'action' => $regexMatches[2]
);
continue;
}
}
Expand Down Expand Up @@ -216,4 +218,4 @@ protected static function _hasRole($requesters, $request, array $options = array
}
}

?>
?>
11 changes: 10 additions & 1 deletion tests/cases/extensions/adapter/security/access/AuthRbacTest.php
Expand Up @@ -226,6 +226,15 @@ public function testParseMatch() {
$test = function() { return false; };
$this->assertFalse(Access::adapter('test_closures')->parseMatch(array($test), $request));
$this->assertFalse(Access::adapter('test_closures')->parseMatch(array(), $request));

$request = new Request(array('params' => array(
'controller' => 'lithium\test\Controller',
'action' => 'index'
)));
$match = 'Controller::*';
$this->assertFalse(Access::adapter('test_check')->parseMatch($match, $request));
$match = 'lithium\test\Controller::*';
$this->assertTrue(Access::adapter('test_check')->parseMatch($match, $request));
}

public function testClosures() {
Expand Down Expand Up @@ -271,4 +280,4 @@ public function testNoRolesConfigured() {
}
}

?>
?>

0 comments on commit 386d00d

Please sign in to comment.