permify icon indicating copy to clipboard operation
permify copied to clipboard

Option for an array of permissions to Lookup Entity

Open EgeAytin opened this issue 1 year ago • 2 comments

Provide an option for an array of permissions to client.permission.lookupEntity and have the response group entity IDs by permissions.

EgeAytin avatar Jul 18 '24 10:07 EgeAytin

Hi @EgeAytin I was going through and thinking to pick this , possible to assign me pls ,What I am thinking is - Update Proto

  1. Modify PermissionLookupEntityRequest to accept permissions as a list.
  2. Change PermissionLookupEntityResponse and PermissionLookupEntityStreamResponse to return data in the format <permission, list<EntityIds>>, with each key defaulting to an empty list. Update Lookup Engine
  3. Adjust lookupEntity and lookupEntityStream to handle a list of permissions.
  4. Ensure the callback function returns permissions for specific EntityIDs in LookupEntity.
  5. Implement a schema walk for all permissions. If all permissions fail, return an error. Otherwise, process the successful ones further. After this I have two approach Approach 1 :-
  6. We have to somehow need to pass list of permissions to EntityFilter function in schemaBasedEntityFilter.go for which either we update PermissionEntityFilterRequest proto's EntityReference as list of References , or we update RelationReference proto's Relations as list of string which is used as permissions.
  7. From EntityFilter function we need to invoke RelationshipLinkedEntrances function in linkedSchema.go which invokes findEntrance function so we again need to update either this function accept target param as list of RelationReference or we have updated RelationReference with list of relations.
  8. From Here for each permission we can invoke findEntrance in a new goroutine and we need to make sure update of visits function to be thread safe and it saves us from some duplicate work and I think it should be pretty much optimized And finally from here we would got list of entrances and we can keep our rest of flow as almost same only i think function type would update according to our proto updates.

I would need your inputs if I am not missing anything and which way should we go should we update proto PermissionEntityFilterRequest or RelationReference

  1. Update relevant test cases and Add more test cases

Approach 2:-

  1. Just invoke EntityFilter from lookup.go in for loop on all permission and each invoke to EntityFilter in a new goroutine and wait for all goroutine to be completed
  2. Add more test cases

Approach 1 is more optimized but it would required to update lot of codebase and its kind of changing our main important base design Approach 2 is not optimized it may have some duplicate works while finding entrances and after that exploring those entrances also but it would be more simple

I would like to hear your valuable feedback before I invest my more time to start doing the coding stuff which way should we go or if you have some improvements or some other thought around same .

ankitsheoran1 avatar Jul 29 '24 10:07 ankitsheoran1

Hi @ankitsheoran1, firs approach seems legit you can go to that direction. If you need any help, just let us know. Happy hacking!

EgeAytin avatar Aug 05 '24 09:08 EgeAytin