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

Argument 1 passed to Casbin\Rbac\DefaultRoleManager\RoleManager::hasLink() must be of the type string, int given, called in /var/www/html/amitdeveloper28/vendor/casbin/casbin/src/Util/BuiltinOperations.php on line 440 #36

Closed amitgoldy1 closed 2 years ago

amitgoldy1 commented 2 years ago

I am getting this issue, when I used following steps to reproduce this issue.

  1. I am using laravel Laravel Framework 6.20.38.
  2. add permission of logged user in laravel. Below are my code: $email = Auth::user()->email; // adds permissions to a user \Enforcer::addPermissionForUser($email, '/photo/index', 'GET');
  3. When, I hit this allow path, I am getting this error:
  4. Argument 1 passed to Casbin\Rbac\DefaultRoleManager\RoleManager::hasLink() must be of the type string, int given, called in /var/www/html/amitdeveloper28/vendor/casbin/casbin/src/Util/BuiltinOperations.php on line 440
hsluoyz commented 2 years ago

@basakest @techoner

basakest commented 2 years ago

Are you using the default lauthz-rbac-model.conf configuration file? I tried to reproduce this error, but did not succeed.

amitgoldy1 commented 2 years ago

Yes, I am using default model file. Below are the code:

[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)

amitgoldy1 commented 2 years ago

I am using this middleware in web.php file.

Route::group(['middleware' => ['http_request']], function () { Route::resource('photo', 'PhotoController'); });

leeqvip commented 2 years ago

@basakest @amitgoldy1 There should be a need to convert the AuthIdentifier to a string : https://github.com/php-casbin/laravel-authz/blob/master/src/Middlewares/RequestMiddleware.php#L53

hsluoyz commented 2 years ago

@basakest plz work on it

leeqvip commented 2 years ago

:tada: This issue has been resolved in version 3.0.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: