public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['authenticator'] = [
'class' => HttpBasicAuth::className(),
'auth' => function ($username, $password)
{
;
if ($user=User::find()->where(["username"=>$username])->one() and !empty($password) and $user->validatePassword($password)) {
return $user;
}
else {
return null;
}
},
];
return $behaviors;
}