Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
71 additions
and
39 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
cake/libs/controller/components/auth/base_authenticate.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/** | ||
* PHP 5 | ||
* | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
App::import('Core', 'Security'); | ||
|
||
/** | ||
* Base Authentication class with common methods and properties. | ||
* | ||
* @package cake.libs.controller.components.auth | ||
*/ | ||
abstract class BaseAuthenticate { | ||
|
||
/** | ||
* Settings for this object. | ||
* | ||
* - `fields` The fields to use to identify a user by. | ||
* - `userModel` The model name of the User, defaults to User. | ||
* - `scope` Additional conditions to use when looking up and authenticating users, | ||
* i.e. `array('User.is_active' => 1).` | ||
* | ||
* @var array | ||
*/ | ||
public $settings = array( | ||
'fields' => array( | ||
'username' => 'username', | ||
'password' => 'password' | ||
), | ||
'userModel' => 'User', | ||
'scope' => array() | ||
); | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param array $settings Array of settings to use. | ||
*/ | ||
public function __construct($settings) { | ||
$this->settings = Set::merge($this->settings, $settings); | ||
} | ||
|
||
/** | ||
* Hash the supplied password using the configured hashing method. | ||
* | ||
* @param string $password The password to hash. | ||
* @return string Hashed string | ||
*/ | ||
public function hash($password) { | ||
return Security::hash($password, null, true); | ||
} | ||
|
||
/** | ||
* Authenticate a user based on the request information. | ||
* | ||
* @param CakeRequest $request Request to get authentication information from. | ||
* @return mixed Either false on failure, or an array of user data on success. | ||
*/ | ||
abstract public function authenticate(CakeRequest $request); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters