admin管理员组

文章数量:1122832

Yii2

When i put var_dump in findIdentityByAccessToken method is not called

Why is findIdentityByAccessToken method not called? Why is there no user verification?

curl -H "Authorization: Bearer tok" -H "Accept: application/json" https://....plcapp/cooper/listcontr

I get error 403.

<?php

namespace common\modules\plcapp\controllers;

use Yii;
use yii\helpers\ArrayHelper;
use yii\filters\auth\HttpBearerAuth;
use yii\web\Response;
use yii\filters\AccessControl;
//use yii\rest\ActiveController;
use yii\web\Controller;
//use yii\filters\VerbFilter;
//use yii\web\NotFoundHttpException;
use common\models\Access;
use common\models\DevContr;
use common\models\User;
use yii\web\IdentityInterface;

class CooperController extends Controller
{
    //public $modelClass = 'common\models\User';

    public function behaviors()
    {
        $behaviors = parent::behaviors();

        $behaviors['authenticator'] = [
            'class' => HttpBearerAuth::class,
        ];

        return $behaviors;
    }


    public function actionConect()
    {
        return $this->render('index');
    }

    public function actionListcontr()
    {

        Yii::$app->response->format = Response::FORMAT_JSON;

            return [
                'success' => true,
            ];

    }
}

LGpt4 chat can't say anything useful

本文标签: yii2When using HttpHeaderAuththe findIdentityByAccessToken method is not calledStack Overflow