Skip to content

Commit

Permalink
Fixing issue where changing the case for an action in the url would a…
Browse files Browse the repository at this point in the history
…llow the action in the AuthComponent making it accessible to not-logged in users
  • Loading branch information
lorenzo committed Nov 28, 2011
1 parent 2bffd4c commit f6534d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Cake/Controller/Component/AuthComponent.php
Expand Up @@ -268,8 +268,8 @@ public function startup($controller) {
return true; return true;
} }


$methods = array_flip($controller->methods); $methods = array_flip(array_map('strtolower', $controller->methods));
$action = $controller->request->params['action']; $action = strtolower($controller->request->params['action']);


$isMissingAction = ( $isMissingAction = (
$controller->scaffold === false && $controller->scaffold === false &&
Expand All @@ -296,7 +296,7 @@ public function startup($controller) {
$allowedActions = $this->allowedActions; $allowedActions = $this->allowedActions;
$isAllowed = ( $isAllowed = (
$this->allowedActions == array('*') || $this->allowedActions == array('*') ||
in_array($action, $allowedActions) in_array($action, array_map('strtolower', $allowedActions))
); );


if ($loginAction != $url && $isAllowed) { if ($loginAction != $url && $isAllowed) {
Expand Down
5 changes: 5 additions & 0 deletions lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php
Expand Up @@ -671,6 +671,11 @@ public function testDenyWithCamelCaseMethods() {
$this->Controller->request->query['url'] = Router::normalize($url); $this->Controller->request->query['url'] = Router::normalize($url);


$this->assertFalse($this->Controller->Auth->startup($this->Controller)); $this->assertFalse($this->Controller->Auth->startup($this->Controller));

$url = '/auth_test/CamelCase';
$this->Controller->request->addParams(Router::parse($url));
$this->Controller->request->query['url'] = Router::normalize($url);
$this->assertFalse($this->Controller->Auth->startup($this->Controller));
} }


/** /**
Expand Down

0 comments on commit f6534d2

Please sign in to comment.