bedezign / yii2-audit

Yii2 Audit records and displays web/cli requests, database changes, php/js errors and associated data.
https://bedezign.github.io/yii2-audit/
Other
193 stars 112 forks source link

PHP Fatal Error – yii\base\ErrorException Call to a member function checkAccess() on a non-object #13

Closed cloudswitch closed 9 years ago

cloudswitch commented 9 years ago

when trying to access ?r=auditing/default/trail

  1. in D:\wamp\www\basic\vendor\yiisoft\yii2\web\User.php
  2. $access = $auth->checkAccess($this->getId(), $permissionName, $params);

I'm using yii2-user. Can it be the problem? Thanks!

Blizzke commented 9 years ago

The module uses the default Yii2 AccessControl action filter to check permissions. The AccessRule functionality assumes that there is an AuthenticationManager configured. If the yii2-user module does not support RBAC in the way the framework expects, I'm afraid that at this point you'll have to disable the checking for a role. Perhaps we can add some kind of a callback function functionality so that you can implement the access check yourself?

cloudswitch commented 9 years ago

oooookay, so basically I don't want to use roles, only rules. sorry I know it's not your task to make it clear for me, but if you can help me how can I disable checking for roles, I would be grateful. Meanwhile I'm also searching for a soultion, but as I'm beginner, for me it's very hard.

Blizzke commented 9 years ago

I'm trying to figure out what or why. I was just saying that the module was written expecting default yii behavior (and requires an authManager if you want to use roles). I don't know if the yii2-user module changes anything there.

You can configure the module to not check roles by adding 'accessRoles' => null to its configuration. Please beware that this opens up the auditing for everyone, unless you also add 'accessUsers' => array(userIds) to limit it to specific users. Please refer to the Auditing.php file for the configuration options.

cloudswitch commented 9 years ago

Thanks a lot! It works now! Super! You are a pro! are you willing to teach me? :) I'm trying to use this one:

'components' => [
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
        ],

but as I mentioned, I'm trying to use only rules at the moment (and I don't know yet how it can be implemented)

MGHollander commented 9 years ago

Did you read http://www.yiiframework.com/doc-2.0/guide-security-authorization.html ? This is some basic information about the Yii2 basic roles and rules. Especially in the RBAC section. Good luck!

Blizzke commented 9 years ago

I've also updated the README to reflect the fact that the user should have RBAC active to use checking on roles. Closing this issue as it is not a real problem.