Authorization within filtered, sorted, and paged lists #329
Unanswered
jonathaneckman
asked this question in
Q&A
Replies: 1 comment
-
@jonathaneckman Thanks for the link to the Oso article and your thoughts. I feel validated, that I am not the only one having problems integrating it. May I ask, what conclusions you’ve arrived at? As for me, I think building a Local Index and using it to join the local data might be the way to go. @aaguiarz It would be really useful if there was a minimal example how such a Local Index could be built using the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have read Search with Permissions but am still struggling to see an efficient way to handle this basic use case. Say I have an endpoint in my apps API that allows the client to request a list of projects that can be paged, sorted, and filtered. It is rendered on the page as a table with:
Only my database has the context to know how to page, filter, and sort. Only my FGA store has the context to know whether an item in the results can be viewed by the user.
Below are your recommended approaches and where I'm getting stuck in each.
Option 1: Search, Then Check
/check
to verify the user can see each of the results, so 100 checks will be performed in a batch./check
calls or with the final "viewable" list in hand, now callListRelations
using the SDK to get the permissions array for each individual item (ex: can_edit and can_delete).To prevent step 5, I know I could filter my db query so it mimics the relationships defined in the tuples that are evaluated during the checks, but this feels like complexity would quickly accumulate within my queries and business logic. This flavor of complexity is the very thing I had hoped FGA would eliminate.
Option 2: Build A Local Index From Changes Endpoint, Search, Then Check
To build an index, I'd run this process at some frequency or triggered by some event:
/changes
API. This does not return concentric relationships. Only a list of changes to tuples I have added and removed from my store./expand
for each of these changed tuples to get the concentric relationships. It is not clear how this would work. See question below.Now with these permissions in my database, I can very easily query for a filtered, sorted, paged, and authorized list from my own database:
I see
/expand
is recommended to expand the changed tuples in your docs to get the concentric relationships. Say I have a model where:The
/changes
endpoint would alert me thatuser:X
now hasadmin
relation onsystem:my-system
. Would I have to then use expand to walk the graph down to the lowest level "tasks" type? Is there an easier way?Ideal solution?
It seems that to solve this, 1 of 2 things needs to be true:
The latter feels the most correct. Oso seems to be trying to solve this with Distributed Authorization. A solution in my (currently FGA amateur) mind would be something like:
/changes
endpoint I can poll where FGA could send a list of flattened tuples (concentric and direct) to detect when a relationship between a user and a type has changed.That said, even this feels less than ideal because 1 change at a high level (like adding or removing a system admin) could trigger a new tuple for every row in my database at a lower level (such as tasks from my example above).
Help
At the moment, I don't see how either options would be viable for my use case. Option 1 feels possible but incredibly inefficient and Option 2 doesn't seem possible unless I know exactly what a change to a direct relationship tuple means within the context of my application.
I am new to FGA and trying to ramp up quickly, but am hitting this wall. Help me out. What am I missing?
Beta Was this translation helpful? Give feedback.
All reactions