mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding ability set component configuration from component settings for SecurityComponent.
This commit is contained in:
parent
3a6b29d042
commit
e45fcf4337
2 changed files with 39 additions and 1 deletions
|
@ -168,10 +168,23 @@ class SecurityComponent extends Object {
|
|||
*/
|
||||
var $_action = null;
|
||||
|
||||
/**
|
||||
* Initialize the SecurityComponent
|
||||
*
|
||||
* @param object $controller Controller instance for the request
|
||||
* @param array $settings Settings to set to the component
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function initialize(&$controller, $settings = array()) {
|
||||
$this->_set($settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Component startup. All security checking happens here.
|
||||
*
|
||||
* @param object $controller Instantiating controller
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function startup(&$controller) {
|
||||
|
@ -342,7 +355,7 @@ class SecurityComponent extends Object {
|
|||
if (strtolower($options['type']) == 'digest') {
|
||||
$out[] = 'qop="auth"';
|
||||
$out[] = 'nonce="' . uniqid("") . '"';
|
||||
$out[] = 'opaque="' . md5($options['realm']).'"';
|
||||
$out[] = 'opaque="' . md5($options['realm']) . '"';
|
||||
}
|
||||
|
||||
return $auth . ' ' . implode(',', $out);
|
||||
|
|
|
@ -166,6 +166,31 @@ class SecurityComponentTest extends CakeTestCase {
|
|||
unset($this->Controller);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that initalize can set properties.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testInitialize() {
|
||||
$settings = array(
|
||||
'requirePost' => array('edit', 'update'),
|
||||
'requireSecure' => array('update_account'),
|
||||
'requireGet' => array('index'),
|
||||
'validatePost' => false,
|
||||
'loginUsers' => array(
|
||||
'mark' => 'password'
|
||||
),
|
||||
'requireLogin' => array('login'),
|
||||
);
|
||||
$this->Controller->Security->initialize($this->Controller, $settings);
|
||||
$this->assertEqual($this->Controller->Security->requirePost, $settings['requirePost']);
|
||||
$this->assertEqual($this->Controller->Security->requireSecure, $settings['requireSecure']);
|
||||
$this->assertEqual($this->Controller->Security->requireGet, $settings['requireGet']);
|
||||
$this->assertEqual($this->Controller->Security->validatePost, $settings['validatePost']);
|
||||
$this->assertEqual($this->Controller->Security->loginUsers, $settings['loginUsers']);
|
||||
$this->assertEqual($this->Controller->Security->requireLogin, $settings['requireLogin']);
|
||||
}
|
||||
|
||||
/**
|
||||
* testStartup method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue