Cakephp 3.1の認証コンポーネントを使用してダイジェスト認証を作成しようとしていますが、問題が発生しました。私は以下のコードを使用しています。私は、以前のポップアップで正しいユーザー名とパスワードを入力した直後にポップアップするHTTP認証ポップアップを持っています。私がキャンセルを押すと、Cake \ Auth \ BasicAuthenticate-> unauthenticatedと表示されます。CakePHP 3のダイジェスト認証
私が間違っていることを教えてもらえますか?私は、デバッグ・キット環境をチェックインすると、クライアントの一部
public function digest(){
$http = new Client();
$response = $http->get('http://localhost/project/api/v1/users/view/22', [], [
'auth' => [
'type' => 'digest',
'username' => 'Digest',
'password' => 'my_password',
]
]);
でAppController.php
$this->loadComponent('Auth', [
'authorize' => 'Controller',
'loginRedirect' => [
'controller' => 'Users',
'action' => 'index'
],
'authenticate' => [
'Digest' => [
'fields' => ['username' => 'username', 'password' => 'digest_hash'],
'userModel' => 'Users',
],
],
'loginAction' => [
'controller' => 'Users',
'action' => 'login',
],
'storage' => 'Memory',
'unauthorizedRedirect' => false
]);
UserTable.php
public function beforeSave(Event $event)
{
$entity = $event->data['entity'];
// Make a password for digest auth.
$entity->digest_hash = DigestAuthenticate::password(
$entity->username,
$entity->plain_password,
env('SCRIPT_NAME')
);
return true;
}
、私はこれを持っている:
PHP_AUTH_DIGEST username="Digest", realm="localhost", nonce="57ac3609a5b79", uri="/project/api/v1/users/view/22", response="af0e1fe455aa7f1475df715ef5231b56", opaque="421aa90e079fa326b6494f812ad13e79", qop=auth, nc=00000001, cnonce="0bb461453700ebc1"