Cakephp 3 Basic Authentication clarification needed -
according cakephp official document version 3, states configure authcomponent. did added below code appcontroller inside public function initialize
method.
$this->auth->config('authenticate', [ 'basic' => [ 'fields' => ['username' => 'username', 'password' => 'api_key'], 'usermodel' => 'users' ] ]);
then in userstable added below code generate new api key user:
public function beforesave(event $event) { $entity = $event->data['entity']; if ($entity->isnew()) { $entity->api_key = security::hash(text::uuid()); } return true; }
what trying understand how , api keys gets store? when create new user, dont know can api_key
.
do need create column in users table called api_key able store key user? official document doesnt state on how access key , use in basic authentication.
do need create column in users table called api_key able store key user?
of course. makes think stored anywhere magically?
the official document doesnt state on how access key , use in basic authentication.
it does. read first 3 paragraphs. either didn't read or don't know how basic auth works. look here. if client uses basic auth , sends proper information, adapter automatically take care of , user up, done code you've pasted:
$this->auth->config('authenticate', [ 'basic' => [ 'fields' => ['username' => 'username', 'password' => 'api_key'], 'usermodel' => 'users' ] ]);
Comments
Post a Comment