Skip to content

Commit

Permalink
Merge pull request #3445 from renan/2.5-authenticate
Browse files Browse the repository at this point in the history
2.5 Allowing same Authenticate object to be setup with different settings
  • Loading branch information
markstory committed May 6, 2014
2 parents 23519e1 + 87683b1 commit 0e37f1b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Cake/Controller/Component/AuthComponent.php
Expand Up @@ -776,6 +776,10 @@ public function constructAuthenticate() {
unset($config[AuthComponent::ALL]);
}
foreach ($config as $class => $settings) {
if (!empty($settings['className'])) {
$class = $settings['className'];
unset($settings['className']);
}
list($plugin, $class) = pluginSplit($class, true);
$className = $class . 'Authenticate';
App::uses($className, $plugin . 'Controller/Component/Auth');
Expand Down
21 changes: 21 additions & 0 deletions lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php
Expand Up @@ -590,6 +590,27 @@ public function testAllConfigWithAuthenticate() {
$this->assertEquals('AuthUser', $result->settings['userModel']);
}

/**
* test defining the same Authenticate object but with different password hashers
*
* @return void
*/
public function testSameAuthenticateWithDifferentHashers() {
$this->Controller->Auth->authenticate = array(
'FormSimple' => array('className' => 'Form', 'passwordHasher' => 'Simple'),
'FormBlowfish' => array('className' => 'Form', 'passwordHasher' => 'Blowfish'),
);

$objects = $this->Controller->Auth->constructAuthenticate();
$this->assertEquals(2, count($objects));

$this->assertInstanceOf('FormAuthenticate', $objects[0]);
$this->assertInstanceOf('FormAuthenticate', $objects[1]);

$this->assertInstanceOf('SimplePasswordHasher', $objects[0]->passwordHasher());
$this->assertInstanceOf('BlowfishPasswordHasher', $objects[1]->passwordHasher());
}

/**
* Tests that deny always takes precedence over allow
*
Expand Down

0 comments on commit 0e37f1b

Please sign in to comment.