php-casbin / php-casbin

An authorization library that supports access control models like ACL, RBAC, ABAC in PHP .
https://casbin.org
Apache License 2.0
1.23k stars 128 forks source link

Is there an example of FilteredAdapter or implement document ? #56

Closed pigochu closed 3 years ago

pigochu commented 4 years ago

I am trying yii-permission , and post an issue.

https://github.com/php-casbin/yii-permission/issues/6

Becasue every request will query all data from casbin_rule, If i have many domain and user , the result will be very large.

I think FilteredAdapter may fix the problem , but I can not find any example for php version. Anyone who has implemented it for mysql( or any database ) ? please provide it , thanks.

leeqvip commented 4 years ago

You can use an adapter that implements FilteredAdapter, but the official has not yet provided such an adapter

leeqvip commented 3 years ago

@pigochu Now in the latest version, we have provided the FilteredAdapter interface, and have built-in FileFilteredAdapter.

hsluoyz commented 3 years ago

@pigochu See:

https://github.com/php-casbin/php-casbin/blob/master/src/Persist/FilteredAdapter.php https://github.com/php-casbin/php-casbin/blob/master/src/Persist/Adapters/FileFilteredAdapter.php

pigochu commented 3 years ago

I know there is FilterAdapter originally, I just want to find if anyone implements for database.

hsluoyz commented 3 years ago

@pigochu which DB adapter do you use? So we can add the feature to that first.

pigochu commented 3 years ago

@hsluoyz Thank you I use yii2 activerecord and mysql , I think php-casbin/database-adapter could implement it for all sql databases.

hsluoyz commented 3 years ago

@pigochu can you send an issue to: https://github.com/php-casbin/database-adapter to ask for the FilteredAdapter feature, so we can better track the progress?

pigochu commented 3 years ago

Thanks I just added the issue.. https://github.com/php-casbin/database-adapter/issues/4

hsluoyz commented 3 years ago

Thanks. Closed here. Moved to: https://github.com/php-casbin/database-adapter/issues/4