Skip to content

Commit

Permalink
Move Security.salt value check to WeakPasswordHasher.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Aug 29, 2014
1 parent 7cda879 commit c3038f7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/Auth/WeakPasswordHasher.php
Expand Up @@ -15,6 +15,8 @@
namespace Cake\Auth;

use Cake\Auth\AbstractPasswordHasher;
use Cake\Core\Configure;
use Cake\Utility\Debugger;
use Cake\Utility\Security;

/**
Expand All @@ -34,6 +36,16 @@ class WeakPasswordHasher extends AbstractPasswordHasher {
'hashType' => null
];

/**
* {@inheritDoc}
*/
public function __construct(array $config = []) {
if (Configure::read('debug')) {
Debugger::checkSecurityKeys();
}
parent::config($config);
}

/**
* Generates password hash.
*
Expand Down
6 changes: 0 additions & 6 deletions src/Controller/Component/AuthComponent.php
Expand Up @@ -18,13 +18,11 @@
use Cake\Controller\ComponentRegistry;
use Cake\Controller\Controller;
use Cake\Core\App;
use Cake\Core\Configure;
use Cake\Error;
use Cake\Event\Event;
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\Routing\Router;
use Cake\Utility\Debugger;
use Cake\Utility\Hash;

/**
Expand Down Expand Up @@ -249,10 +247,6 @@ public function __construct(ComponentRegistry $registry, array $config = []) {
$this->response = $controller->response;
$this->_methods = $controller->methods;
$this->session = $controller->request->session();

if (Configure::read('debug')) {
Debugger::checkSecurityKeys();
}
}

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/TestCase/Auth/WeakPasswordHasherTest.php
Expand Up @@ -23,6 +23,17 @@
*/
class WeakPasswordHasherTest extends TestCase {

/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();

Configure::write('Security.salt', 'YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
}

/**
* Tests that any password not produced by WeakPasswordHasher needs
* to be rehashed
Expand Down

0 comments on commit c3038f7

Please sign in to comment.