php-casbin / laravel-authz

An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.
Apache License 2.0
272 stars 46 forks source link

Call to undefined method Casbin\\Enforcer::buildIncrementalRoleLinks() #26

Closed rus-ik closed 2 years ago

rus-ik commented 2 years ago

Starting from v2.2.0 I'm getting the following error while executing Enforcer::deleteRoleForUser

Call to undefined method Casbin\Enforcer::buildIncrementalRoleLinks()\n#0 /var/www/html/vendor/casbin/casbin/src/ManagementEnforcer.php(582): Casbin\InternalEnforcer->removePolicyInternal()\n#1 /var/www/html/vendor/casbin/casbin/src/ManagementEnforcer.php(540): Casbin\ManagementEnforcer->removeNamedGroupingPolicy()\n#2 /var/www/html/vendor/casbin/casbin/src/Enforcer.php(100): Casbin\ManagementEnforcer->removeGroupingPolicy()\n#3 /var/www/html/app/Observers/Auth/UserAccessGroupObserver.php(65): Casbin\Enforcer->deleteRoleForUser()\n#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(412): ... casbin/casbin version is v3.6.0

If it's difficult to implement, then it seems "require" in composer.json is not quite correct..

"require" : { "casbin/casbin": "~3.1", ... }

hsluoyz commented 2 years ago

@basakest

basakest commented 2 years ago

I tried to use the corresponding version of the composer package to reproduce this error, but I got another error, the error message is as follows: Class Lauthz\Adapters\DatabaseAdapter contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Casbin\Persist\UpdatableAdapter::updatePolicies). Can you provide some other information?

Screen Shot 2021-07-29 at 10 04 05 AM Screen Shot 2021-07-29 at 10 04 37 AM Screen Shot 2021-07-29 at 10 05 27 AM
hsluoyz commented 2 years ago

@techoner

rus-ik commented 2 years ago

Any ETA of the bugfix, guys?

rus-ik commented 2 years ago

hey guys, the problem is that .. the minimal workable version of laravel-authz (it seems it was v1.4 or 1.5, which worked fine w/o the error mentioned above) is not working with the latest laravel v8.. and since we've moved forward to v8 we cannot downgrade to make everything work fine again like it was..

So can you please either catchup in v1.5 to laravel v8 or to fix the bug in the latest version.. Thanks in advance!

image

hsluoyz commented 2 years ago

@basakest plz support Laravel 8

leeqvip commented 2 years ago

@rus-ik Can you upgrade laravel-authz to the latest version(v2.4.0)?

rus-ik commented 2 years ago

It seems it's a tricky bug: image

rus-ik commented 2 years ago

here is my model.conf:

[request_definition] r = sub, obj, act

[policy_definition] p = sub, obj, act

[roledefinition] g = , _

[policy_effect] e = some(where (p.eft == allow))

[matchers] m = g(r.sub, p.sub) && keyMatch2(r.obj, p.obj) && regexMatch(r.act, p.act)

basakest commented 2 years ago

I'm sorry, but I still haven't been able to reproduce this error

Screen Shot 2021-08-07 at 11 48 29 AM
hsluoyz commented 2 years ago

@rus-ik can you provide a fully reproducible code repo?

rus-ik commented 2 years ago

Sorry guys, it turned out that we had overloaded casbin classes (mainly to suppress the not controlled logging) and after the right upgrade everything works fine. Thank you for your time and attention!

But nonetheless, it'd be great to have any feature for the logging switching in the places like this one: https://github.com/php-casbin/php-casbin/blob/master/src/CoreEnforcer.php#L365

And to have a short, one-line logging like this one, out of the box: ... [2021-08-08 11:00:10] prod.INFO: DENIED 212.118.111.222 - o.ivanov@mail.ru "GET" "/api/v1/role1/users" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36" ...

/**

hsluoyz commented 2 years ago

@rus-ik can you make a PR?

rus-ik commented 2 years ago

I will, but .. not now..