Access Control Filter实现是否适用于REST API?

时间:2015-09-28 01:20:57

标签: yii2 yii2-user

我尝试从文档中找到但没有提到它,并且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

0 个答案:

没有答案