Giter Club home page Giter Club logo

yii2-admin's Introduction

RBAC Manager for Yii 2

GUI manager for RBAC (Role Base Access Control) Yii2. Easy to manage authorization of user ๐Ÿ˜„.

Latest Unstable Version Total Downloads Daily Downloads License Reference Status Build Status Dependency Status Scrutinizer Code Quality Code Climate

Documentation

Important: If you install version 3.x, please see this readme.

Installation

Install With Composer

The preferred way to install this extension is through composer.

Either run

php composer.phar require mdmsoft/yii2-admin "~1.0"
or
php composer.phar require mdmsoft/yii2-admin "~2.0"

or for the dev-master

php composer.phar require mdmsoft/yii2-admin "2.x-dev"

Or, you may add

"mdmsoft/yii2-admin": "~2.0"

to the require section of your composer.json file and execute php composer.phar update.

Install From the Archive

Download the latest release from here releases, then extract it to your project. In your application config, add the path alias for this extension.

return [
    ...
    'aliases' => [
        '@mdm/admin' => 'path/to/your/extracted',
        // for example: '@mdm/admin' => '@app/extensions/mdm/yii2-admin-2.0.0',
        ...
    ]
];

More...

screenshots

yii2-admin's People

Contributors

apexwire avatar cgernert avatar firefox747 avatar hscstudio avatar iforme avatar itzen avatar jafaripur avatar kongoon avatar m0zart89 avatar marciocamello avatar marsuboss avatar mdmunir avatar noname007 avatar pgyf avatar pigochu avatar qwekaa avatar re3lex avatar realtebo avatar rubenheymans avatar shoxabbos avatar sihar avatar soap avatar softark avatar songlipeng2003 avatar sosojni avatar taufikherjanto avatar vilkh3m avatar wa1kb0y avatar wilwade avatar zakdma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-admin's Issues

GroupDependency changed to TagDependency in Yii2 core

Hi

Just wanted to point out that GroupDependency has now changed to TagDependency in Yii2 core, so some errors have crept in here.

As far as I can tell, the files affected are DbManager, MenuHelper, and RouteController.

Module fails to install

Hi,

This module does not work. I follow your instructions and it fails to install.

./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package mdmsoft/yii2-admin could not be found in any version, there may be a typo in the package name.

Potential causes:

Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, reverting ./composer.json to its original content.

Undefined variable: cache

Hi!,
When pass $callback = null and $refresh = true on AccessHelper::getAssignedMenu, This cause Exception. This is because the conditional not evaluate the second sentence

if ($refresh || ($cache = Yii::$app->getCache()) === null || ($result = $cache->get($key)) === false) {
...

and $cache variable is not declared.
Thks.

problem on composer

mbp-di-egidio:htdocs nuovoutente$ php composer.phar require mdmsoft/yii2-admin "*"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package mdmsoft/yii2-admin could not be found in any version, there may be a typo in the package name.

Potential causes:

Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, reverting ./composer.json to its original content.

How to rename "menu" table?

Hello,
I'm using postgres and want to put "menu" table to my own schema (not in "public"). How can I rename table name?

i'm using f3b5717.

Thank you.

`assigment` route

After last composer update I noticed that assigment route name was changed to assignment.
I know there was a typo in the route name but you have to be careful because it is possible that there are other links in the website created by developers or also admin users could write the route directly on the browser and this will lead to a 404 error page. I suggest that you keep both routes (a redirection perhaps?).

ERROR : Create Menu

backend/web/index.php?r=admin/menu/create

Create Root(parent is null) Menu

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'parent' cannot be null
The SQL being executed was: INSERT INTO `yii_menu` (`name`, `route`, `order`, `data`, `parent`) VALUES ('Logout', '/site/logout', 1, 'data', NULL)

or parent is 0 : Menu "0" not found.

Yii2-jui required

I think you should add "yiisoft/yii2-jui": "*" to the 'required' array on composer.json

bizz rule

Hi ,
can you plz show me an example to bizzrule?

Can a user have multiple role?

Hello,there.
Thanks for your work.

I know a role maight has other roles or permission, but can a user have many roles? Is there a little confused? in your yii2-admin module, we can assign many roles to a user.
I readed this article from Yii2 reop, there never describe "a user can has multiple roles".

Call to a member function checkAccess() on a non-object

I installed admin on the advanced template and got this error:

PHP Fatal Error โ€“ yii\base\ErrorException
Call to a member function checkAccess() on a non-object

1. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\web\User.php at line 597
592593594595596597598599600601602

    {
        $auth = Yii::$app->getAuthManager();
        if ($allowCaching && empty($params) && isset($this->_access[$operation])) {
            return $this->_access[$operation];
        }
        $access = $auth->checkAccess($this->getId(), $operation, $params);
        if ($allowCaching && empty($params)) {
            $this->_access[$operation] = $access;
        }

        return $access;

2. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\Component.php โ€“ mdm\admin\components\AccessControl::beforeAction() at line 540
3. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\Component.php โ€“ call_user_func() at line 540
4. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\Controller.php โ€“ yii\base\Component::trigger() at line 125
5. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\Module.php โ€“ yii\base\Controller::runAction() at line 434
6. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\web\Application.php โ€“ yii\base\Module::runAction() at line 84
7. in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\base\Application.php โ€“ yii\web\Application::handleRequest() at line 313
8. in C:\wamp\www\infoweb-cms\backend\web\index.php โ€“ yii\base\Application::run() at line 17
121314151617

    require(__DIR__ . '/../config/main.php'),
    require(__DIR__ . '/../config/main-local.php')
);

$application = new yii\web\Application($config);
$application->run();

2014-03-25, 12:04:04

Apache/2.4.4 (Win32)

Yii Framework/2.0.0-dev

PHP 5.4.16

This is my conmmon/config/main.php

return [ 'vendorPath' => dirname(dirname(**DIR**)) . '/vendor', 'extensions' => require(**DIR** . '/../../vendor/yiisoft/extensions.php'), 'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', 'authManager' => [ 'class' => 'yii\rbac\PhpManager', // or use 'yii\rbac\DbManager' ] ], ], 'aliases' => [ '@root' => realpath(**DIR** . '/../..'), ], 'modules' => [ 'packaii' => [ 'class' => 'schmunk42\packaii\Module', 'gitHubUsername' => 'hashie5', 'gitHubPassword' => 'vugames5', ], 'admin' => 'mdm\admin\Module', ], 'as access' => 'mdm\admin\components\AccessControl', ];

Default layout missing

I tried your module in my application. So installed and integrated your adminmodule as you describe in your readme.md. I got the assign list first but there was no menue rsp. it showed my standard menue.

After checking your code I saw that you use nested layouts but the sub layout wasn't defined somewhere. After defining the property layoutin module config section it worked.

I propose that you define a default layout in your Module.php like public $layout = '@mdm/admin/views/layouts/left-menu.php'; and add in your readme.md the other two options (left, right, top). This would save time for a new developper if he uses your module first time.

Migrations & Error in Call to undefined method app\models\User::find()

Hi..

I am not able to create the tables.

  • How do I create tables? .. In the 'migration' folder only has a migrate.
  • And the name of 'migration' folder should not be plural?

php yii migrate/up --migrationPath=@vendor/mdmsoft/yii2-admin/migration
Only migrate 'create_menu_table'

..And..

captura de tela 2014-06-26 as 22 16 45

error

Comprehension questions for route and menue

RBAC knows assignment, roles und permission with hierarchal links (item_child).

I don't understand your page route and menueexactly.

  • Is it same as a permission instaed a name it's an route?
  • Means route /xy/* equal to index?
  • Does menue work only if I use route instead of permission name?
  • Is there a difference between permission and route in the access filter handling?
  • Is it possible to have several menues like "Main menue", "Detail Menu 1", "Detail Menu2" etc.?
  • How can I add an id to a route in a menu? (eg. controller/action?id= Yii::$app->user->id)

Thank you for your answers.

menu missing on r=admin page

Hi,

I've installed yii2-admin but having an issue with the admin page. It should be showing a menu with assignments, roles, rules, etc. - but no menu is showing up - only the assignments grid/page is showed.

Any clue/hints? :)

CSRF validation error

/backend/web/index.php?r=admin/role/view&id=AdminRole

Add and delete:

POST : /backend/web/index.php?r=admin/role/assign&id=AdminRole&action=delete
400 (Bad Request)

Bad Request (#400): Unable to verify your data submission.

mdmsoft\yii2-admin\views\role_script.php:31-32

                var params = $((action == 'assign' ? '#avaliable' : '#assigned')+', .role-search').serialize();
                $.post('<?= Url::toRoute(['assign','id'=>$name]) ?>&action='+action,

Ignore exceptions when getting app routes

Hi

I had a problem displaying the 'admin/routes' page. It kept showing a 404 page not found exception.

I discovered it is due to a user module I'm testing out (https://github.com/amnah/yii2-user).
One of the controllers in this module throws a 404 exception upon object creation (in the init() function) if the request does not come from the console.

This means that the yii2-admin getRouteRecrusive() and getControllerRoutes() methods can potentially throw a page not found exception when getting the app routes for 3rd party modules.

My suggestion is to put a try ... catch block when calling $this->getRouteRecrusive(Yii::$app, $result); in the RouteController->getAppRoutes() method and simply don't do anything with the thrown exceptions (or maybe log them at least).

tablePrefix not empty, table name error

        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname=yii2_app',
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
            'tablePrefix'=>'yii_',
        ],

When tablePrefix not empty

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'yii2_app.menu' doesn't exist
The SQL being executed was: SELECT COUNT(*) FROM `yii_menu` LEFT JOIN `menu` `parent` ON menu.parent=parent.id

\mdmsoft\yii2-admin\models\searchs\Menu.php:38

$query->leftJoin(['parent' => 'menu'], 'menu.parent=parent.id');

Auto pop up hints or show roles/permissions parent and child when click it.

I have create several roles, permissions, and assign some sub roles/permissions to specific roles too.
Would appreciate program can list out the parent and child when click the assignments.

It can make things more clearly , especially if you have many roles/permissions and hard to remember everything when time elapsed.

Installation failed

PHP Fatal Error โ€“ yii\base\ErrorException

Call to a member function getItems() on a non-object

  1. in /vendor/mdm-yii2/mdm-admin/mdm/admin/models/AuthItemSearch.php at line 54
    4950515253545556575859 /
    public function search($params)
    {
    /
    @var \yii\rbac\Manager $authManager */
    $authManager = Yii::$app->authManager;
    $items = $authManager->getItems(null, $this->type);
    if ($this->load($params) && $this->validate()) {
    $items = array_filter($items, function($item) {
    if (trim($this->name) === '') {
    return true;
    }
  2. yii\base\Application::handleFatalError()

Set rbac work for the module itself

It should be nice to pass the access configuration (permissions) on a per-module or per-controller basis, for example. Would you like a PR with that? We might also add a doc extension with a workaround to the issue.

tbl_menu error, migration missing

Do you have a migration or sql file for tbl_menu?
What is the menu tabs supposed to do?
I get this error when I open it

Database Exception โ€“ yii\db\Exception
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'yii2advanced.tbl_menu' doesn't exist
The SQL being executed was: SELECT COUNT(*) FROM tbl_menu
โ†ต
Caused by: PDOException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'yii2advanced.tbl_menu' doesn't exist

in C:\wamp\www\infoweb-cms\vendor\yiisoft\yii2\db\Command.php at line 404

Typo in manual?

is 'as access' defined right? not under components or modules? What is this access control? What it is used by?

    'as access' => [
        'class' => 'mdm\admin\components\AccessControl',
        'allowActions' => [
            'admin/*', // add or remove allowed actions to this list
        ]

I still believe there is a typo in 'as access' as I searched the project and found no such text in code.

Error if no cache is used

If you do not specify a caching component in your config, the module throws an error.

In Module.php at line 36:

$this->cache = Instance::ensure($this->cache, Cache::className());

Other error

\mdmsoft\yii2-admin\components\AccessHelper.php

$files = scandir($path);

The system cannot find the path specified. (code: 3);

Class 'yii\web\AccessDeniedHttpException' not found

PHP Fatal Error โ€“ yii\base\ErrorException
Class 'yii\web\AccessDeniedHttpException' not found

1. in C:\wamp\www\advanced\vendor\mdmsoft\yii2-admin\components\AccessControl.php at line 68
6364656667686970717273

    {

        if ($user->getIsGuest()) {
            $user->loginRequired();
        } else {
            throw new AccessDeniedHttpException(Yii::t('yii', 'You are not allowed to perform this action.'));
        }

    }

}

2. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\Component.php โ€“ mdm\admin\components\AccessControl::beforeAction() at line 540
3. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\Component.php โ€“ call_user_func() at line 540
4. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\Controller.php โ€“ yii\base\Component::trigger() at line 125
5. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\Module.php โ€“ yii\base\Controller::runAction() at line 435
6. in C:\wamp\www\advanced\vendor\yiisoft\yii2\web\Application.php โ€“ yii\base\Module::runAction() at line 84
7. in C:\wamp\www\advanced\vendor\yiisoft\yii2\base\Application.php โ€“ yii\web\Application::handleRequest() at line 312
8. in C:\wamp\www\advanced\backend\web\index.php โ€“ yii\base\Application::run() at line 17

2014-03-24, 10:26:56

Apache/2.4.4 (Win32)

Yii Framework/2.0.0-dev

[Qn] Relation with Yii RBAC

Hi,
is this going to add anything than just being UI on top of Yii RBAC?
I mean does it do anything else or add dependency apart from Yii2 itself?
Thanks!

Exception 'ReflectionException' with message 'Class user does not exist'

I've installed this module and when I try to use console I get error:

Exception 'ReflectionException' with message 'Class user does not exist'

in /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php:408

Stack trace:
#0 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php(408): ReflectionClass->__construct('user')
#1 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php(354): yii\di\Container->getDependencies('user')
#2 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php(147): yii\di\Container->build('user', Array, Array)
#3 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Instance.php(146): yii\di\Container->get('user')
#4 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Instance.php(120): yii\di\Instance->get(NULL)
#5 /home/fimak/web/tradesimple/vendor/mdmsoft/yii2-admin/components/AccessControl.php(33): yii\di\Instance::ensure('user', 'yii\web\User')
#6 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/base/Object.php(107): mdm\admin\components\AccessControl->init()
#7 [internal function]: yii\base\Object->__construct(Array)
#8 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php(364): ReflectionClass->newInstanceArgs(Array)
#9 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/di/Container.php(147): yii\di\Container->build('mdm\admin\compo...', Array, Array)
#10 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/BaseYii.php(344): yii\di\Container->get('mdm\admin\compo...', Array, Array)
#11 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/base/Component.php(180): yii\BaseYii::createObject(Array)
#12 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/BaseYii.php(518): yii\base\Component->__set('as access', Array)
#13 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/base/Object.php(105): yii\BaseYii::configure(Object(yii\console\Application), Array)
#14 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/base/Application.php(202): yii\base\Object->__construct(Array)
#15 /home/fimak/web/tradesimple/vendor/yiisoft/yii2/console/Application.php(79): yii\base\Application->__construct(Array)
#16 /home/fimak/web/tradesimple/yii(29): yii\console\Application->__construct(Array)
#17 {main}

/common/config/main.php

return [
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
    'extensions' => require(__DIR__ . '/../../vendor/yiisoft/extensions.php'),
    'components' => [
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
        ],
    ],
    'modules'=>[
        'admin' => [
            'class' => 'mdm\admin\Module',
        ],
    ],
    'as access' => [
        'class' => 'mdm\admin\components\AccessControl',
        'allowActions' => [
            'admin/*',
        ],
    ],
];

Change biz_rule to rule_name

Change biz_rule to rule_name, and change biz_url in tables from DBMnager, Yii 2 has updated this

And

yii\web\VerbFilter, yii\web\AccessControll to
yii\filters\VerbFilter, yii\filters\AccessControll

Check new release, ok.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.