AccessControl - deny access to all actions/controllers with stated exceptions

Hi folk,

I am creating a site which will force login for any users visiting the site.

I currently have this configured in the site controller (the currently only controller I have), with the follow config…




'access' => [


	'class' => AccessControl::className(),

	'rules' => [

		[

			'actions' => ['login', 'request-password-reset', 'reset-password'],

			'allow' => TRUE,

		],

		[

			'actions' => ['logout', 'index'], // add all actions to take guest to login page

			'allow' => TRUE,

			'roles' => ['@'],

		],

	],

],



Is there any way I can implement this in Yii\Web\Controller so that every controller/action is blocked for unauthenticated users with the exception of site/login, site/request-password-reset, and site/reset-password?

Thanks in advance.

Your controllers can inherit from defined by you ProtectedController.

In this controller you apply what you need.