Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added access control in controllers. An unprivileged user has uncontr… #432

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ php:
# faster builds on new travis setup not using sudo
sudo: false

services:
- mysql

# cache vendor dirs
cache:
directories:
Expand All @@ -28,12 +31,12 @@ install:
codecept build
cd ..

before_script:
before_install:
- mysql --version

# initialize databases
- mysql -e 'CREATE DATABASE mdm_admin_test;';
- mysql -e 'CREATE DATABASE IF NOT EXISTS mdm_admin_test;'

script:
- |
cd tests/web
Expand Down
4 changes: 4 additions & 0 deletions controllers/AssignmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use mdm\admin\components\AccessControl;

/**
* AssignmentController implements the CRUD actions for Assignment model.
Expand Down Expand Up @@ -49,6 +50,9 @@ public function behaviors()
'revoke' => ['post'],
],
],
'access' => [
'class' => AccessControl::class,
],
];
}

Expand Down
13 changes: 13 additions & 0 deletions controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace mdm\admin\controllers;

use Yii;
use mdm\admin\components\AccessControl;

/**
* DefaultController
Expand All @@ -13,6 +14,18 @@
class DefaultController extends \yii\web\Controller
{

/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::class,
],
];
}

/**
* Action index
*/
Expand Down
4 changes: 4 additions & 0 deletions controllers/MenuController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use mdm\admin\components\Helper;
use mdm\admin\components\AccessControl;

/**
* MenuController implements the CRUD actions for Menu model.
Expand All @@ -31,6 +32,9 @@ public function behaviors()
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::class,
],
];
}

Expand Down
13 changes: 13 additions & 0 deletions controllers/PermissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use mdm\admin\components\ItemController;
use yii\rbac\Item;
use mdm\admin\components\AccessControl;

/**
* PermissionController implements the CRUD actions for AuthItem model.
Expand All @@ -14,6 +15,18 @@
class PermissionController extends ItemController
{

/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::class,
],
];
}

/**
* @inheritdoc
*/
Expand Down
13 changes: 13 additions & 0 deletions controllers/RoleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use mdm\admin\components\ItemController;
use yii\rbac\Item;
use mdm\admin\components\AccessControl;

/**
* RoleController implements the CRUD actions for AuthItem model.
Expand All @@ -13,6 +14,18 @@
*/
class RoleController extends ItemController
{
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::class,
],
];
}

/**
* @inheritdoc
*/
Expand Down
4 changes: 4 additions & 0 deletions controllers/RouteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use mdm\admin\models\Route;
use yii\web\Controller;
use yii\filters\VerbFilter;
use mdm\admin\components\AccessControl;

/**
* Description of RuleController
Expand All @@ -27,6 +28,9 @@ public function behaviors()
'refresh' => ['post'],
],
],
'access' => [
'class' => AccessControl::class,
],
];
}
/**
Expand Down
4 changes: 4 additions & 0 deletions controllers/RuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use yii\web\NotFoundHttpException;
use mdm\admin\components\Helper;
use mdm\admin\components\Configs;
use mdm\admin\components\AccessControl;

/**
* Description of RuleController
Expand All @@ -32,6 +33,9 @@ public function behaviors()
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::class,
],
];
}

Expand Down
4 changes: 4 additions & 0 deletions controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use mdm\admin\components\AccessControl;

/**
* User controller
Expand All @@ -40,6 +41,9 @@ public function behaviors()
'activate' => ['post'],
],
],
'access' => [
'class' => AccessControl::class,
],
];
}

Expand Down