Код: Выделить всё
class UserController extends \yii\rest\Controller
{
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['authenticator'] = [
'class' => HttpBearerAuth::className(),
];
$behaviors['access'] = [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => ['index'],
'allow' => true,
'roles' => ['*'],
],
],
];
return $behaviors;
}
public function actionIndex()
{
return 'index';
}
}
Стоит убрать authenticator из behaviors, получаю доступ. Почему?{
"name": "Unauthorized",
"message": "You are requesting with an invalid credential.",
"code": 0,
"status": 401
}