GEOFFREY MWANGI GEOFFREY MWANGI -4 years ago 220
PHP Question

Yii2 exempt controller actions from http bearer auth

I have setup my yii2 restful controller but i would like to exempt an action login from httpbearer auth method since no access token is sent during login

This is the way i have setup

class DefaultController extends Controller
{

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

$behaviors['authenticator'] = [
'class' => CompositeAuth::className(),
'authMethods' => [
HttpBasicAuth::className(),
HttpBearerAuth::className(),
QueryParamAuth::className(),
],
];
return $behaviors;

}


public function actionLogin(){
//login logic
}


what do i need to add to the
$behaviours['authenticator']
to exempt Login action from it

Answer Source

Since this is ActionFilter you can add in the behavior's config:

'except' => ['login']
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download