Ich habe successifully Setup ein Rest api, die successifully einen Benutzer korrekt identifiziert, aber die Zugriffskontrolle Filter immer nicht zurückkehrt, dieYii2 Rest api Verhalten
public function behaviors()
{
$behaviors = parent::behaviors();
$auth = $behaviors['authenticator'] = [
'class' => HttpBearerAuth::className(),
'only' => ['can-access'],
];
$behaviors['access'] = [ //This fails
'class' => AccessControl::className(),
'only' => ['can-access'],
'rules' => [
[
'actions' => ['can-access'],
'allow' => true,
'roles' => ['@'],
],
],
];
$behaviors['contentNegotiator'] = [
'class' => ContentNegotiator::className(),
'formats' => [
'application/json' => Response::FORMAT_JSON,
],
];
];
$behaviors['authenticator']['except'] = ['options'];
return $behaviors;
}
A die oben genannten Zugriffskontrolle Filter immer
nicht erforderlich anmeldenAber nachdem sie zu entfernen und dann in der Steuerung als
rewrtingpublic function actionCanAccess()
{
echo $access = Yii::$app->user->isGuest; //this returns false
}
Was ist der Grund, warum Filter das Verhalten Zugriffskontrolle könnte versagt und doch beim Einchecken des Controllers funktioniert es wie erwartet