我尝试从文档中找到但没有提到它,并且this answer here它应该可以正常使用REST API。这是我的代码,只要我不通过我的请求发送访问令牌,就会返回状态代码401。
goToBlue
我的查询中 public function behaviors()
{
return [
'compositeAuth' => [
'class' => CompositeAuth::className(),
'authMethods' => [
QueryParamAuth::className(),
],
],
'access' => [
'class' => AccessControl::className(),
'only' => ['index', 'logout'],
'rules' => [
[
'actions' => ['index'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'logout' => ['post'],
],
],
];
}
和actionIndex
都需要访问令牌,但我只想注销来执行此操作。我的控制器扩展了我的基类,扩展了actionLogout