Yii access — do I have to specify the list of action games in 'Only'?

Try the access control (filter). There is a Blog Controller and his action: index add. When that's code for some reason in any case (and blog/index and blog/add) throws login although the list is only action add:
public function behaviors()
{
 return [
 'access' => [
 'class' => AccessControl::className(),
 'rules' => [
[
 'actions' => ['add'],
 'allow' => true,
 'roles' => ['admin'],
],
],
]
];
 }

And if you add Only that already index are normally available, and add there:
public function behaviors()
{
 return [
 'access' => [
 'class' => AccessControl::className(),
 'only' => ['add'],
 'rules' => [
[
 'actions' => ['add'],
 'allow' => true,
 'roles' => ['admin'],
],
],
]
];
 }

It turns out the Only string you should always in any case to prescribe? Although many of the code examples in this Only no. An example of where no rules work in humans:
5de03022dab94456591589.png
April 2nd 20 at 16:46
1 answer
April 2nd 20 at 16:48
You can change the order of application of rules, with the "everything not allowed is forbidden", to "everything that is not forbidden - is allowed". View Doc to AccessControl

Find more questions by tags Yii