casbin
casbin copied to clipboard
[Feature] should we add paging feature for getRolesForUser or getPermissionsForUser API?
**Want to prioritize this issue? LOW
Is your feature request related to a problem? Please describe. when a user get a large scale of roles or permission, it is imposible to get all of the permissions or roles in one request.
Describe the solution you'd like I'd like to add a pagnation options for those API.
Describe alternatives you've considered I am not sure if we already have an alternative to cover this situation.
@tangyang9464 @closetool @sagilio
@iyjian how many objects do you query?
for a user, there may be thousands of thousands of granted permission objects, and we have a portal to view this objects, so I was wondering if we have a way to paging this results on the server side.
@hsluoyz
@tangyang9464
@iyjian We don't have this option. Could you make a PR for this?
I can try
the proposal is add pagnation arguments for method getpermissionsforuser, just like:
getpermissionsforuser(user = 'user1', page = 1, limit = 1000000)
page and limit should with a default value for adopting old version.
is it ok?
the proposal is add pagnation arguments for method getpermissionsforuser, just like:
getpermissionsforuser(user = 'user1', page = 1, limit = 1000000)page and limit should with a default value for adopting old version.
is it ok?
@iyjian Because getpermissionsforuser traverses all policies and then filters out those that meet the requirements. If we query the second page, should we need to traverse from the beginning?
it depens on adapter implement. It can be a cursor.
it depens on adapter implement. It can be a cursor.
In fact getpermissionsforuser queries the policies in memory instead of querying the database through the adapter
does getpermissionsforuser intended for searching permissions for management? if so, I think we should implement it in adapter.
@iyjian what adapter do you use?
does getpermissionsforuser intended for searching permissions for management? if so, I think we should implement it in adapter.
@iyjian The memory is consistent with the policies in the database. Can reading from adapter bring any changes?
@iyjian you can extend the role manager and its GetRoles() function to have pagination.