title: Denying view site for not logged users in Yii2
body: <p>I have this code in Yii2, where I define users (in models/Users.php):</p>
  
  <pre><code>&lt;?php
  
  namespace app\models;
  
  class User extends \yii\base\Object implements \yii\web\IdentityInterface
  {
      public $id;
      public $username;
      public $password;
      public $authKey;
      public $accessToken;
  
      private static $users = [
          '100' =&gt; [
              'id' =&gt; '100',
              'username' =&gt; 'admin',
              'password' =&gt; 'my_password',
              'authKey' =&gt; 'my_authkey',
              'accessToken' =&gt; 'my_accessyoken',
  </code></pre>
  
  <p>And this is my code in SiteController.php:</p>
  
  <pre><code>&lt;?php
  
  namespace app\controllers;
  
  use Yii;
  use yii\filters\AccessControl;
  use yii\web\Controller;
  use yii\filters\VerbFilter;
  use app\models\LoginForm;
  use app\models\ContactForm;
  
  class SiteController extends Controller
  {
      public function behaviors()
      {
          return [
              'access' =&gt; [
                  'class' =&gt; AccessControl::className(),
                  'only' =&gt; ['logout'],
                  'rules' =&gt; [
                      [
                          'actions' =&gt; ['logout'],
                          'allow' =&gt; true,
                          'roles' =&gt; ['@'],
                      ],
                  ],
              ],
              'verbs' =&gt; [
                  'class' =&gt; VerbFilter::className(),
                  'actions' =&gt; [
                      'logout' =&gt; ['post'],
                  ],
              ],
          ];
      }
  </code></pre>
  
  <p>The problem is:</p>
  
  <p>1) Right now, visitors can view any page in my website without being logged. Which is the easiest way to force users to be logged in to see any pages?</p>
  
  <p>2) How can I let only specific users view some private pages? </p>
  
  <p>I've already tried some options with no luck...</p>
  
  <p>Thanks!</p>