cakePHP2.0でAuthコンポーネントを使おうとしてみたのだが、認証の際、パスワードを暗号化するのが前提となっている模様。
今回やるのは必要ないので、なんとかはずす方法ないかなと探ってみたが
[CakePHP]AuthComponentのパスワード暗号化を無効にする方法
この辺、1.2や1.3の情報らしく、同じようにやってもうまくいかない。2.0でコンポーネントのコードが大分変わった模様。
で、よくよくコード見てみると、パスワードの暗号化は、
BaseAuthenticateクラスの
/**
* Hash the plain text password so that it matches the hashed/encrytped password
* in the datasource.
*
* @param string $password The plain text password.
* @return string The hashed form of the password.
*/
protected function _password($password) {
return Security::hash($password, null, true);
}
この部分で行ってる模様。ここをreturn $passwordとするようにすれば、OKっぽかったので、
app/Controller/Component/Auth
に以下のようなクラスを作成して
App::uses('FormAuthenticate', 'Controller/Component/Auth');
class MyFormAuthenticate extends FormAuthenticate {
protected function _password($password){
return $password;
}
}
呼び出し側で
public $components = array('Auth'=>
array('authenticate'=>array('MyForm'));
こんな感じに記述するとうまく動いた。